diff --git a/test/e2e/common/node/framework/podresize/resize.go b/test/e2e/common/node/framework/podresize/resize.go index a9426587bac..5065883f62b 100644 --- a/test/e2e/common/node/framework/podresize/resize.go +++ b/test/e2e/common/node/framework/podresize/resize.go @@ -375,13 +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 resourceErrs := VerifyPodStatusResources(pod, expectedContainers); resourceErrs != nil { + + if pod.Status.ObservedGeneration < pod.Generation { return func() string { - return fmt.Sprintf("container status resources don't match expected: %v", formatErrors(resourceErrs)) + return fmt.Sprintf("waiting for observedGeneration (%d) to catch up to generation (%d)", + pod.Status.ObservedGeneration, pod.Generation) }, 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 { @@ -390,6 +391,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..a1e404516dc 100644 --- a/test/e2e/common/node/pod_level_resources_resize.go +++ b/test/e2e/common/node/pod_level_resources_resize.go @@ -71,17 +71,20 @@ 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 } // 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