Documentation
¶
Index ¶
- type Allocation
- type AllocationInfo
- type AllocationMap
- type AllocationResourcesMap
- func (arm AllocationResourcesMap) CalculateTargetDevicesToAllocate(ratio float64, accompanyAllocatedDeviceCount int) (int, error)
- func (arm AllocationResourcesMap) Clone() AllocationResourcesMap
- func (arm AllocationResourcesMap) GetAllocatedDeviceIDs(resourceName v1.ResourceName, podUID, containerName string) []string
- func (arm AllocationResourcesMap) GetRatioOfAccompanyResourceToTargetResource(accompanyResourceName, resourceName string) float64
- func (arm AllocationResourcesMap) IsResourceRequestSatisfied(device string, requestPerGPU map[v1.ResourceName]float64, ...) bool
- func (arm AllocationResourcesMap) String() string
- type AllocationState
- func (as *AllocationState) Clone() *AllocationState
- func (as *AllocationState) GetQuantityAllocated() float64
- func (as *AllocationState) GetQuantityAllocatedWithFilter(filter func(ai *AllocationInfo) bool) float64
- func (as *AllocationState) SetAllocationInfo(podUID string, containerName string, allocationInfo *AllocationInfo)
- func (as *AllocationState) String() string
- type ContainerEntries
- type DefaultResourceStateGenerator
- type DefaultResourceStateGeneratorRegistry
- func (r *DefaultResourceStateGeneratorRegistry) GetGenerator(resourceName string) (DefaultResourceStateGenerator, bool)
- func (r *DefaultResourceStateGeneratorRegistry) GetGenerators() map[string]DefaultResourceStateGenerator
- func (r *DefaultResourceStateGeneratorRegistry) RegisterResourceStateGenerator(resourceName string, generator DefaultResourceStateGenerator)
- type GPUPluginCheckpoint
- type PodEntries
- type PodResourceEntries
- type ReadonlyState
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Allocation ¶
type Allocation struct {
// Quantity refers to the device count or the quantity of resource allocated.
// Note: sum of quantity may be greater than allocatable because some pods can share devices.
Quantity float64 `json:"quantity"`
NUMANodes []int `json:"numa_nodes"`
}
func (*Allocation) Clone ¶
func (a *Allocation) Clone() Allocation
type AllocationInfo ¶
type AllocationInfo struct {
commonstate.AllocationMeta `json:",inline"`
AllocatedAllocation Allocation `json:"allocated_allocation"`
TopologyAwareAllocations map[string]Allocation `json:"topology_aware_allocations"`
// DeviceName will be empty if it is a resource allocation (e.g. gpu memory), but it will be non-empty if
// it is a device allocation (e.g. gpu, rdma)
DeviceName string `json:"device_name"`
}
func (*AllocationInfo) Clone ¶
func (i *AllocationInfo) Clone() *AllocationInfo
func (*AllocationInfo) String ¶
func (i *AllocationInfo) String() string
type AllocationMap ¶
type AllocationMap map[string]*AllocationState // AllocationMap keyed by device id i.e. GPU-fef8089b-4820-abfc-e83e-94318197576e
func GenerateResourceStateFromPodEntries ¶
func GenerateResourceStateFromPodEntries( podEntries PodEntries, generator DefaultResourceStateGenerator, ) (AllocationMap, error)
GenerateResourceStateFromPodEntries returns an AllocationMap of a certain resource based on pod entries
func (AllocationMap) Clone ¶
func (am AllocationMap) Clone() AllocationMap
func (AllocationMap) GetQuantityAllocated ¶
func (am AllocationMap) GetQuantityAllocated(id string) float64
func (AllocationMap) IsRequestSatisfied ¶
func (am AllocationMap) IsRequestSatisfied(id string, request float64, allocatable float64) bool
func (AllocationMap) String ¶
func (am AllocationMap) String() string
type AllocationResourcesMap ¶
type AllocationResourcesMap map[v1.ResourceName]AllocationMap
AllocationResourcesMap keyed by resource name. For devices, they are keyed by device type (e.g. rdma_device, gpu_device). For resources, they are keyed by the resource name (e.g. resource.katalyst.kubewharf.io/gpu_memory).
func GenerateMachineState ¶
func GenerateMachineState( defaultMachineStateGenerators *DefaultResourceStateGeneratorRegistry, ) (AllocationResourcesMap, error)
GenerateMachineState returns an empty AllocationResourcesMap for all resource names.
func GenerateMachineStateFromPodEntries ¶
func GenerateMachineStateFromPodEntries( podResourceEntries PodResourceEntries, defaultMachineStateGenerators *DefaultResourceStateGeneratorRegistry, ) (AllocationResourcesMap, error)
GenerateMachineStateFromPodEntries returns AllocationResourcesMap for allocated resources based on resource name along with existed pod resource entries.
func (AllocationResourcesMap) CalculateTargetDevicesToAllocate ¶ added in v0.5.50
func (arm AllocationResourcesMap) CalculateTargetDevicesToAllocate(ratio float64, accompanyAllocatedDeviceCount int) (int, error)
CalculateTargetDevicesToAllocate calculates the number of target devices to be allocated proportionally to the accompany resource devices.
func (AllocationResourcesMap) Clone ¶
func (arm AllocationResourcesMap) Clone() AllocationResourcesMap
func (AllocationResourcesMap) GetAllocatedDeviceIDs ¶ added in v0.5.50
func (arm AllocationResourcesMap) GetAllocatedDeviceIDs(resourceName v1.ResourceName, podUID, containerName string) []string
GetAllocatedDeviceIDs returns the deviceIDs that are allocated to the specific container.
func (AllocationResourcesMap) GetRatioOfAccompanyResourceToTargetResource ¶
func (arm AllocationResourcesMap) GetRatioOfAccompanyResourceToTargetResource(accompanyResourceName, resourceName string) float64
GetRatioOfAccompanyResourceToTargetResource returns the ratio of total accompany resource to total target resource. For example, if the total number of accompany resource is 4 and the total number of target resource is 2, the ratio is 2.
func (AllocationResourcesMap) IsResourceRequestSatisfied ¶ added in v0.5.49
func (arm AllocationResourcesMap) IsResourceRequestSatisfied(device string, requestPerGPU map[v1.ResourceName]float64, allocatablePerGPU map[v1.ResourceName]float64) bool
IsResourceRequestSatisfied checks if all requested resources can be satisfied for a given GPU device
func (AllocationResourcesMap) String ¶
func (arm AllocationResourcesMap) String() string
type AllocationState ¶
type AllocationState struct {
// Allocatable refers to the total quantity of resource or device count that can be allocated.
Allocatable float64 `json:"allocatable"`
PodEntries PodEntries `json:"pod_entries"`
}
func (*AllocationState) Clone ¶
func (as *AllocationState) Clone() *AllocationState
func (*AllocationState) GetQuantityAllocated ¶
func (as *AllocationState) GetQuantityAllocated() float64
func (*AllocationState) GetQuantityAllocatedWithFilter ¶
func (as *AllocationState) GetQuantityAllocatedWithFilter(filter func(ai *AllocationInfo) bool) float64
func (*AllocationState) SetAllocationInfo ¶
func (as *AllocationState) SetAllocationInfo(podUID string, containerName string, allocationInfo *AllocationInfo)
func (*AllocationState) String ¶
func (as *AllocationState) String() string
type ContainerEntries ¶
type ContainerEntries map[string]*AllocationInfo // Keyed by container name
type DefaultResourceStateGenerator ¶
type DefaultResourceStateGenerator interface {
GenerateDefaultResourceState() (AllocationMap, error)
// MustInitDefaultResourceState indicates whether the default resource state of a resource should be initialized at the start
MustInitDefaultResourceState() bool
}
DefaultResourceStateGenerator interface is used to generate default resource state for each resource
func NewDefaultResourceStateGeneratorStub ¶
func NewDefaultResourceStateGeneratorStub() DefaultResourceStateGenerator
func NewGenericDefaultResourceStateGenerator ¶
func NewGenericDefaultResourceStateGenerator( deviceNames []string, topologyRegistry *machine.DeviceTopologyRegistry, allocatable float64, mustInitDefaultResourceState bool, ) DefaultResourceStateGenerator
type DefaultResourceStateGeneratorRegistry ¶
type DefaultResourceStateGeneratorRegistry struct {
// contains filtered or unexported fields
}
func NewDefaultResourceStateGeneratorRegistry ¶
func NewDefaultResourceStateGeneratorRegistry() *DefaultResourceStateGeneratorRegistry
func (*DefaultResourceStateGeneratorRegistry) GetGenerator ¶
func (r *DefaultResourceStateGeneratorRegistry) GetGenerator(resourceName string) (DefaultResourceStateGenerator, bool)
func (*DefaultResourceStateGeneratorRegistry) GetGenerators ¶
func (r *DefaultResourceStateGeneratorRegistry) GetGenerators() map[string]DefaultResourceStateGenerator
func (*DefaultResourceStateGeneratorRegistry) RegisterResourceStateGenerator ¶
func (r *DefaultResourceStateGeneratorRegistry) RegisterResourceStateGenerator(resourceName string, generator DefaultResourceStateGenerator)
type GPUPluginCheckpoint ¶
type GPUPluginCheckpoint struct {
PolicyName string `json:"policyName"`
MachineState AllocationResourcesMap `json:"machineState"`
PodResourceEntries PodResourceEntries `json:"pod_entries"`
Checksum checksum.Checksum `json:"checksum"`
}
func NewGPUPluginCheckpoint ¶
func NewGPUPluginCheckpoint() *GPUPluginCheckpoint
func (*GPUPluginCheckpoint) MarshalCheckpoint ¶
func (cp *GPUPluginCheckpoint) MarshalCheckpoint() ([]byte, error)
MarshalCheckpoint returns marshaled checkpoint
func (*GPUPluginCheckpoint) UnmarshalCheckpoint ¶
func (cp *GPUPluginCheckpoint) UnmarshalCheckpoint(blob []byte) error
UnmarshalCheckpoint tries to unmarshal passed bytes to checkpoint
func (*GPUPluginCheckpoint) VerifyChecksum ¶
func (cp *GPUPluginCheckpoint) VerifyChecksum() error
VerifyChecksum verifies that current checksum of checkpoint is valid
type PodEntries ¶
type PodEntries map[string]ContainerEntries // Keyed by pod UID
func (PodEntries) Clone ¶
func (e PodEntries) Clone() PodEntries
func (PodEntries) GetAllocationInfo ¶
func (e PodEntries) GetAllocationInfo(uid string, name string) *AllocationInfo
func (PodEntries) SetAllocationInfo ¶
func (e PodEntries) SetAllocationInfo(podUID string, containerName string, allocationInfo *AllocationInfo)
func (PodEntries) String ¶
func (e PodEntries) String() string
type PodResourceEntries ¶
type PodResourceEntries map[v1.ResourceName]PodEntries // Keyed by resource name
func (PodResourceEntries) Clone ¶
func (pre PodResourceEntries) Clone() PodResourceEntries
func (PodResourceEntries) RemovePod ¶
func (pre PodResourceEntries) RemovePod(podUID string)
func (PodResourceEntries) String ¶
func (pre PodResourceEntries) String() string
type ReadonlyState ¶
type ReadonlyState interface {
// contains filtered or unexported methods
}
ReadonlyState interface only provides methods for tracking pod assignments
type State ¶
type State interface {
ReadonlyState
// contains filtered or unexported methods
}
State interface provides methods for tracking and setting pod assignments
func NewCheckpointState ¶
func NewCheckpointState( stateDirectoryConfig *statedirectory.StateDirectoryConfiguration, conf *qrm.QRMPluginsConfiguration, checkpointName, policyName string, defaultResourceStateGenerators *DefaultResourceStateGeneratorRegistry, skipStateCorruption bool, emitter metrics.MetricEmitter, ) (State, error)
func NewGPUPluginState ¶
func NewGPUPluginState( conf *qrm.QRMPluginsConfiguration, resourceStateGeneratorRegistry *DefaultResourceStateGeneratorRegistry, ) (State, error)