From ca2c46a273033440fe142232fbb2120327ee314c Mon Sep 17 00:00:00 2001 From: Swati Sehgal Date: Fri, 17 Jan 2025 13:02:15 +0000 Subject: [PATCH] node: cpu-mgr: Add logs when CPU allocation is skipped CPU Allocation is skipped in CPU Manager with static policy in case the pod doesn't belong to Guaranteed QoS or the CPUs requested are not integral. We add logs to capture these skips. Signed-off-by: Swati Sehgal --- pkg/kubelet/cm/cpumanager/policy_static.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/kubelet/cm/cpumanager/policy_static.go b/pkg/kubelet/cm/cpumanager/policy_static.go index 7abb868b8fc..d517aa698b5 100644 --- a/pkg/kubelet/cm/cpumanager/policy_static.go +++ b/pkg/kubelet/cm/cpumanager/policy_static.go @@ -456,7 +456,9 @@ func (p *staticPolicy) allocateCPUs(s state.State, numCPUs int, numaAffinity bit } func (p *staticPolicy) guaranteedCPUs(pod *v1.Pod, container *v1.Container) int { - if v1qos.GetPodQOS(pod) != v1.PodQOSGuaranteed { + qos := v1qos.GetPodQOS(pod) + if qos != v1.PodQOSGuaranteed { + klog.V(5).InfoS("Exclusive CPU allocation skipped, pod QoS is not guaranteed", "pod", klog.KObj(pod), "containerName", container.Name, "qos", qos) return 0 } cpuQuantity := container.Resources.Requests[v1.ResourceCPU] @@ -469,7 +471,9 @@ func (p *staticPolicy) guaranteedCPUs(pod *v1.Pod, container *v1.Container) int cpuQuantity = cs.AllocatedResources[v1.ResourceCPU] } } - if cpuQuantity.Value()*1000 != cpuQuantity.MilliValue() { + cpuValue := cpuQuantity.Value() + if cpuValue*1000 != cpuQuantity.MilliValue() { + klog.V(5).InfoS("Exclusive CPU allocation skipped, pod is not requesting integral CPUs", "pod", klog.KObj(pod), "containerName", container.Name, "cpu", cpuValue) return 0 } // Safe downcast to do for all systems with < 2.1 billion CPUs.