From 643aa3f10d8b1379e4dbf4397e1f286b57af4581 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 | 2 ++ 2 files changed, 7 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..ef53f3e19 100644 --- a/pkg/koordlet/qosmanager/plugins/cpuburst/cpu_burst_test.go +++ b/pkg/koordlet/qosmanager/plugins/cpuburst/cpu_burst_test.go @@ -149,6 +149,7 @@ func newTestPodWithQOS(name string, qos apiext.QoSClass, cpuMilli, memoryBytes i { Name: containerName, ContainerID: genTestContainerIDByName(containerName), + State: corev1.ContainerState{Running: &corev1.ContainerStateRunning{}}, }, }, Phase: corev1.PodRunning, @@ -233,6 +234,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)