state

package
v0.5.16 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2024 License: Apache-2.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateMemoryContainerAllocationMeta added in v0.5.12

func GenerateMemoryContainerAllocationMeta(req *pluginapi.ResourceRequest, qosLevel string) commonstate.AllocationMeta

GenerateMemoryContainerAllocationMeta generates allocation metadata specifically for a memory resource request. This function is a wrapper around GenerateGenericContainerAllocationMeta, but it automatically computes the owner pool name using a QoS level and a specific annotation from the request. Parameters: - req: The resource request for memory, containing information about the pod and container. - qosLevel: The QoS (Quality of Service) level for the container. Returns: - A pointer to a commonstate.AllocationMeta struct generated based on the memory-specific logic.

func GetReclaimedNUMAHeadroom added in v0.5.16

func GetReclaimedNUMAHeadroom(numaHeadroom map[int]int64, numaSet machine.CPUSet) int64

GetReclaimedNUMAHeadroom returns the total reclaimed headroom for the given NUMA set.

func GetRequestedQuantityFromPodEntries added in v0.5.16

func GetRequestedQuantityFromPodEntries(podEntries PodEntries, allocationFilter func(info *AllocationInfo) bool) int64

GetRequestedQuantityFromPodEntries returns total quantity of reclaim without numa_binding requested

func SetReadWriteState added in v0.5.14

func SetReadWriteState(state State)

SetReadWriteState updates the readWriteState in a thread-safe manner.

func SetReadonlyState added in v0.5.14

func SetReadonlyState(state ReadonlyState)

SetReadonlyState updates the readonlyState in a thread-safe manner.

func WrapAllocationMetaFilter added in v0.5.16

func WrapAllocationMetaFilter(metaFilter func(meta *commonstate.AllocationMeta) bool) func(info *AllocationInfo) bool

WrapAllocationMetaFilter takes a filter function that operates on AllocationMeta and returns a wrapper function that applies the same filter to an AllocationInfo by extracting its AllocationMeta.

Types

type AllocationInfo

type AllocationInfo struct {
	commonstate.AllocationMeta `json:",inline"`

	AggregatedQuantity   uint64         `json:"aggregated_quantity"`
	NumaAllocationResult machine.CPUSet `json:"numa_allocation_result,omitempty"`

	// keyed by numa node id, value is assignment for the pod in corresponding NUMA node
	TopologyAwareAllocations map[int]uint64 `json:"topology_aware_allocations"`

	// keyed by control knob names referred in memory advisor package
	ExtraControlKnobInfo map[string]commonstate.ControlKnobInfo `json:"extra_control_knob_info"`
}

func (*AllocationInfo) Clone

func (ai *AllocationInfo) Clone() *AllocationInfo

func (*AllocationInfo) GetResourceAllocation added in v0.3.0

func (ai *AllocationInfo) GetResourceAllocation() (*pluginapi.ResourceAllocation, error)

GetResourceAllocation transforms resource allocation information into *pluginapi.ResourceAllocation

func (*AllocationInfo) String

func (ai *AllocationInfo) String() string

type ContainerEntries

type ContainerEntries map[string]*AllocationInfo // Keyed by container name

type MemoryPluginCheckpoint

type MemoryPluginCheckpoint struct {
	PolicyName         string               `json:"policyName"`
	MachineState       NUMANodeResourcesMap `json:"machineState"`
	NUMAHeadroom       map[int]int64        `json:"numa_headroom"`
	PodResourceEntries PodResourceEntries   `json:"pod_resource_entries"`
	SocketTopology     map[int]string       `json:"socket_topology,omitempty"`
	Checksum           checksum.Checksum    `json:"checksum"`
}

func NewMemoryPluginCheckpoint

func NewMemoryPluginCheckpoint() *MemoryPluginCheckpoint

func (*MemoryPluginCheckpoint) MarshalCheckpoint

func (cp *MemoryPluginCheckpoint) MarshalCheckpoint() ([]byte, error)

MarshalCheckpoint returns marshaled checkpoint

func (*MemoryPluginCheckpoint) UnmarshalCheckpoint

func (cp *MemoryPluginCheckpoint) UnmarshalCheckpoint(blob []byte) error

UnmarshalCheckpoint tries to unmarshal passed bytes to checkpoint

func (*MemoryPluginCheckpoint) VerifyChecksum

func (cp *MemoryPluginCheckpoint) VerifyChecksum() error

VerifyChecksum verifies that current checksum of checkpoint is valid

type NUMANodeMap

type NUMANodeMap map[int]*NUMANodeState // keyed by numa node id

func GenerateMemoryStateFromPodEntries added in v0.2.0

func GenerateMemoryStateFromPodEntries(machineInfo *info.MachineInfo,
	podEntries PodEntries, reserved map[v1.ResourceName]map[int]uint64,
) (NUMANodeMap, error)

GenerateMemoryStateFromPodEntries returns NUMANodeMap for memory based on machine info and reserved resources along with existed pod entries

func GenerateResourceState added in v0.2.0

func GenerateResourceState(machineInfo *info.MachineInfo, reserved map[v1.ResourceName]map[int]uint64, resourceName v1.ResourceName) (NUMANodeMap, error)

GenerateResourceState returns NUMANodeMap for given resource based on machine info and reserved resources

func GenerateResourceStateFromPodEntries added in v0.2.0

func GenerateResourceStateFromPodEntries(machineInfo *info.MachineInfo,
	podEntries PodEntries, reserved map[v1.ResourceName]map[int]uint64, resourceName v1.ResourceName,
) (NUMANodeMap, error)

GenerateResourceStateFromPodEntries returns NUMANodeMap for given resource based on machine info and reserved resources along with existed pod entries

func (NUMANodeMap) BytesPerNUMA added in v0.2.0

func (nm NUMANodeMap) BytesPerNUMA() (uint64, error)

BytesPerNUMA is a helper function to parse memory capacity at per numa level

func (NUMANodeMap) Clone

func (nm NUMANodeMap) Clone() NUMANodeMap

func (NUMANodeMap) GetNUMANodesWithoutDedicatedNUMABindingAndNUMAExclusivePods added in v0.5.12

func (nm NUMANodeMap) GetNUMANodesWithoutDedicatedNUMABindingAndNUMAExclusivePods() machine.CPUSet

GetNUMANodesWithoutDedicatedNUMABindingAndNUMAExclusivePods returns a set of numa nodes; for those numa nodes, they all don't contain dedicated with numa-binding and numa-exclusive pods

func (NUMANodeMap) GetNUMANodesWithoutReclaimedActualNUMABindingPods added in v0.5.16

func (nm NUMANodeMap) GetNUMANodesWithoutReclaimedActualNUMABindingPods() machine.CPUSet

GetNUMANodesWithoutReclaimedActualNUMABindingPods returns a set of numa nodes; for those numa nodes, they all don't contain reclaimed actual numa binding pods

func (NUMANodeMap) GetNUMANodesWithoutReclaimedNonActualNUMABindingPods added in v0.5.16

func (nm NUMANodeMap) GetNUMANodesWithoutReclaimedNonActualNUMABindingPods() machine.CPUSet

GetNUMANodesWithoutReclaimedNonActualNUMABindingPods returns a set of numa nodes; for those numa nodes, they all don't contain reclaimed non-actual numa binding pods

func (NUMANodeMap) GetNUMANodesWithoutSharedOrDedicatedNUMABindingPods added in v0.5.12

func (nm NUMANodeMap) GetNUMANodesWithoutSharedOrDedicatedNUMABindingPods() machine.CPUSet

GetNUMANodesWithoutSharedOrDedicatedNUMABindingPods returns a set of numa nodes; for those numa nodes, they all don't contain shared or dedicated numa-binding pods

func (NUMANodeMap) GetNonActualNUMABindingAvailableHeadroom added in v0.5.16

func (nm NUMANodeMap) GetNonActualNUMABindingAvailableHeadroom(numaHeadroom map[int]int64) int64

type NUMANodeResourcesMap

type NUMANodeResourcesMap map[v1.ResourceName]NUMANodeMap // keyed by resource name

func GenerateMachineState added in v0.2.0

func GenerateMachineState(machineInfo *info.MachineInfo, reserved map[v1.ResourceName]map[int]uint64) (NUMANodeResourcesMap, error)

GenerateMachineState returns NUMANodeResourcesMap based on machine info and reserved resources

func GenerateMachineStateFromPodEntries added in v0.2.0

func GenerateMachineStateFromPodEntries(machineInfo *info.MachineInfo,
	podResourceEntries PodResourceEntries, reserved map[v1.ResourceName]map[int]uint64,
) (NUMANodeResourcesMap, error)

GenerateMachineStateFromPodEntries returns NUMANodeResourcesMap based on machine info and reserved resources (along with existed pod entries)

func (NUMANodeResourcesMap) Clone

func (NUMANodeResourcesMap) String

func (nrm NUMANodeResourcesMap) String() string

type NUMANodeState

type NUMANodeState struct {
	TotalMemSize   uint64     `json:"total"`
	SystemReserved uint64     `json:"systemReserved"`
	Allocatable    uint64     `json:"allocatable"`
	Allocated      uint64     `json:"Allocated"`
	Free           uint64     `json:"free"`
	PodEntries     PodEntries `json:"pod_entries"`
}

NUMANodeState records the amount of memory per numa node (in bytes)

func (*NUMANodeState) Clone

func (ns *NUMANodeState) Clone() *NUMANodeState

func (*NUMANodeState) ExistMatchedAllocationInfo added in v0.5.16

func (ns *NUMANodeState) ExistMatchedAllocationInfo(f func(ai *AllocationInfo) bool) bool

ExistMatchedAllocationInfo returns true if the stated predicate holds true for some pods of this numa else it returns false.

func (*NUMANodeState) GetNonActualNUMABindingAvailableHeadroom added in v0.5.16

func (ns *NUMANodeState) GetNonActualNUMABindingAvailableHeadroom(numaHeadroom int64) int64

func (*NUMANodeState) HasDedicatedNUMABindingAndNUMAExclusivePods added in v0.5.12

func (ns *NUMANodeState) HasDedicatedNUMABindingAndNUMAExclusivePods() bool

HasDedicatedNUMABindingAndNUMAExclusivePods returns true if any AllocationInfo in this NUMANodeState is for dedicated with numa-binding and numa-exclusive

func (*NUMANodeState) HasReclaimedActualNUMABindingPods added in v0.5.16

func (ns *NUMANodeState) HasReclaimedActualNUMABindingPods() bool

HasReclaimedActualNUMABindingPods returns true if any AllocationInfo in this NUMANodeState is for reclaimed actual numa-binding

func (*NUMANodeState) HasReclaimedNonActualNUMABindingPods added in v0.5.16

func (ns *NUMANodeState) HasReclaimedNonActualNUMABindingPods() bool

HasReclaimedNonActualNUMABindingPods returns true if any AllocationInfo in this NUMANodeState is for reclaimed non-actual numa-binding

func (*NUMANodeState) HasSharedOrDedicatedNUMABindingPods added in v0.5.12

func (ns *NUMANodeState) HasSharedOrDedicatedNUMABindingPods() bool

HasSharedOrDedicatedNUMABindingPods returns true if any AllocationInfo in this NUMANodeState is for shared or dedicated numa-binding

func (*NUMANodeState) SetAllocationInfo

func (ns *NUMANodeState) SetAllocationInfo(podUID string, containerName string, allocationInfo *AllocationInfo)

SetAllocationInfo adds a new AllocationInfo (for pod/container pairs) into the given NUMANodeState

func (*NUMANodeState) String

func (ns *NUMANodeState) String() string

type PodEntries

type PodEntries map[string]ContainerEntries // Keyed by pod UID

func (PodEntries) Clone

func (pe PodEntries) Clone() PodEntries

func (PodEntries) GetMainContainerAllocation added in v0.2.0

func (pe PodEntries) GetMainContainerAllocation(podUID string) (*AllocationInfo, bool)

GetMainContainerAllocation returns AllocationInfo that belongs the main container for this pod

type PodResourceEntries

type PodResourceEntries map[v1.ResourceName]PodEntries // Keyed by resource name

func (PodResourceEntries) Clone

func (PodResourceEntries) String

func (pre PodResourceEntries) String() string

type ReadonlyState

type ReadonlyState interface {
	GetMachineInfo() *info.MachineInfo
	GetReservedMemory() map[v1.ResourceName]map[int]uint64
	// contains filtered or unexported methods
}

ReadonlyState interface only provides methods for tracking pod assignments

func GetReadonlyState added in v0.5.14

func GetReadonlyState() (ReadonlyState, error)

GetReadonlyState retrieves the readonlyState in a thread-safe manner. Returns an error if readonlyState is not set.

type State

type State interface {
	ReadonlyState
	// contains filtered or unexported methods
}

State interface provides methods for tracking and setting pod assignments

func GetReadWriteState added in v0.5.14

func GetReadWriteState() (State, error)

GetReadWriteState retrieves the readWriteState in a thread-safe manner. Returns an error if readWriteState is not set.

func NewCheckpointState

func NewCheckpointState(stateDir, checkpointName, policyName string,
	topology *machine.CPUTopology, machineInfo *info.MachineInfo,
	reservedMemory map[v1.ResourceName]map[int]uint64, skipStateCorruption bool,
) (State, error)

func NewMemoryPluginState

func NewMemoryPluginState(topology *machine.CPUTopology, machineInfo *info.MachineInfo, reservedMemory map[v1.ResourceName]map[int]uint64) (State, error)

Jump to

Keyboard shortcuts

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