From 7f4b9a52db28ffdf5138c37c5f4f8b83c9df4596 Mon Sep 17 00:00:00 2001 From: vinay kulkarni Date: Wed, 19 Mar 2025 19:11:21 +0000 Subject: [PATCH] Consider memory requests in determining if resize is in progress, set termination grace period to 0 --- pkg/kubelet/kubelet.go | 3 +-- pkg/kubelet/kuberuntime/kuberuntime_manager.go | 1 - test/e2e/framework/pod/resize.go | 4 ++-- test/e2e/framework/pod/utils.go | 1 - 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/pkg/kubelet/kubelet.go b/pkg/kubelet/kubelet.go index ced300f6432..d104a68f624 100644 --- a/pkg/kubelet/kubelet.go +++ b/pkg/kubelet/kubelet.go @@ -2989,7 +2989,6 @@ func (kl *Kubelet) handlePodResourcesResize(pod *v1.Pod, podStatus *kubecontaine // for any running containers. Specifically, the following differences are ignored: // - Non-resizable containers: non-restartable init containers, ephemeral containers // - Non-resizable resources: only CPU & memory are resizable -// - Non-actuated resources: memory requests are not actuated // - Non-running containers: they will be sized correctly when (re)started func (kl *Kubelet) isPodResizeInProgress(allocatedPod *v1.Pod, podStatus *kubecontainer.PodStatus) bool { return !podutil.VisitContainers(&allocatedPod.Spec, podutil.InitContainers|podutil.Containers, @@ -3007,9 +3006,9 @@ func (kl *Kubelet) isPodResizeInProgress(allocatedPod *v1.Pod, podStatus *kubeco actuatedResources, _ := kl.allocationManager.GetActuatedResources(allocatedPod.UID, allocatedContainer.Name) allocatedResources := allocatedContainer.Resources - // Memory requests are excluded since they don't need to be actuated. return allocatedResources.Requests[v1.ResourceCPU].Equal(actuatedResources.Requests[v1.ResourceCPU]) && allocatedResources.Limits[v1.ResourceCPU].Equal(actuatedResources.Limits[v1.ResourceCPU]) && + allocatedResources.Requests[v1.ResourceMemory].Equal(actuatedResources.Requests[v1.ResourceMemory]) && allocatedResources.Limits[v1.ResourceMemory].Equal(actuatedResources.Limits[v1.ResourceMemory]) }) } diff --git a/pkg/kubelet/kuberuntime/kuberuntime_manager.go b/pkg/kubelet/kuberuntime/kuberuntime_manager.go index d44a05c1800..909e83e854b 100644 --- a/pkg/kubelet/kuberuntime/kuberuntime_manager.go +++ b/pkg/kubelet/kuberuntime/kuberuntime_manager.go @@ -77,7 +77,6 @@ const ( kubeRuntimeAPIVersion = "0.1.0" // A minimal shutdown window for avoiding unnecessary SIGKILLs minimumGracePeriodInSeconds = 2 - MinimumGracePeriodInSeconds = int64(minimumGracePeriodInSeconds) // The expiration time of version cache. versionCacheTTL = 60 * time.Second diff --git a/test/e2e/framework/pod/resize.go b/test/e2e/framework/pod/resize.go index 4403bdba0e3..1103be02a80 100644 --- a/test/e2e/framework/pod/resize.go +++ b/test/e2e/framework/pod/resize.go @@ -31,7 +31,6 @@ import ( utilerrors "k8s.io/apimachinery/pkg/util/errors" helpers "k8s.io/component-helpers/resource" kubecm "k8s.io/kubernetes/pkg/kubelet/cm" - "k8s.io/kubernetes/pkg/kubelet/kuberuntime" "k8s.io/kubernetes/test/e2e/framework" imageutils "k8s.io/kubernetes/test/utils/image" @@ -170,7 +169,7 @@ func makeResizableContainer(tcInfo ResizableContainerInfo) v1.Container { func MakePodWithResizableContainers(ns, name, timeStamp string, tcInfo []ResizableContainerInfo) *v1.Pod { testInitContainers, testContainers := separateContainers(tcInfo) - minGracePeriodSeconds := kuberuntime.MinimumGracePeriodInSeconds + minGracePeriodSeconds := int64(0) pod := &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ Name: name, @@ -433,6 +432,7 @@ func WaitForPodResizeActuation(ctx context.Context, f *framework.Framework, podC containerRestartWaitPeriod = MinRestartWaitPeriod } time.Sleep(time.Duration(containerRestartWaitPeriod) * time.Second) + resizedPod, err := framework.GetObject(podClient.Get, pod.Name, metav1.GetOptions{})(ctx) framework.ExpectNoError(err, "failed to get resized pod") return resizedPod diff --git a/test/e2e/framework/pod/utils.go b/test/e2e/framework/pod/utils.go index 1c4cb50d8de..e4c122e0f7b 100644 --- a/test/e2e/framework/pod/utils.go +++ b/test/e2e/framework/pod/utils.go @@ -309,7 +309,6 @@ func VerifyOomScoreAdjValue(f *framework.Framework, pod *v1.Pod, cName, expected if oomScoreAdj != expectedOomScoreAdj { return fmt.Errorf("oom_score_adj value %s not equal to expected %s", oomScoreAdj, expectedOomScoreAdj) } - fmt.Printf("VDBG: POD: %s EXPECTED_OOM_ADJ %s ACTUAL_OOM_ADJ %s\n", pod.Name, expectedOomScoreAdj, oomScoreAdj) return nil }