state

package
v0.5.42 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

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 amount of device allocated
	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               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 name 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 i.e. v1.ResourceName("nvidia.com/gpu")

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) Clone

func (AllocationResourcesMap) GetRatioOfAccompanyResourceToTargetResource

func (arm AllocationResourcesMap) GetRatioOfAccompanyResourceToTargetResource(accompanyResourceName, targetResourceName 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) String

func (arm AllocationResourcesMap) String() string

type AllocationState

type AllocationState struct {
	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)
}

DefaultResourceStateGenerator interface is used to generate default resource state for each resource

func NewDefaultResourceStateGeneratorStub

func NewDefaultResourceStateGeneratorStub() DefaultResourceStateGenerator

func NewGenericDefaultResourceStateGenerator

func NewGenericDefaultResourceStateGenerator(
	resourceName string,
	topologyRegistry *machine.DeviceTopologyRegistry,
) DefaultResourceStateGenerator

type DefaultResourceStateGeneratorRegistry

type DefaultResourceStateGeneratorRegistry struct {
	// contains filtered or unexported fields
}

func NewDefaultResourceStateGeneratorRegistry

func NewDefaultResourceStateGeneratorRegistry() *DefaultResourceStateGeneratorRegistry

func (*DefaultResourceStateGeneratorRegistry) GetGenerator

func (*DefaultResourceStateGeneratorRegistry) GetGenerators

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 (PodResourceEntries) GetTotalAllocatedResourceOfContainer

func (pre PodResourceEntries) GetTotalAllocatedResourceOfContainer(
	resourceName v1.ResourceName, podUID, containerName string,
) (int, sets.String)

GetTotalAllocatedResourceOfContainer returns the total allocated resource quantity of a container together with the specific resource IDs that are allocated.

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL