state

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: Apache-2.0 Imports: 17 Imported by: 14

Documentation

Index

Constants

View Source
const (
	PoolNameShare     = "share"
	PoolNameReclaim   = "reclaim"
	PoolNameDedicated = "dedicated"
	PoolNameReserve   = "reserve"
	PoolNameIsolation = "isolation"

	// PoolNameFallback is not a real pool, and is a union of
	// all none-reclaimed pools to put pod should have been isolated
	PoolNameFallback = "fallback"
)

notice that pool-name may not have direct mapping relations with qos-level, for instance - both isolated_shared_cores and dedicated_cores fall into PoolNameDedicated

Variables

View Source
var (
	// StaticPools are generated by cpu plugin statically,
	// and they will be ignored when reading cpu advisor list and watch response.
	StaticPools = sets.NewString(
		PoolNameReserve,
	)

	// ResidentPools are guaranteed existing in state,
	// and they are usually used to ensure stability.
	ResidentPools = sets.NewString(
		PoolNameReclaim,
	).Union(StaticPools)
)

Functions

func CheckDedicated added in v0.2.0

func CheckDedicated(ai *AllocationInfo) bool

CheckDedicated returns true if the AllocationInfo is for pod with dedicated-qos

func CheckDedicatedNUMABinding added in v0.2.0

func CheckDedicatedNUMABinding(ai *AllocationInfo) bool

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

func CheckDedicatedPool added in v0.3.0

func CheckDedicatedPool(ai *AllocationInfo) bool

CheckDedicatedPool returns true if the AllocationInfo is for a container in the dedicated pool

func CheckNUMABinding added in v0.2.0

func CheckNUMABinding(ai *AllocationInfo) bool

CheckNUMABinding returns true if the AllocationInfo is for pod with numa-binding enhancement

func CheckReclaimed added in v0.2.0

func CheckReclaimed(ai *AllocationInfo) bool

CheckReclaimed returns true if the AllocationInfo is for pod with reclaimed-qos

func CheckShared added in v0.2.0

func CheckShared(ai *AllocationInfo) bool

CheckShared returns true if the AllocationInfo is for pod with shared-qos

func GetContainerRequestedCores

func GetContainerRequestedCores() func(allocationInfo *AllocationInfo) int

func GetIsolatedQuantityMapFromPodEntries

func GetIsolatedQuantityMapFromPodEntries(podEntries PodEntries, ignoreAllocationInfos []*AllocationInfo) map[string]map[string]int

GetIsolatedQuantityMapFromPodEntries returns a map to indicates isolation info, and the map is formatted as pod -> container -> isolated-quantity

func GetSharedQuantityMapFromPodEntries added in v0.2.0

func GetSharedQuantityMapFromPodEntries(podEntries PodEntries, ignoreAllocationInfos []*AllocationInfo) map[string]int

GetSharedQuantityMapFromPodEntries returns a map to indicates quantity info for each shared pool, and the map is formatted as pool -> quantity

func IsIsolationPool added in v0.3.0

func IsIsolationPool(poolName string) bool

func SetContainerRequestedCores added in v0.3.0

func SetContainerRequestedCores(f func(allocationInfo *AllocationInfo) int)

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"`
	OwnerPoolName            string         `json:"owner_pool_name,omitempty"`
	PodRole                  string         `json:"pod_role,omitempty"`
	PodType                  string         `json:"pod_type,omitempty"`
	AllocationResult         machine.CPUSet `json:"allocation_result,omitempty"`
	OriginalAllocationResult machine.CPUSet `json:"original_allocation_result,omitempty"`

	// key by numa node id, value is assignment for the pod in corresponding NUMA node
	TopologyAwareAssignments map[int]machine.CPUSet `json:"topology_aware_assignments"`
	// key by numa node id, value is assignment for the pod in corresponding NUMA node
	OriginalTopologyAwareAssignments map[int]machine.CPUSet `json:"original_topology_aware_assignments"`
	// for ramp up calculation. notice we don't use time.Time type here to avid checksum corruption.
	InitTimestamp string `json:"init_timestamp"`

	Labels          map[string]string `json:"labels"`
	Annotations     map[string]string `json:"annotations"`
	QoSLevel        string            `json:"qosLevel"`
	RequestQuantity int               `json:"request_quantity,omitempty"`
}

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) 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) GetOwnerPoolName added in v0.2.0

func (ai *AllocationInfo) GetOwnerPoolName() string

GetOwnerPoolName parses the owner pool name for AllocationInfo

func (*AllocationInfo) GetPoolName added in v0.2.0

func (ai *AllocationInfo) GetPoolName() string

GetPoolName parses the owner pool name for AllocationInfo if owner exists, just return; otherwise, parse from qos-level

func (*AllocationInfo) GetSpecifiedPoolName added in v0.2.0

func (ai *AllocationInfo) GetSpecifiedPoolName() string

GetSpecifiedPoolName parses the owner pool name for AllocationInfo from qos-level

func (*AllocationInfo) String

func (ai *AllocationInfo) String() string

type CPUPluginCheckpoint

type CPUPluginCheckpoint struct {
	PolicyName   string            `json:"policyName"`
	MachineState NUMANodeMap       `json:"machineState"`
	PodEntries   PodEntries        `json:"pod_entries"`
	Checksum     checksum.Checksum `json:"checksum"`
}

func NewCPUPluginCheckpoint

func NewCPUPluginCheckpoint() *CPUPluginCheckpoint

func (*CPUPluginCheckpoint) MarshalCheckpoint

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

MarshalCheckpoint returns marshaled checkpoint

func (*CPUPluginCheckpoint) UnmarshalCheckpoint

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

UnmarshalCheckpoint tries to unmarshal passed bytes to checkpoint

func (*CPUPluginCheckpoint) VerifyChecksum

func (cp *CPUPluginCheckpoint) VerifyChecksum() error

VerifyChecksum verifies that current checksum of checkpoint is valid

type ContainerEntries

type ContainerEntries map[string]*AllocationInfo // Keyed by containerName.

func (ContainerEntries) GetMainContainerEntry added in v0.2.0

func (ce ContainerEntries) GetMainContainerEntry() *AllocationInfo

GetMainContainerEntry returns the main container entry in pod container entries

func (ContainerEntries) GetMainContainerPoolName added in v0.2.0

func (ce ContainerEntries) GetMainContainerPoolName() string

GetMainContainerPoolName returns the main container owner pool name in pod container entries

func (ContainerEntries) GetPoolEntry

func (ce ContainerEntries) GetPoolEntry() *AllocationInfo

func (ContainerEntries) IsPoolEntry

func (ce ContainerEntries) IsPoolEntry() bool

IsPoolEntry returns true if this entry is for a pool; otherwise, this entry is for a container entity.

type NUMANodeMap

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

func GenerateMachineStateFromPodEntries added in v0.2.0

func GenerateMachineStateFromPodEntries(topology *machine.CPUTopology, podEntries PodEntries, policyName string) (NUMANodeMap, error)

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

func GetDefaultMachineState

func GetDefaultMachineState(topology *machine.CPUTopology) NUMANodeMap

func (NUMANodeMap) Clone

func (nm NUMANodeMap) Clone() NUMANodeMap

func (NUMANodeMap) GetAvailableCPUSet added in v0.3.0

func (nm NUMANodeMap) GetAvailableCPUSet(reservedCPUs machine.CPUSet) machine.CPUSet

GetAvailableCPUSet returns available cpuset in this node

func (NUMANodeMap) GetDefaultCPUSet

func (nm NUMANodeMap) GetDefaultCPUSet() machine.CPUSet

GetDefaultCPUSet returns default cpuset in this node

func (NUMANodeMap) GetFilteredAvailableCPUSet added in v0.2.0

func (nm NUMANodeMap) GetFilteredAvailableCPUSet(reservedCPUs machine.CPUSet,
	excludeEntry, excludeWholeNUMA func(ai *AllocationInfo) bool) machine.CPUSet

GetFilteredAvailableCPUSet returns available cpuset in this node, along with the filter functions

func (NUMANodeMap) GetFilteredDefaultCPUSet added in v0.2.0

func (nm NUMANodeMap) GetFilteredDefaultCPUSet(excludeEntry, excludeWholeNUMA func(ai *AllocationInfo) bool) machine.CPUSet

GetFilteredDefaultCPUSet returns default cpuset in this node, along with the filter functions

func (NUMANodeMap) GetFilteredNUMASet added in v0.3.0

func (nm NUMANodeMap) GetFilteredNUMASet(excludeNUMAPredicate func(ai *AllocationInfo) bool) machine.CPUSet

GetFilteredNUMASet return numa set except the numa which are excluded by the predicate.

func (NUMANodeMap) String

func (nm NUMANodeMap) String() string

type NUMANodeState

type NUMANodeState struct {
	// equals to allocatable cpuset subtracting original allocation result of dedicated_cores with NUMA binding
	DefaultCPUSet machine.CPUSet `json:"default_cpuset,omitempty"`
	// equals to original allocation result of dedicated_cores with NUMA binding
	AllocatedCPUSet machine.CPUSet `json:"allocated_cpuset,omitempty"`

	PodEntries PodEntries `json:"pod_entries"`
}

func (*NUMANodeState) Clone

func (ns *NUMANodeState) Clone() *NUMANodeState

func (*NUMANodeState) ExistMatchedAllocationInfo added in v0.3.0

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

func (ns *NUMANodeState) GetAvailableCPUSet(reservedCPUs machine.CPUSet) machine.CPUSet

GetAvailableCPUSet returns available cpuset in this numa

func (*NUMANodeState) GetFilteredDefaultCPUSet added in v0.2.0

func (ns *NUMANodeState) GetFilteredDefaultCPUSet(excludeEntry, excludeWholeNUMA func(ai *AllocationInfo) bool) machine.CPUSet

GetFilteredDefaultCPUSet returns default cpuset in this numa, along with the filter functions

func (*NUMANodeState) SetAllocationInfo

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

type PodEntries

type PodEntries map[string]ContainerEntries // Keyed by podUID.

func (PodEntries) CheckPoolEmpty added in v0.2.0

func (pe PodEntries) CheckPoolEmpty(poolName string) bool

CheckPoolEmpty returns true if the given pool doesn't exist

func (PodEntries) Clone

func (pe PodEntries) Clone() PodEntries

func (PodEntries) GetCPUSetForPool added in v0.2.0

func (pe PodEntries) GetCPUSetForPool(poolName string) (machine.CPUSet, error)

GetCPUSetForPool returns cpuset that belongs to the given pool

func (PodEntries) GetFilteredPodEntries added in v0.2.0

func (pe PodEntries) GetFilteredPodEntries(filter func(ai *AllocationInfo) bool) PodEntries

GetFilteredPodEntries filter out PodEntries according to the given filter logic

func (PodEntries) GetFilteredPoolsCPUSet added in v0.2.0

func (pe PodEntries) GetFilteredPoolsCPUSet(ignorePools sets.String) machine.CPUSet

GetFilteredPoolsCPUSet returns a mapping of pools for all of them (except for those skipped ones)

func (PodEntries) GetFilteredPoolsCPUSetMap added in v0.2.0

func (pe PodEntries) GetFilteredPoolsCPUSetMap(ignorePools sets.String) map[string]machine.CPUSet

GetFilteredPoolsCPUSetMap returns a mapping of pools for all of them (except for those skipped ones)

func (PodEntries) String

func (pe PodEntries) 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 {
	// contains filtered or unexported methods
}

State interface provides methods for tracking and setting pod assignments

func NewCPUPluginState

func NewCPUPluginState(topology *machine.CPUTopology) State

func NewCheckpointState

func NewCheckpointState(stateDir, checkpointName, policyName string,
	topology *machine.CPUTopology, skipStateCorruption bool) (State, error)

Jump to

Keyboard shortcuts

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