Documentation
¶
Index ¶
- Constants
- Variables
- func AdvisorDegradation(advisorHealth, enableReclaim bool) bool
- func CPUIsSufficient(request, available float64) bool
- func CalculateCPUBurstFromPercent(percent float64, cpuQuota int64) uint64
- func GetAggResourcePackagePinnedCPUSet(attributeSelector labels.Selector, machineState state.NUMANodeMap) machine.CPUSet
- func GetCPUTopologyAllocationsAnnotations(allocationInfo *state.AllocationInfo, topologyAllocationAnnotationKey string) (map[string]string, error)
- func GetContainerRequestedCores(metaServer *metaserver.MetaServer, allocationInfo *state.AllocationInfo) float64
- func GetCoresReservedForSystem(conf *config.Configuration, metaServer *metaserver.MetaServer, ...) (machine.CPUSet, error)
- func GetPodAggregatedRequestResourceFromAllocationInfo(allocationInfo *state.AllocationInfo, resourceName v1.ResourceName) (int, float64, error)
- func GetPodCPUBurstPercent(qosConf *generic.QoSConfiguration, pod *v1.Pod, ...) (float64, error)
- func GetPodCPUBurstPolicy(conf *config.Configuration, pod *v1.Pod, ...) (string, error)
- func IsSoleSharedCoresPod(conf *config.Configuration, podList []*v1.Pod, ...) bool
- func IsTopologyAllocationChanged(oldInfo, newInfo *state.AllocationInfo) bool
- func PackAllocationResponse(allocationInfo *state.AllocationInfo, resourceName, ociPropertyName string, ...) (*pluginapi.ResourceAllocationResponse, error)
- func PopulateHintsByAvailableNUMANodes(numaNodes []int, hints *pluginapi.ListOfTopologyHints, preferred bool)
- func RegenerateHints(allocationInfo *state.AllocationInfo, regenerate bool) map[string]*pluginapi.ListOfTopologyHints
- type Entries
- type MetricInfo
- type MetricRing
- func (ring *MetricRing) Avg() float64
- func (ring *MetricRing) AvgAfterTimestampWithCountBound(ts int64, countBound int) (float64, error)
- func (ring *MetricRing) Count() (softOverCount, hardOverCount int)
- func (ring *MetricRing) Len() int
- func (ring *MetricRing) OverCount(threshold float64) (overCount int)
- func (ring *MetricRing) Push(snapShot *MetricSnapshot)
- func (ring *MetricRing) Sum() float64
- type MetricSnapshot
- type NumaMetricHistory
- type PoolMetricCollectHandler
- type SubEntries
Constants ¶
const (
FakePodUID = ""
)
Variables ¶
var ( ErrNoAvailableCPUHints = pkgerrors.New("no available cpu hints") ErrNoAvailableMemoryBandwidthHints = pkgerrors.New("no available memory bandwidth hints") )
Functions ¶
func AdvisorDegradation ¶ added in v0.5.4
AdvisorDegradation checks if the advisor is in a degraded state. It returns true if the advisor is unhealthy and reclaim is disabled.
func CPUIsSufficient ¶ added in v0.5.12
CPUIsSufficient checks if the requested CPU is within the available limits, considering a small tolerance for floating point comparison.
func CalculateCPUBurstFromPercent ¶ added in v0.5.39
CalculateCPUBurstFromPercent calculates the CPU burst value based on the given percentage and CPU quota.
func GetAggResourcePackagePinnedCPUSet ¶ added in v0.5.49
func GetAggResourcePackagePinnedCPUSet(attributeSelector labels.Selector, machineState state.NUMANodeMap) machine.CPUSet
GetAggResourcePackagePinnedCPUSet aggregates pinned CPUSets from resource packages that match the given attribute selector. It iterates through each NUMA node's resource packages, filters them using the attribute selector, and unions the pinned CPUSets from the corresponding machine state.
func GetCPUTopologyAllocationsAnnotations ¶ added in v0.5.49
func GetCPUTopologyAllocationsAnnotations(allocationInfo *state.AllocationInfo, topologyAllocationAnnotationKey string, ) (map[string]string, error)
GetCPUTopologyAllocationsAnnotations returns the topology-aware CPU allocation annotations for a given container. It handles different QoS levels: - For DedicatedCores: uses the actual assigned CPUSet size on each NUMA node. - For SharedCores/ReclaimedCores with NUMA binding: uses the pod's aggregated request quantity. This function only processes main containers and returns nil for sidecars or invalid allocation info.
func GetContainerRequestedCores ¶ added in v0.5.28
func GetContainerRequestedCores(metaServer *metaserver.MetaServer, allocationInfo *state.AllocationInfo) float64
GetContainerRequestedCores parses and returns request cores for the given container
func GetCoresReservedForSystem ¶ added in v0.4.0
func GetCoresReservedForSystem(conf *config.Configuration, metaServer *metaserver.MetaServer, machineInfo *machine.KatalystMachineInfo, allCPUs machine.CPUSet) (machine.CPUSet, error)
GetCoresReservedForSystem calculates the CPU cores reserved for the system based on the configuration. It prioritizes the kubelet configuration if enabled, otherwise falls back to the static configuration. It returns a CPUSet representing the reserved cores.
func GetPodAggregatedRequestResourceFromAllocationInfo ¶ added in v0.5.49
func GetPodAggregatedRequestResourceFromAllocationInfo(allocationInfo *state.AllocationInfo, resourceName v1.ResourceName) (int, float64, error)
GetPodAggregatedRequestResourceFromAllocationInfo returns both integer and float64 quantities for the main resource based on allocationInfo. If the allocationInfo.Annotations contain aggregated resource keys, those values are used; otherwise, it falls back to use quantities in allocationInfo.
func GetPodCPUBurstPercent ¶ added in v0.5.39
func GetPodCPUBurstPercent(qosConf *generic.QoSConfiguration, pod *v1.Pod, dynamicConfig *dynamic.DynamicAgentConfiguration) (float64, error)
GetPodCPUBurstPercent gets the cpu burst percent of a given pod.
func GetPodCPUBurstPolicy ¶ added in v0.5.39
func GetPodCPUBurstPolicy(conf *config.Configuration, pod *v1.Pod, dynamicConfig *dynamic.DynamicAgentConfiguration, isSoleSharedCoresPod bool, ) (string, error)
GetPodCPUBurstPolicy gets the cpu burst policy of a given pod.
func IsSoleSharedCoresPod ¶ added in v0.5.43
func IsSoleSharedCoresPod(conf *config.Configuration, podList []*v1.Pod, dynamicConfig *dynamic.DynamicAgentConfiguration) bool
IsSoleSharedCoresPod returns true if there is only one shared cores pod in the node. Keeps the original dynamic-config gating, and also calculates when core config EnableDefaultSharedCoresCPUBurst is true.
func IsTopologyAllocationChanged ¶ added in v0.5.49
func IsTopologyAllocationChanged(oldInfo, newInfo *state.AllocationInfo) bool
IsTopologyAllocationChanged checks if the topology allocation of a container has changed.
func PackAllocationResponse ¶ added in v0.4.0
func PackAllocationResponse(allocationInfo *state.AllocationInfo, resourceName, ociPropertyName string, isNodeResource, isScalarResource bool, req *pluginapi.ResourceRequest, resourceAllocationAnnotations ...map[string]string, ) (*pluginapi.ResourceAllocationResponse, error)
PackAllocationResponse assembles a ResourceAllocationResponse for the CPU plugin. It populates the response with pod/container metadata and resource allocation results, and directly applies the provided resourceAllocationAnnotations to the response.
func PopulateHintsByAvailableNUMANodes ¶ added in v0.5.28
func PopulateHintsByAvailableNUMANodes( numaNodes []int, hints *pluginapi.ListOfTopologyHints, preferred bool, )
PopulateHintsByAvailableNUMANodes appends topology hints for the given NUMA nodes to the hints list.
func RegenerateHints ¶ added in v0.4.0
func RegenerateHints(allocationInfo *state.AllocationInfo, regenerate bool) map[string]*pluginapi.ListOfTopologyHints
RegenerateHints regenerates hints for container that'd already been allocated cpu, and regenerateHints will assemble hints based on already-existed AllocationInfo, without any calculation logics at all
Types ¶
type Entries ¶ added in v0.5.33
type Entries map[string]SubEntries
Entries are keyed by pod UID or pool name
type MetricInfo ¶ added in v0.5.33
type MetricRing ¶ added in v0.5.33
type MetricRing struct {
MaxLen int
Queue []*MetricSnapshot
CurrentIndex int
sync.RWMutex
}
func CreateMetricRing ¶ added in v0.5.33
func CreateMetricRing(size int) *MetricRing
func (*MetricRing) Avg ¶ added in v0.5.33
func (ring *MetricRing) Avg() float64
func (*MetricRing) AvgAfterTimestampWithCountBound ¶ added in v0.5.33
func (ring *MetricRing) AvgAfterTimestampWithCountBound(ts int64, countBound int) (float64, error)
func (*MetricRing) Count ¶ added in v0.5.33
func (ring *MetricRing) Count() (softOverCount, hardOverCount int)
func (*MetricRing) Len ¶ added in v0.5.33
func (ring *MetricRing) Len() int
func (*MetricRing) OverCount ¶ added in v0.5.33
func (ring *MetricRing) OverCount(threshold float64) (overCount int)
OverCount pass threshold from outside
func (*MetricRing) Push ¶ added in v0.5.33
func (ring *MetricRing) Push(snapShot *MetricSnapshot)
func (*MetricRing) Sum ¶ added in v0.5.33
func (ring *MetricRing) Sum() float64
type MetricSnapshot ¶ added in v0.5.33
type MetricSnapshot struct {
Info MetricInfo
Time int64
}
type NumaMetricHistory ¶ added in v0.5.33
type NumaMetricHistory struct {
// numa -> pod -> metric -> ring
Inner map[int]map[string]map[string]*MetricRing
RingSize int
}
func NewMetricHistory ¶ added in v0.5.33
func NewMetricHistory(ringSize int) *NumaMetricHistory
type PoolMetricCollectHandler ¶ added in v0.5.33
type SubEntries ¶ added in v0.5.33
type SubEntries map[string]*MetricRing
SubEntries is keyed by container name or empty string (for pool)
func (SubEntries) IsPoolEntry ¶ added in v0.5.33
func (se SubEntries) IsPoolEntry() bool