state

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: Apache-2.0 Imports: 14 Imported by: 14

Documentation

Index

Constants

View Source
const (
	PoolNameShare     = "share"
	PoolNameReclaim   = "reclaim"
	PoolNameDedicated = "dedicated"
	PoolNameReserve   = "reserve"
	// PoolNameFallback is not a real pool and is the union result of
	// all online pools to put pod should have been isolated
	PoolNameFallback = "fallback"
)

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
	ResidentPools = sets.NewString(
		PoolNameReclaim,
	).Union(StaticPools)
)
View Source
var GetContainerRequestedCores func(allocationInfo *AllocationInfo) int

Functions

func GetIsolatedQuantityMapFromCPUAdvisorResp

func GetIsolatedQuantityMapFromCPUAdvisorResp(resp *advisorapi.ListAndWatchResponse, chkEntries PodEntries) (map[string]map[string]int, error)

func GetIsolatedQuantityMapFromPodEntries

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

func GetIsolatedQuantityMapFromPodEntriesAndCPUAdvisorResp

func GetIsolatedQuantityMapFromPodEntriesAndCPUAdvisorResp(entries PodEntries, resp *advisorapi.ListAndWatchResponse) (map[string]map[string]int, error)

func GetPoolsQuantityMapFromCPUAdvisorResp

func GetPoolsQuantityMapFromCPUAdvisorResp(resp *advisorapi.ListAndWatchResponse) (map[string]int, error)

GetPoolsQuantityMapFromCPUAdvisorResp GetQuantityMap returns a map from cpu-set pool to cpu size; this info is constructed by advisor response, and this response contain cpu-set pool by a special container name .i.e empty string

func GetPoolsQuantityMapFromPodEntries

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

GetPoolsQuantityMapFromPodEntries is used to constrict mapping from pool name to its corresponding resource quantity

func GetPoolsQuantityMapFromPodEntriesAndCPUAdvisorResp

func GetPoolsQuantityMapFromPodEntriesAndCPUAdvisorResp(entries PodEntries, resp *advisorapi.ListAndWatchResponse) (map[string]int, error)

GetPoolsQuantityMapFromPodEntriesAndCPUAdvisorResp returns a map from cpu-set pool to cpu size; this info is constructed by combine advisor response and given pod entry list

func GetRealOwnerPoolName

func GetRealOwnerPoolName(allocationInfo *AllocationInfo) string

GetRealOwnerPoolName parses the owner pool name for a given allocation

func GetSpecifiedPoolName

func GetSpecifiedPoolName(allocationInfo *AllocationInfo) string

GetSpecifiedPoolName parses the belonging pool name for a given allocation according to QoS level

func GetSpecifiedPoolNameForSharedCores

func GetSpecifiedPoolNameForSharedCores(allocationInfo *AllocationInfo) string

GetSpecifiedPoolNameForSharedCores returns cpu enhancement from allocation

func UpdateOwnerPoolsForSharedCoresByCPUAdvisorResp

func UpdateOwnerPoolsForSharedCoresByCPUAdvisorResp(chkEntries PodEntries, resp *advisorapi.ListAndWatchResponse, poolsQuantityMap map[string]int) error

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

func (ai *AllocationInfo) Clone() *AllocationInfo

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 marshalled 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) GetPoolEntry

func (ce ContainerEntries) GetPoolEntry() *AllocationInfo

func (ContainerEntries) IsPoolEntry

func (ce ContainerEntries) IsPoolEntry() bool

type NUMANodeMap

type NUMANodeMap map[int]*NUMANodeState

func GenerateCPUMachineStateByPodEntries

func GenerateCPUMachineStateByPodEntries(topology *machine.CPUTopology, podEntries PodEntries) (NUMANodeMap, error)

GenerateCPUMachineStateByPodEntries is used to re-organize podEntries by assembling allocation info into each NUMA node

func GetDefaultMachineState

func GetDefaultMachineState(topology *machine.CPUTopology) NUMANodeMap

func (NUMANodeMap) Clone

func (nm NUMANodeMap) Clone() NUMANodeMap

func (NUMANodeMap) GetAvailableCPUSetExcludeDedicatedCoresPods

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

func (NUMANodeMap) GetAvailableCPUSetExcludeDedicatedCoresPodsAndPools

func (nm NUMANodeMap) GetAvailableCPUSetExcludeDedicatedCoresPodsAndPools(reservedCPUs machine.CPUSet,
	podEntries PodEntries, ignorePools sets.String) machine.CPUSet

func (NUMANodeMap) GetAvailableCPUSetExcludeNUMABindingPods

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

func (NUMANodeMap) GetDefaultCPUSet

func (nm NUMANodeMap) GetDefaultCPUSet() machine.CPUSet

func (NUMANodeMap) GetDefaultCPUSetExcludeDedicatedCoresPods

func (nm NUMANodeMap) GetDefaultCPUSetExcludeDedicatedCoresPods() machine.CPUSet

func (NUMANodeMap) GetDefaultCPUSetExcludeDedicatedCoresPodsAndPools

func (nm NUMANodeMap) GetDefaultCPUSetExcludeDedicatedCoresPodsAndPools(podEntries PodEntries, ignorePools sets.String) machine.CPUSet

func (NUMANodeMap) GetDefaultCPUSetExcludeNUMABindingPods

func (nm NUMANodeMap) GetDefaultCPUSetExcludeNUMABindingPods() machine.CPUSet

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

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

func (*NUMANodeState) GetDefaultCPUSetExcludeDedicatedCoresPods

func (ns *NUMANodeState) GetDefaultCPUSetExcludeDedicatedCoresPods() machine.CPUSet

func (*NUMANodeState) GetDefaultCPUSetExcludeNUMABindingPods

func (ns *NUMANodeState) GetDefaultCPUSetExcludeNUMABindingPods() machine.CPUSet

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

func (pe PodEntries) Clone() PodEntries

func (PodEntries) GetPoolCPUset

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

func (PodEntries) GetPoolsCPUset

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

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