diff --git a/pkg/kubelet/kuberuntime/kuberuntime_manager.go b/pkg/kubelet/kuberuntime/kuberuntime_manager.go index 909e83e854b..4165b24af79 100644 --- a/pkg/kubelet/kuberuntime/kuberuntime_manager.go +++ b/pkg/kubelet/kuberuntime/kuberuntime_manager.go @@ -77,6 +77,7 @@ 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 @@ -84,6 +85,7 @@ const ( identicalErrorDelay = 1 * time.Minute // OpenTelemetry instrumentation scope name instrumentationScope = "k8s.io/kubernetes/pkg/kubelet/kuberuntime" + ) var ( diff --git a/test/e2e/common/node/pod_resize.go b/test/e2e/common/node/pod_resize.go index 07264dbf792..69822033d7f 100644 --- a/test/e2e/common/node/pod_resize.go +++ b/test/e2e/common/node/pod_resize.go @@ -1440,7 +1440,7 @@ func doPodResizeErrorTests() { // Above tests are performed by doSheduletTests() and doPodResizeResourceQuotaTests() // in test/e2e/node/pod_resize.go -var _ = SIGDescribe("[InPlacePodResize] Pod InPlace Resize Container", feature.InPlacePodVerticalScaling, func() { +var _ = SIGDescribe("Pod InPlace Resize Container", feature.InPlacePodVerticalScaling, func() { f := framework.NewDefaultFramework("pod-resize-tests") ginkgo.BeforeEach(func(ctx context.Context) { diff --git a/test/e2e/framework/pod/resize.go b/test/e2e/framework/pod/resize.go index b077f62a9cd..00465bfb93a 100644 --- a/test/e2e/framework/pod/resize.go +++ b/test/e2e/framework/pod/resize.go @@ -31,6 +31,7 @@ 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" @@ -49,7 +50,7 @@ const ( Cgroupv2CPURequest string = "/sys/fs/cgroup/cpu.weight" CPUPeriod string = "100000" MinContainerRuntimeVersion string = "1.6.9" - MinimumGracePeriodSeconds int64 = 2 + MinRestartWaitPeriod int = 10 ) var ( @@ -169,7 +170,7 @@ func makeResizableContainer(tcInfo ResizableContainerInfo) v1.Container { func MakePodWithResizableContainers(ns, name, timeStamp string, tcInfo []ResizableContainerInfo) *v1.Pod { testInitContainers, testContainers := separateContainers(tcInfo) - var minGracePeriodSeconds int64 = MinimumGracePeriodSeconds + minGracePeriodSeconds := kuberuntime.MinimumGracePeriodInSeconds pod := &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ Name: name, @@ -354,7 +355,8 @@ func VerifyPodContainersCgroupValues(ctx context.Context, f *framework.Framework } errs = append(errs, VerifyCgroupValue(f, pod, ci.Name, cgroupCPULimit, expectedCPULimitString)) errs = append(errs, VerifyCgroupValue(f, pod, ci.Name, cgroupCPURequest, strconv.FormatInt(expectedCPUShares, 10))) - //TODO(vinaykul,InPlacePodVerticalScaling): Verify oom_score_adj when runc adds support for updating it + // TODO(vinaykul,InPlacePodVerticalScaling): Verify oom_score_adj when runc adds support for updating it + // See https://github.com/opencontainers/runc/pull/4669 } } return utilerrors.NewAggregate(errs) @@ -425,8 +427,12 @@ func WaitForPodResizeActuation(ctx context.Context, f *framework.Framework, podC })), ) - // Wait 2x termination grace period to catch any restarts - expected or not - time.Sleep(time.Duration(*pod.Spec.TerminationGracePeriodSeconds*2) * time.Second) + // Wait min(3 x termination grace period, MinRestartWaitPeriod) to catch any restarts - expected or not + containerRestartWaitPeriod := int(*pod.Spec.TerminationGracePeriodSeconds) * 3 + if containerRestartWaitPeriod < MinRestartWaitPeriod { + 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 824c1ada969..1c4cb50d8de 100644 --- a/test/e2e/framework/pod/utils.go +++ b/test/e2e/framework/pod/utils.go @@ -298,7 +298,7 @@ func VerifyCgroupValue(f *framework.Framework, pod *v1.Pod, cName, cgPath, expec // has the expected value in specified container of the pod. It execs into the container, // reads the oom_score_adj value from procfs, and compares it against the expected value. func VerifyOomScoreAdjValue(f *framework.Framework, pod *v1.Pod, cName, expectedOomScoreAdj string) error { - cmd := fmt.Sprintf("cat /proc/1/oom_score_adj") + cmd := "cat /proc/1/oom_score_adj" framework.Logf("Namespace %s Pod %s Container %s - looking for oom_score_adj value %s", pod.Namespace, pod.Name, cName, expectedOomScoreAdj) oomScoreAdj, _, err := ExecCommandInContainerWithFullOutput(f, pod.Name, cName, "/bin/sh", "-c", cmd)