mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Consider memory requests in determining if resize is in progress, set termination grace period to 0
This commit is contained in:
parent
951e33fdf9
commit
7f4b9a52db
@ -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])
|
||||
})
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user