From d41d3c3a654f83b9639aa157c0583ccd971761f8 Mon Sep 17 00:00:00 2001 From: yangfeiyu Date: Tue, 21 May 2024 17:56:41 +0800 Subject: [PATCH] koordlet: skip the container which is not running in cpuBurst applyCFSQuotaBurst Some containers are not running, maybe they have failed, just skip them. It can also reduce the confusing err msgs. Signed-off-by: yangfeiyu --- pkg/koordlet/qosmanager/plugins/cpuburst/cpu_burst.go | 5 +++++ pkg/koordlet/qosmanager/plugins/cpuburst/cpu_burst_test.go | 1 + 2 files changed, 6 insertions(+) diff --git a/pkg/koordlet/qosmanager/plugins/cpuburst/cpu_burst.go b/pkg/koordlet/qosmanager/plugins/cpuburst/cpu_burst.go index b7e7b124f..67fc78f38 100644 --- a/pkg/koordlet/qosmanager/plugins/cpuburst/cpu_burst.go +++ b/pkg/koordlet/qosmanager/plugins/cpuburst/cpu_burst.go @@ -355,6 +355,11 @@ func (b *cpuBurst) applyCFSQuotaBurst(burstCfg *slov1alpha1.CPUBurstConfig, podM continue } + if containerStat.State.Running == nil { + klog.Infof("skip container %s/%s/%s, because it is not running", pod.Namespace, pod.Name, containerStat.Name) + continue + } + containerBaseCFS := koordletutil.GetContainerBaseCFSQuota(container) if containerBaseCFS <= 0 { continue diff --git a/pkg/koordlet/qosmanager/plugins/cpuburst/cpu_burst_test.go b/pkg/koordlet/qosmanager/plugins/cpuburst/cpu_burst_test.go index 545445189..e915b1f68 100644 --- a/pkg/koordlet/qosmanager/plugins/cpuburst/cpu_burst_test.go +++ b/pkg/koordlet/qosmanager/plugins/cpuburst/cpu_burst_test.go @@ -233,6 +233,7 @@ func createPodMetaByResource(podName string, containersRes map[string]corev1.Res containerStat := corev1.ContainerStatus{ Name: containerName, ContainerID: genTestContainerIDByName(containerName), + State: corev1.ContainerState{Running: &corev1.ContainerStateRunning{}}, } pod.Spec.Containers = append(pod.Spec.Containers, container) pod.Status.ContainerStatuses = append(pod.Status.ContainerStatuses, containerStat)