state

package
v0.4.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllocationInfo

type AllocationInfo struct {
	PodUid               string         `json:"pod_uid,omitempty"`
	PodNamespace         string         `json:"pod_namespace,omitempty"`
	PodName              string         `json:"pod_name,omitempty"`
	ContainerName        string         `json:"container_name,omitempty"`
	ContainerType        string         `json:"container_type,omitempty"`
	ContainerIndex       uint64         `json:"container_index,omitempty"`
	RampUp               bool           `json:"ramp_up,omitempty"`
	PodRole              string         `json:"pod_role,omitempty"`
	PodType              string         `json:"pod_type,omitempty"`
	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 memoryadvisor package
	ExtraControlKnobInfo map[string]commonstate.ControlKnobInfo `json:"extra_control_knob_info"`
	Labels               map[string]string                      `json:"labels"`
	Annotations          map[string]string                      `json:"annotations"`
	QoSLevel             string                                 `json:"qosLevel"`
}

func (*AllocationInfo) CheckMainContainer added in v0.2.0

func (ai *AllocationInfo) CheckMainContainer() bool

CheckMainContainer returns true if the AllocationInfo is for main container

func (*AllocationInfo) CheckNumaBinding added in v0.2.0

func (ai *AllocationInfo) CheckNumaBinding() bool

CheckNumaBinding returns true if the AllocationInfo is for pod with dedicated-qos and numa-binding enhancement

func (*AllocationInfo) CheckSideCar added in v0.2.0

func (ai *AllocationInfo) CheckSideCar() bool

CheckSideCar returns true if the AllocationInfo is for side-car container

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"`
	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) GetNUMANodesWithoutNUMABindingPods

func (nm NUMANodeMap) GetNUMANodesWithoutNUMABindingPods() machine.CPUSet

GetNUMANodesWithoutNUMABindingPods returns a set of numa nodes; for those numa nodes, they all don't contain numa-binding pods

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

func (ns *NUMANodeState) HasNUMABindingPods() bool

HasNUMABindingPods returns true if any AllocationInfo in this NUMANodeState is for 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

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(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