Documentation
¶
Index ¶
- Variables
- func GetNodeScore(info *NodeInfo) float64
- func NewAllocator(n *NodeInfo) *allocator
- func NewDeviceBinpackPriority(number int) *sortPriority[*DeviceInfo]
- func NewDeviceInfoMapByNode(node *corev1.Node) (map[int]*DeviceInfo, error)
- func NewDeviceSpreadPriority(number int) *sortPriority[*DeviceInfo]
- func NewNodeBinpackPriority() *sortPriority[*NodeInfo]
- func NewNodeSpreadPriority() *sortPriority[*NodeInfo]
- func NewSortPriority[T any](less ...LessFunc[T]) *sortPriority[T]
- type ClaimDevice
- type ContainerDevices
- type DeviceInfo
- func (dev *DeviceInfo) AllocatableCores() int
- func (dev *DeviceInfo) AllocatableMemory() int
- func (dev *DeviceInfo) AllocatableNumber() int
- func (dev *DeviceInfo) GetComputeCapability() int
- func (dev *DeviceInfo) GetID() int
- func (dev *DeviceInfo) GetNUMA() int
- func (dev *DeviceInfo) GetTotalCore() int
- func (dev *DeviceInfo) GetTotalMemory() int
- func (dev *DeviceInfo) GetTotalNumber() int
- func (dev *DeviceInfo) GetType() string
- func (dev *DeviceInfo) GetUUID() string
- func (dev *DeviceInfo) Healthy() bool
- func (dev *DeviceInfo) Mig() bool
- type GPUInfo
- type LessFunc
- type NodeDeviceInfos
- type NodeInfo
- func (n *NodeInfo) GetAvailableCore() int
- func (n *NodeInfo) GetAvailableMemory() int
- func (n *NodeInfo) GetAvailableNumber() int
- func (n *NodeInfo) GetDeviceCount() int
- func (n *NodeInfo) GetDeviceMap() map[int]*DeviceInfo
- func (n *NodeInfo) GetMaxCapability() int
- func (n *NodeInfo) GetName() string
- func (n *NodeInfo) GetNode() *corev1.Node
- func (n *NodeInfo) GetTotalCore() int
- func (n *NodeInfo) GetTotalMemory() int
- func (n *NodeInfo) GetTotalNumber() int
- type PodDevices
Constants ¶
This section is empty.
Variables ¶
var ( // ByAllocatableMemoryAsc Compare the assignable memory of two devices in ascending order ByAllocatableMemoryAsc = func(p1, p2 *DeviceInfo) bool { return p1.AllocatableMemory() < p2.AllocatableMemory() } // ByAllocatableMemoryDes Compare the assignable memory of two devices in descending order ByAllocatableMemoryDes = func(p1, p2 *DeviceInfo) bool { return p1.AllocatableMemory() > p2.AllocatableMemory() } // ByAllocatableCoresAsc Compare the assignable cores of two devices in ascending order ByAllocatableCoresAsc = func(p1, p2 *DeviceInfo) bool { return p1.AllocatableCores() < p2.AllocatableCores() } // ByAllocatableCoresDes Compare the assignable cores of two devices in descending order ByAllocatableCoresDes = func(p1, p2 *DeviceInfo) bool { return p1.AllocatableCores() > p2.AllocatableCores() } // ByDeviceIdAsc Compare the device id of two devices in ascending order ByDeviceIdAsc = func(p1, p2 *DeviceInfo) bool { return p1.GetID() < p2.GetID() } ByAllocatableNumberDes = func(p1, p2 *DeviceInfo) bool { return p1.AllocatableNumber() > p2.AllocatableNumber() } ByNumaAsc = func(p1, p2 *DeviceInfo) bool { return p1.GetNUMA() < p2.GetNUMA() } //ByAllocatableNumberAsc = func(p1, p2 *DeviceInfo) bool { // return p1.AllocatableNumber() < p2.AllocatableNumber() //} ByNodeScoreDes = func(p1, p2 *NodeInfo) bool { return GetNodeScore(p1) > GetNodeScore(p2) } ByNodeScoreAsc = func(p1, p2 *NodeInfo) bool { return GetNodeScore(p1) < GetNodeScore(p2) } ByNodeNameAsc = func(p1, p2 *NodeInfo) bool { return p1.GetName() < p2.GetName() } )
Functions ¶
func GetNodeScore ¶
GetNodeScore 计算节点空闲资源得分:空闲资源 / 资源总量 = 可用资源百分比
func NewAllocator ¶
func NewAllocator(n *NodeInfo) *allocator
func NewDeviceBinpackPriority ¶
func NewDeviceBinpackPriority(number int) *sortPriority[*DeviceInfo]
func NewDeviceInfoMapByNode ¶
func NewDeviceInfoMapByNode(node *corev1.Node) (map[int]*DeviceInfo, error)
func NewDeviceSpreadPriority ¶
func NewDeviceSpreadPriority(number int) *sortPriority[*DeviceInfo]
func NewNodeBinpackPriority ¶
func NewNodeBinpackPriority() *sortPriority[*NodeInfo]
func NewNodeSpreadPriority ¶
func NewNodeSpreadPriority() *sortPriority[*NodeInfo]
func NewSortPriority ¶
Types ¶
type ClaimDevice ¶
type ClaimDevice struct {
Id int `json:"id"`
Uuid string `json:"uuid"`
Core int `json:"core"`
Memory int `json:"memory"`
}
func (*ClaimDevice) MarshalText ¶
func (c *ClaimDevice) MarshalText() (string, error)
func (*ClaimDevice) UnmarshalText ¶
func (c *ClaimDevice) UnmarshalText(text string) error
type ContainerDevices ¶
type ContainerDevices struct {
Name string `json:"name"`
Devices []ClaimDevice `json:"devices"`
}
func GetCurrentPreAllocateContainerDevice ¶
func GetCurrentPreAllocateContainerDevice(pod *corev1.Pod) (*ContainerDevices, error)
GetCurrentPreAllocateContainerDevice find the device information pre allocated to the current container.
func (*ContainerDevices) MarshalText ¶
func (c *ContainerDevices) MarshalText() (string, error)
func (*ContainerDevices) UnmarshalText ¶
func (c *ContainerDevices) UnmarshalText(text string) error
type DeviceInfo ¶
type DeviceInfo struct {
// contains filtered or unexported fields
}
func NewDeviceInfo ¶
func NewDeviceInfo(gpuInfo GPUInfo) *DeviceInfo
func (*DeviceInfo) AllocatableCores ¶
func (dev *DeviceInfo) AllocatableCores() int
AllocatableCores returns the remaining cores of this GPU device
func (*DeviceInfo) AllocatableMemory ¶
func (dev *DeviceInfo) AllocatableMemory() int
AllocatableMemory returns the remaining memory of this GPU device
func (*DeviceInfo) AllocatableNumber ¶
func (dev *DeviceInfo) AllocatableNumber() int
AllocatableNumber returns the remaining number of this GPU device
func (*DeviceInfo) GetComputeCapability ¶
func (dev *DeviceInfo) GetComputeCapability() int
GetComputeCapability returns the capability of this device
func (*DeviceInfo) GetNUMA ¶
func (dev *DeviceInfo) GetNUMA() int
GetNUMA returns the numa of this device
func (*DeviceInfo) GetTotalCore ¶
func (dev *DeviceInfo) GetTotalCore() int
GetTotalCore returns the totalCore of this device
func (*DeviceInfo) GetTotalMemory ¶
func (dev *DeviceInfo) GetTotalMemory() int
GetTotalMemory returns the totalMemory of this device
func (*DeviceInfo) GetTotalNumber ¶
func (dev *DeviceInfo) GetTotalNumber() int
GetTotalNumber returns the totalNum of this device
func (*DeviceInfo) GetType ¶
func (dev *DeviceInfo) GetType() string
GetType returns the type of this device
func (*DeviceInfo) GetUUID ¶
func (dev *DeviceInfo) GetUUID() string
GetUUID returns the uuid of this device
func (*DeviceInfo) Healthy ¶
func (dev *DeviceInfo) Healthy() bool
Healthy return whether the device is healthy
func (*DeviceInfo) Mig ¶
func (dev *DeviceInfo) Mig() bool
type NodeDeviceInfos ¶
type NodeDeviceInfos []GPUInfo
func ParseNodeDeviceInfos ¶
func ParseNodeDeviceInfos(val string) (NodeDeviceInfos, error)
func (NodeDeviceInfos) Encode ¶
func (n NodeDeviceInfos) Encode() (string, error)
type NodeInfo ¶
type NodeInfo struct {
// contains filtered or unexported fields
}
func (*NodeInfo) GetAvailableCore ¶
GetAvailableCore returns the remaining cores of this node
func (*NodeInfo) GetAvailableMemory ¶
GetAvailableMemory returns the remaining memory of this node
func (*NodeInfo) GetAvailableNumber ¶
GetAvailableNumber returns the remaining number of this node
func (*NodeInfo) GetDeviceCount ¶
GetDeviceCount returns the number of GPU devices
func (*NodeInfo) GetDeviceMap ¶
func (n *NodeInfo) GetDeviceMap() map[int]*DeviceInfo
GetDeviceMap returns each GPU device information structure
func (*NodeInfo) GetMaxCapability ¶
GetMaxCapability returns the maxCapability of GPU devices
func (*NodeInfo) GetTotalCore ¶
GetTotalCore returns the total cores of this node
func (*NodeInfo) GetTotalMemory ¶
GetTotalMemory returns the total memory of this node
func (*NodeInfo) GetTotalNumber ¶
GetTotalNumber returns the total number of this node
type PodDevices ¶
type PodDevices []ContainerDevices
func GetPodAssignDevices ¶
func GetPodAssignDevices(pod *corev1.Pod) PodDevices
func (*PodDevices) MarshalText ¶
func (p *PodDevices) MarshalText() (string, error)
func (*PodDevices) UnmarshalText ¶
func (p *PodDevices) UnmarshalText(text string) error