Skip to content

Commit 7f4b9a5

Browse files
committed
Consider memory requests in determining if resize is in progress, set termination grace period to 0
1 parent 951e33f commit 7f4b9a5

File tree

4 files changed

+3
-6
lines changed

4 files changed

+3
-6
lines changed

pkg/kubelet/kubelet.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2989,7 +2989,6 @@ func (kl *Kubelet) handlePodResourcesResize(pod *v1.Pod, podStatus *kubecontaine
29892989
// for any running containers. Specifically, the following differences are ignored:
29902990
// - Non-resizable containers: non-restartable init containers, ephemeral containers
29912991
// - Non-resizable resources: only CPU & memory are resizable
2992-
// - Non-actuated resources: memory requests are not actuated
29932992
// - Non-running containers: they will be sized correctly when (re)started
29942993
func (kl *Kubelet) isPodResizeInProgress(allocatedPod *v1.Pod, podStatus *kubecontainer.PodStatus) bool {
29952994
return !podutil.VisitContainers(&allocatedPod.Spec, podutil.InitContainers|podutil.Containers,
@@ -3007,9 +3006,9 @@ func (kl *Kubelet) isPodResizeInProgress(allocatedPod *v1.Pod, podStatus *kubeco
30073006
actuatedResources, _ := kl.allocationManager.GetActuatedResources(allocatedPod.UID, allocatedContainer.Name)
30083007
allocatedResources := allocatedContainer.Resources
30093008

3010-
// Memory requests are excluded since they don't need to be actuated.
30113009
return allocatedResources.Requests[v1.ResourceCPU].Equal(actuatedResources.Requests[v1.ResourceCPU]) &&
30123010
allocatedResources.Limits[v1.ResourceCPU].Equal(actuatedResources.Limits[v1.ResourceCPU]) &&
3011+
allocatedResources.Requests[v1.ResourceMemory].Equal(actuatedResources.Requests[v1.ResourceMemory]) &&
30133012
allocatedResources.Limits[v1.ResourceMemory].Equal(actuatedResources.Limits[v1.ResourceMemory])
30143013
})
30153014
}

pkg/kubelet/kuberuntime/kuberuntime_manager.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ const (
7777
kubeRuntimeAPIVersion = "0.1.0"
7878
// A minimal shutdown window for avoiding unnecessary SIGKILLs
7979
minimumGracePeriodInSeconds = 2
80-
MinimumGracePeriodInSeconds = int64(minimumGracePeriodInSeconds)
8180

8281
// The expiration time of version cache.
8382
versionCacheTTL = 60 * time.Second

test/e2e/framework/pod/resize.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
utilerrors "k8s.io/apimachinery/pkg/util/errors"
3232
helpers "k8s.io/component-helpers/resource"
3333
kubecm "k8s.io/kubernetes/pkg/kubelet/cm"
34-
"k8s.io/kubernetes/pkg/kubelet/kuberuntime"
3534
"k8s.io/kubernetes/test/e2e/framework"
3635
imageutils "k8s.io/kubernetes/test/utils/image"
3736

@@ -170,7 +169,7 @@ func makeResizableContainer(tcInfo ResizableContainerInfo) v1.Container {
170169
func MakePodWithResizableContainers(ns, name, timeStamp string, tcInfo []ResizableContainerInfo) *v1.Pod {
171170
testInitContainers, testContainers := separateContainers(tcInfo)
172171

173-
minGracePeriodSeconds := kuberuntime.MinimumGracePeriodInSeconds
172+
minGracePeriodSeconds := int64(0)
174173
pod := &v1.Pod{
175174
ObjectMeta: metav1.ObjectMeta{
176175
Name: name,
@@ -433,6 +432,7 @@ func WaitForPodResizeActuation(ctx context.Context, f *framework.Framework, podC
433432
containerRestartWaitPeriod = MinRestartWaitPeriod
434433
}
435434
time.Sleep(time.Duration(containerRestartWaitPeriod) * time.Second)
435+
436436
resizedPod, err := framework.GetObject(podClient.Get, pod.Name, metav1.GetOptions{})(ctx)
437437
framework.ExpectNoError(err, "failed to get resized pod")
438438
return resizedPod

test/e2e/framework/pod/utils.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ func VerifyOomScoreAdjValue(f *framework.Framework, pod *v1.Pod, cName, expected
309309
if oomScoreAdj != expectedOomScoreAdj {
310310
return fmt.Errorf("oom_score_adj value %s not equal to expected %s", oomScoreAdj, expectedOomScoreAdj)
311311
}
312-
fmt.Printf("VDBG: POD: %s EXPECTED_OOM_ADJ %s ACTUAL_OOM_ADJ %s\n", pod.Name, expectedOomScoreAdj, oomScoreAdj)
313312
return nil
314313
}
315314

0 commit comments

Comments
 (0)