cpumanager

package
v1.22.6-rc.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2021 License: Apache-2.0 Imports: 21 Imported by: 51

Documentation

Index

Constants

View Source
const (

	// PolicyStatic is the name of the static policy.
	// Should options be given, these will be ignored and backward (up to 1.21 included)
	// compatible behaviour will be enforced
	PolicyStatic policyName = "static"
	// ErrorSMTAlignment represents the type of an SMTAlignmentError
	ErrorSMTAlignment = "SMTAlignmentError"
)
View Source
const (
	// FullPCPUsOnlyOption is the name of the CPU Manager policy option
	FullPCPUsOnlyOption string = "full-pcpus-only"
)
View Source
const PolicyNone policyName = "none"

PolicyNone name of none policy

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivePodsFunc

type ActivePodsFunc func() []*v1.Pod

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

type Manager

type Manager interface {
	// Start is called during Kubelet initialization.
	Start(activePods ActivePodsFunc, sourcesReady config.SourcesReady, podStatusProvider status.PodStatusProvider, containerRuntime runtimeService, initialContainers containermap.ContainerMap) error

	// Called to trigger the allocation of CPUs to a container. This must be
	// called at some point prior to the AddContainer() call for a container,
	// e.g. at pod admission time.
	Allocate(pod *v1.Pod, container *v1.Container) error

	// AddContainer adds the mapping between container ID to pod UID and the container name
	// The mapping used to remove the CPU allocation during the container removal
	AddContainer(p *v1.Pod, c *v1.Container, containerID string)

	// RemoveContainer is called after Kubelet decides to kill or delete a
	// container. After this call, the CPU manager stops trying to reconcile
	// that container and any CPUs dedicated to the container are freed.
	RemoveContainer(containerID string) error

	// State returns a read-only interface to the internal CPU manager state.
	State() state.Reader

	// GetTopologyHints implements the topologymanager.HintProvider Interface
	// and is consulted to achieve NUMA aware resource alignment among this
	// and other resource controllers.
	GetTopologyHints(*v1.Pod, *v1.Container) map[string][]topologymanager.TopologyHint

	// GetCPUs implements the podresources.CPUsProvider interface to provide allocated
	// cpus for the container
	GetCPUs(podUID, containerName string) cpuset.CPUSet

	// GetPodTopologyHints implements the topologymanager.HintProvider Interface
	// and is consulted to achieve NUMA aware resource alignment per Pod
	// among this and other resource controllers.
	GetPodTopologyHints(pod *v1.Pod) map[string][]topologymanager.TopologyHint

	// GetAllocatableCPUs returns the assignable (not allocated) CPUs
	GetAllocatableCPUs() cpuset.CPUSet
}

Manager interface provides methods for Kubelet to manage pod cpus.

func NewFakeManager

func NewFakeManager() Manager

NewFakeManager creates empty/fake cpu manager

func NewManager

func NewManager(cpuPolicyName string, cpuPolicyOptions map[string]string, reconcilePeriod time.Duration, machineInfo *cadvisorapi.MachineInfo, specificCPUs cpuset.CPUSet, nodeAllocatableReservation v1.ResourceList, stateFileDirectory string, affinity topologymanager.Store) (Manager, error)

NewManager creates new cpu manager based on provided policy

type Policy

type Policy interface {
	Name() string
	Start(s state.State) error
	// Allocate call is idempotent
	Allocate(s state.State, pod *v1.Pod, container *v1.Container) error
	// RemoveContainer call is idempotent
	RemoveContainer(s state.State, podUID string, containerName string) error
	// GetTopologyHints implements the topologymanager.HintProvider Interface
	// and is consulted to achieve NUMA aware resource alignment among this
	// and other resource controllers.
	GetTopologyHints(s state.State, pod *v1.Pod, container *v1.Container) map[string][]topologymanager.TopologyHint
	// GetPodTopologyHints implements the topologymanager.HintProvider Interface
	// and is consulted to achieve NUMA aware resource alignment per Pod
	// among this and other resource controllers.
	GetPodTopologyHints(s state.State, pod *v1.Pod) map[string][]topologymanager.TopologyHint
	// GetAllocatableCPUs returns the assignable (not allocated) CPUs
	GetAllocatableCPUs(m state.State) cpuset.CPUSet
}

Policy implements logic for pod container to CPU assignment.

func NewNonePolicy

func NewNonePolicy(cpuPolicyOptions map[string]string) (Policy, error)

NewNonePolicy returns a cpuset manager policy that does nothing

func NewStaticPolicy

func NewStaticPolicy(topology *topology.CPUTopology, numReservedCPUs int, reservedCPUs cpuset.CPUSet, affinity topologymanager.Store, cpuPolicyOptions map[string]string) (Policy, error)

NewStaticPolicy returns a CPU manager policy that does not change CPU assignments for exclusively pinned guaranteed containers after the main container process starts.

type SMTAlignmentError added in v1.22.0

type SMTAlignmentError struct {
	RequestedCPUs int
	CpusPerCore   int
}

SMTAlignmentError represents an error due to SMT alignment

func (SMTAlignmentError) Error added in v1.22.0

func (e SMTAlignmentError) Error() string

func (SMTAlignmentError) Type added in v1.22.0

func (e SMTAlignmentError) Type() string

type StaticPolicyOptions added in v1.22.0

type StaticPolicyOptions struct {
	// flag to enable extra allocation restrictions to avoid
	// different containers to possibly end up on the same core.
	// we consider "core" and "physical CPU" synonim here, leaning
	// towards the terminoloy k8s hints. We acknowledge this is confusing.
	//
	// looking at https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/,
	// any possible naming scheme will lead to ambiguity to some extent.
	// We picked "pcpu" because it the established docs hints at vCPU already.
	FullPhysicalCPUsOnly bool
}

func NewStaticPolicyOptions added in v1.22.0

func NewStaticPolicyOptions(policyOptions map[string]string) (StaticPolicyOptions, error)

Directories

Path Synopsis
Package topology contains helpers for the CPU manager.
Package topology contains helpers for the CPU manager.

Jump to

Keyboard shortcuts

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