Skip to content

Commit ca2c46a

Browse files
committed
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 <[email protected]>
1 parent 01a546f commit ca2c46a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pkg/kubelet/cm/cpumanager/policy_static.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,9 @@ func (p *staticPolicy) allocateCPUs(s state.State, numCPUs int, numaAffinity bit
456456
}
457457

458458
func (p *staticPolicy) guaranteedCPUs(pod *v1.Pod, container *v1.Container) int {
459-
if v1qos.GetPodQOS(pod) != v1.PodQOSGuaranteed {
459+
qos := v1qos.GetPodQOS(pod)
460+
if qos != v1.PodQOSGuaranteed {
461+
klog.V(5).InfoS("Exclusive CPU allocation skipped, pod QoS is not guaranteed", "pod", klog.KObj(pod), "containerName", container.Name, "qos", qos)
460462
return 0
461463
}
462464
cpuQuantity := container.Resources.Requests[v1.ResourceCPU]
@@ -469,7 +471,9 @@ func (p *staticPolicy) guaranteedCPUs(pod *v1.Pod, container *v1.Container) int
469471
cpuQuantity = cs.AllocatedResources[v1.ResourceCPU]
470472
}
471473
}
472-
if cpuQuantity.Value()*1000 != cpuQuantity.MilliValue() {
474+
cpuValue := cpuQuantity.Value()
475+
if cpuValue*1000 != cpuQuantity.MilliValue() {
476+
klog.V(5).InfoS("Exclusive CPU allocation skipped, pod is not requesting integral CPUs", "pod", klog.KObj(pod), "containerName", container.Name, "cpu", cpuValue)
473477
return 0
474478
}
475479
// Safe downcast to do for all systems with < 2.1 billion CPUs.

0 commit comments

Comments
 (0)