From 466e5d4720ba2646c10cfa5674188d71a3f93479 Mon Sep 17 00:00:00 2001 From: ndixita Date: Wed, 18 Mar 2026 22:30:36 +0000 Subject: [PATCH 1/3] sync on observedGeneration and add CPU tolerance in resize framework --- test/e2e/common/node/framework/podresize/resize.go | 11 +++++++++-- test/e2e/common/node/pod_level_resources_resize.go | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/test/e2e/common/node/framework/podresize/resize.go b/test/e2e/common/node/framework/podresize/resize.go index a9426587bac..c1888449d9c 100644 --- a/test/e2e/common/node/framework/podresize/resize.go +++ b/test/e2e/common/node/framework/podresize/resize.go @@ -375,8 +375,14 @@ func WaitForPodResizeActuation(ctx context.Context, f *framework.Framework, podC return "resize is infeasible" }, nil } - // TODO: Replace this check with a combination of checking the status.observedGeneration - // and the resize status when available. + + if pod.Status.ObservedGeneration < pod.Generation { + return func() string { + return fmt.Sprintf("waiting for observedGeneration (%d) to catch up to generation (%d)", + pod.Status.ObservedGeneration, pod.Generation) + }, nil + } + if resourceErrs := VerifyPodStatusResources(pod, expectedContainers); resourceErrs != nil { return func() string { return fmt.Sprintf("container status resources don't match expected: %v", formatErrors(resourceErrs)) @@ -390,6 +396,7 @@ func WaitForPodResizeActuation(ctx context.Context, f *framework.Framework, podC }, nil } } + // Wait for the pod to be ready. if !podutils.IsPodReady(pod) { return func() string { return "pod is not ready" }, nil diff --git a/test/e2e/common/node/pod_level_resources_resize.go b/test/e2e/common/node/pod_level_resources_resize.go index e4695f2dd76..183f801e5a1 100644 --- a/test/e2e/common/node/pod_level_resources_resize.go +++ b/test/e2e/common/node/pod_level_resources_resize.go @@ -27,6 +27,7 @@ import ( v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" utilerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/kubernetes/pkg/features" From 3b19886847bff7eb75188437718a94dd6df533f2 Mon Sep 17 00:00:00 2001 From: ndixita Date: Thu, 19 Mar 2026 07:02:08 +0000 Subject: [PATCH 2/3] Test fixes - update expected restart count for containers with no resources that inherit changes due to pod-level modifications --- test/e2e/common/node/pod_level_resources_resize.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/e2e/common/node/pod_level_resources_resize.go b/test/e2e/common/node/pod_level_resources_resize.go index 183f801e5a1..f71c166ce9b 100644 --- a/test/e2e/common/node/pod_level_resources_resize.go +++ b/test/e2e/common/node/pod_level_resources_resize.go @@ -79,10 +79,11 @@ func doGuaranteedPodLevelResizeTests(f *framework.Framework) { } // For containers where the resize policy is "restart", we expect a restart. expectRestart := int32(0) - if cpuPolicy == v1.RestartContainer && desiredCtrCPU != originalCtrCPU { + + if cpuPolicy == v1.RestartContainer && (desiredCtrCPU != originalCtrCPU || (desiredCtrCPU == "" && desiredPodCPU != originalCPU)) { expectRestart = 1 } - if memPolicy == v1.RestartContainer && desiredCtrMem != originalCtrMem { + if memPolicy == v1.RestartContainer && (desiredCtrMem != originalCtrMem || (desiredCtrMem == "" && desiredPodMem != originalMem)) { expectRestart = 1 } c.RestartCount = expectRestart From ec6d65e33397e0739800a64d0fb32f8f9407b045 Mon Sep 17 00:00:00 2001 From: ndixita Date: Thu, 19 Mar 2026 21:21:39 +0000 Subject: [PATCH 3/3] test fixes --- test/e2e/common/node/framework/podresize/resize.go | 5 ----- test/e2e/common/node/pod_level_resources_resize.go | 5 +++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/test/e2e/common/node/framework/podresize/resize.go b/test/e2e/common/node/framework/podresize/resize.go index c1888449d9c..5065883f62b 100644 --- a/test/e2e/common/node/framework/podresize/resize.go +++ b/test/e2e/common/node/framework/podresize/resize.go @@ -383,11 +383,6 @@ func WaitForPodResizeActuation(ctx context.Context, f *framework.Framework, podC }, nil } - if resourceErrs := VerifyPodStatusResources(pod, expectedContainers); resourceErrs != nil { - return func() string { - return fmt.Sprintf("container status resources don't match expected: %v", formatErrors(resourceErrs)) - }, nil - } // Wait for kubelet to clear the resize status conditions. for _, c := range pod.Status.Conditions { if c.Type == v1.PodResizePending || c.Type == v1.PodResizeInProgress { diff --git a/test/e2e/common/node/pod_level_resources_resize.go b/test/e2e/common/node/pod_level_resources_resize.go index f71c166ce9b..a1e404516dc 100644 --- a/test/e2e/common/node/pod_level_resources_resize.go +++ b/test/e2e/common/node/pod_level_resources_resize.go @@ -27,7 +27,6 @@ import ( v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" utilerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/kubernetes/pkg/features" @@ -72,7 +71,9 @@ func doGuaranteedPodLevelResizeTests(f *framework.Framework) { expectedContainers := makeGuaranteedContainers(1, cpuPolicy, memPolicy, true, true, desiredCtrCPU, desiredCtrMem) for i, c := range expectedContainers { // If the pod has init containers, but we are not resizing them, keep the original resources. - if c.InitCtr && !resizeInitCtrs { + podLevelOnly := (desiredCtrCPU == "" && desiredPodCPU != originalCPU) || (desiredCtrMem == "" && desiredPodMem != originalMem) + + if c.InitCtr && !resizeInitCtrs && !podLevelOnly { c.Resources = originalContainers[i].Resources expectedContainers[i] = c continue