cpumanager

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: Apache-2.0, BSD-2-Clause Imports: 31 Imported by: 0

Documentation

Overview

nolint

Index

Constants

View Source
const (
	PolicyNameStatic = "static"
)

Variables

View Source
var DefaultExclusiveCPUSet = func() cpuset.CPUSet {
	return cpuset.NewCPUSet()
}

Functions

func GetPodCPUPolicy

func GetPodCPUPolicy(attr map[string]string) string

GetPodCPUPolicy returns the cpu policy of pod, only supports none, exclusive, numa and immovable.

func GetPodNUMANodeResult

func GetPodNUMANodeResult(pod *corev1.Pod) topologyapi.ZoneList

GetPodNUMANodeResult returns the NUMA node scheduling result of a pod.

func GetPodTargetContainerIndices

func GetPodTargetContainerIndices(pod *corev1.Pod) []int

GetPodTargetContainerIndices returns all pod whose cpus could be allocated.

func GetPodTopologyResult

func GetPodTopologyResult(pod *corev1.Pod) topologyapi.ZoneList

GetPodTopologyResult returns the Topology scheduling result of a pod.

func GuaranteedCPUs

func GuaranteedCPUs(container *corev1.Container) int

GuaranteedCPUs returns CPUs for guaranteed container.

Types

type ActivePodsByPolicyFunc

type ActivePodsByPolicyFunc func(policy string) ([]*corev1.Pod, error)

ActivePodsByPolicyFunc is a function that returns a list of pods which belong to specified policy.

type ActivePodsFunc

type ActivePodsFunc func() ([]*corev1.Pod, error)

ActivePodsFunc is a function that returns a list of pods to reconcile.

type CPUManager

type CPUManager interface {
	manager.Manager

	GetExclusiveCPUSet() cpuset.CPUSet

	GetSharedCPUs() cpuset.CPUSet
}

func NewCPUManager

func NewCPUManager(
	nodeName string,
	defaultCPUPolicy string,
	reconcilePeriod time.Duration,
	cadvisorManager cadvisor.Manager,
	containerRuntime criapis.RuntimeService,
	stateFileDirectory string,
	podInformer coreinformers.PodInformer,
	nrtInformer topologyinformer.NodeResourceTopologyInformer,
) (CPUManager, error)

type LoopControl

type LoopControl int
const (
	Continue LoopControl = iota
	Break
)

type NodeInfo

type NodeInfo struct {
	CPUs               int
	NumReservedCPUs    int
	ReservedSystemCPUs cpuset.CPUSet
}

type Policy

type Policy interface {
	Name() string
	Start(s cpumanagerstate.State, nodeTopology TopologyResult) error
	// Allocate call is idempotent
	Allocate(s cpumanagerstate.State, pod *corev1.Pod, container *corev1.Container, mode string, tr TopologyResult) error
	// RemoveContainer call is idempotent
	RemoveContainer(s cpumanagerstate.State, podUID string, containerName string)
	// GetAllocatableCPUs returns the assignable (not allocated) CPUs
	GetAllocatableCPUs(m cpumanagerstate.State) (cpuset.CPUSet, error)
	// GetSharedCPUs returns the set of unassigned CPUs minus the reserved set.
	GetSharedCPUs(s cpumanagerstate.State) cpuset.CPUSet
	// GetExclusiveCPUSet returns the set of all CPUs minus the default set.
	GetExclusiveCPUSet(s cpumanagerstate.State) cpuset.CPUSet
	// GetReservedCPUSet returns the set of reserved CPUs
	GetReservedCPUSet() cpuset.CPUSet
}

Policy implements logic for pod container to CPU assignment.

func NewStaticPolicy

func NewStaticPolicy(topology *cputopo.CPUTopology, getPodFunc ActivePodsByPolicyFunc) Policy

NewStaticPolicy builds a new staticPolicy.

type TopologyResult

type TopologyResult map[int]NodeInfo

func NewTopologyResult

func NewTopologyResult() TopologyResult

func (TopologyResult) CPUs

func (tr TopologyResult) CPUs() int

func (TopologyResult) CPUsInNUMANodes

func (tr TopologyResult) CPUsInNUMANodes(ids ...int) int

func (TopologyResult) NumReservedCPUs

func (tr TopologyResult) NumReservedCPUs() int

func (TopologyResult) NumReservedCPUsInNUMANodes

func (tr TopologyResult) NumReservedCPUsInNUMANodes(ids ...int) int

Jump to

Keyboard shortcuts

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