From 459de422628ed1262e5779a05a987e489374c84f 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..36d37af04 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.V(6).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)