topologymanager

package
v1.28.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2023 License: Apache-2.0 Imports: 15 Imported by: 12

Documentation

Index

Constants

View Source
const (

	// ErrorTopologyAffinity represents the type for a TopologyAffinityError
	ErrorTopologyAffinity = "TopologyAffinityError"
)
View Source
const PolicyBestEffort string = "best-effort"

PolicyBestEffort policy name.

View Source
const PolicyNone string = "none"

PolicyNone policy name.

View Source
const PolicyRestricted string = "restricted"

PolicyRestricted policy name.

View Source
const PolicySingleNumaNode string = "single-numa-node"

PolicySingleNumaNode policy name.

View Source
const (
	PreferClosestNUMANodes string = "prefer-closest-numa-nodes"
)

Variables

This section is empty.

Functions

func CheckPolicyOptionAvailable added in v1.26.0

func CheckPolicyOptionAvailable(option string) error

Types

type HintMerger added in v1.26.0

type HintMerger struct {
	NUMAInfo *NUMAInfo
	Hints    [][]TopologyHint
	// Set bestNonPreferredAffinityCount to help decide which affinity mask is
	// preferred amongst all non-preferred hints. We calculate this value as
	// the maximum of the minimum affinity counts supplied for any given hint
	// provider. In other words, prefer a hint that has an affinity mask that
	// includes all of the NUMA nodes from the provider that requires the most
	// NUMA nodes to satisfy its allocation.
	BestNonPreferredAffinityCount int
	CompareNUMAAffinityMasks      func(candidate *TopologyHint, current *TopologyHint) (best *TopologyHint)
}

func NewHintMerger added in v1.26.0

func NewHintMerger(numaInfo *NUMAInfo, hints [][]TopologyHint, policyName string, opts PolicyOptions) HintMerger

func (HintMerger) Merge added in v1.26.0

func (m HintMerger) Merge() TopologyHint

type HintProvider

type HintProvider interface {
	// GetTopologyHints returns a map of resource names to a list of possible
	// concrete resource allocations in terms of NUMA locality hints. Each hint
	// is optionally marked "preferred" and indicates the set of NUMA nodes
	// involved in the hypothetical allocation. The topology manager calls
	// this function for each hint provider, and merges the hints to produce
	// a consensus "best" hint. The hint providers may subsequently query the
	// topology manager to influence actual resource assignment.
	GetTopologyHints(pod *v1.Pod, container *v1.Container) map[string][]TopologyHint
	// GetPodTopologyHints returns a map of resource names to a list of possible
	// concrete resource allocations per Pod in terms of NUMA locality hints.
	GetPodTopologyHints(pod *v1.Pod) map[string][]TopologyHint
	// Allocate triggers resource allocation to occur on the HintProvider after
	// all hints have been gathered and the aggregated Hint is available via a
	// call to Store.GetAffinity().
	Allocate(pod *v1.Pod, container *v1.Container) error
}

HintProvider is an interface for components that want to collaborate to achieve globally optimal concrete resource alignment with respect to NUMA locality.

type Manager

type Manager interface {
	// PodAdmitHandler is implemented by Manager
	lifecycle.PodAdmitHandler
	// AddHintProvider adds a hint provider to manager to indicate the hint provider
	// wants to be consulted with when making topology hints
	AddHintProvider(HintProvider)
	// AddContainer adds pod to Manager for tracking
	AddContainer(pod *v1.Pod, container *v1.Container, containerID string)
	// RemoveContainer removes pod from Manager tracking
	RemoveContainer(containerID string) error
	// Store is the interface for storing pod topology hints
	Store
}

Manager interface provides methods for Kubelet to manage pod topology hints

func NewFakeManager added in v1.16.0

func NewFakeManager() Manager

NewFakeManager returns an instance of FakeManager

func NewFakeManagerWithHint added in v1.22.0

func NewFakeManagerWithHint(hint *TopologyHint) Manager

NewFakeManagerWithHint returns an instance of fake topology manager with specified topology hints

func NewFakeManagerWithPolicy added in v1.25.0

func NewFakeManagerWithPolicy(policy Policy) Manager

NewFakeManagerWithPolicy returns an instance of fake topology manager with specified policy

func NewManager added in v1.16.0

func NewManager(topology []cadvisorapi.Node, topologyPolicyName string, topologyScopeName string, topologyPolicyOptions map[string]string) (Manager, error)

NewManager creates a new TopologyManager based on provided policy and scope

type NUMADistances added in v1.26.0

type NUMADistances map[int][]uint64

func (NUMADistances) CalculateAverageFor added in v1.26.0

func (d NUMADistances) CalculateAverageFor(bm bitmask.BitMask) float64

type NUMAInfo added in v1.26.0

type NUMAInfo struct {
	Nodes         []int
	NUMADistances NUMADistances
}

func NewNUMAInfo added in v1.26.0

func NewNUMAInfo(topology []cadvisorapi.Node, opts PolicyOptions) (*NUMAInfo, error)

func (*NUMAInfo) Closest added in v1.26.0

func (n *NUMAInfo) Closest(m1 bitmask.BitMask, m2 bitmask.BitMask) bitmask.BitMask

func (NUMAInfo) DefaultAffinityMask added in v1.26.0

func (n NUMAInfo) DefaultAffinityMask() bitmask.BitMask

func (*NUMAInfo) Narrowest added in v1.26.0

func (n *NUMAInfo) Narrowest(m1 bitmask.BitMask, m2 bitmask.BitMask) bitmask.BitMask

type Policy

type Policy interface {
	// Returns Policy Name
	Name() string
	// Returns a merged TopologyHint based on input from hint providers
	// and a Pod Admit Handler Response based on hints and policy type
	Merge(providersHints []map[string][]TopologyHint) (TopologyHint, bool)
}

Policy interface for Topology Manager Pod Admit Result

func NewBestEffortPolicy added in v1.16.0

func NewBestEffortPolicy(numaInfo *NUMAInfo, opts PolicyOptions) Policy

NewBestEffortPolicy returns best-effort policy.

func NewNonePolicy added in v1.16.0

func NewNonePolicy() Policy

NewNonePolicy returns none policy.

func NewRestrictedPolicy added in v1.16.0

func NewRestrictedPolicy(numaInfo *NUMAInfo, opts PolicyOptions) Policy

NewRestrictedPolicy returns restricted policy.

func NewSingleNumaNodePolicy added in v1.16.0

func NewSingleNumaNodePolicy(numaInfo *NUMAInfo, opts PolicyOptions) Policy

NewSingleNumaNodePolicy returns single-numa-node policy.

type PolicyOptions added in v1.26.0

type PolicyOptions struct {
	PreferClosestNUMA bool
}

func NewPolicyOptions added in v1.26.0

func NewPolicyOptions(policyOptions map[string]string) (PolicyOptions, error)

type Scope added in v1.20.0

type Scope interface {
	Name() string
	GetPolicy() Policy
	Admit(pod *v1.Pod) lifecycle.PodAdmitResult
	// AddHintProvider adds a hint provider to manager to indicate the hint provider
	// wants to be consoluted with when making topology hints
	AddHintProvider(h HintProvider)
	// AddContainer adds pod to Manager for tracking
	AddContainer(pod *v1.Pod, container *v1.Container, containerID string)
	// RemoveContainer removes pod from Manager tracking
	RemoveContainer(containerID string) error
	// Store is the interface for storing pod topology hints
	Store
}

Scope interface for Topology Manager

func NewContainerScope added in v1.20.0

func NewContainerScope(policy Policy) Scope

NewContainerScope returns a container scope.

func NewNoneScope added in v1.28.0

func NewNoneScope() Scope

NewNoneScope returns a none scope.

func NewPodScope added in v1.20.0

func NewPodScope(policy Policy) Scope

NewPodScope returns a pod scope.

type Store

type Store interface {
	GetAffinity(podUID string, containerName string) TopologyHint
	GetPolicy() Policy
}

Store interface is to allow Hint Providers to retrieve pod affinity

type TopologyAffinityError added in v1.22.0

type TopologyAffinityError struct{}

TopologyAffinityError represents an resource alignment error

func (TopologyAffinityError) Error added in v1.22.0

func (e TopologyAffinityError) Error() string

func (TopologyAffinityError) Type added in v1.22.0

func (e TopologyAffinityError) Type() string

type TopologyHint

type TopologyHint struct {
	NUMANodeAffinity bitmask.BitMask
	// Preferred is set to true when the NUMANodeAffinity encodes a preferred
	// allocation for the Container. It is set to false otherwise.
	Preferred bool
}

TopologyHint is a struct containing the NUMANodeAffinity for a Container

func (*TopologyHint) IsEqual added in v1.17.0

func (th *TopologyHint) IsEqual(topologyHint TopologyHint) bool

IsEqual checks if TopologyHint are equal

func (*TopologyHint) LessThan added in v1.17.0

func (th *TopologyHint) LessThan(other TopologyHint) bool

LessThan checks if TopologyHint `a` is less than TopologyHint `b` this means that either `a` is a preferred hint and `b` is not or `a` NUMANodeAffinity attribute is narrower than `b` NUMANodeAffinity attribute.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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