Skip to content

Commit 6737352

Browse files
authored
Merge pull request kubernetes#125708 from hshiina/dopodresizeaction-error
[FG:InPlacePodVerticalScaling] Fix order of resizing pod cgroups in doPodResizeAction()
2 parents e8a75ac + 1ec1ef3 commit 6737352

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pkg/kubelet/kuberuntime/kuberuntime_manager.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,7 @@ func (m *kubeGenericRuntimeManager) doPodResizeAction(pod *v1.Pod, podStatus *ku
684684
// If an error occurs at any point, abort. Let future syncpod iterations retry the unfinished stuff.
685685
resizeContainers := func(rName v1.ResourceName, currPodCgLimValue, newPodCgLimValue, currPodCgReqValue, newPodCgReqValue int64) error {
686686
var err error
687+
// At upsizing, limits should expand prior to requests in order to keep "requests <= limits".
687688
if newPodCgLimValue > currPodCgLimValue {
688689
if err = setPodCgroupConfig(rName, true); err != nil {
689690
return err
@@ -700,14 +701,17 @@ func (m *kubeGenericRuntimeManager) doPodResizeAction(pod *v1.Pod, podStatus *ku
700701
return err
701702
}
702703
}
703-
if newPodCgLimValue < currPodCgLimValue {
704-
err = setPodCgroupConfig(rName, true)
705-
}
704+
// At downsizing, requests should shrink prior to limits in order to keep "requests <= limits".
706705
if newPodCgReqValue < currPodCgReqValue {
707706
if err = setPodCgroupConfig(rName, false); err != nil {
708707
return err
709708
}
710709
}
710+
if newPodCgLimValue < currPodCgLimValue {
711+
if err = setPodCgroupConfig(rName, true); err != nil {
712+
return err
713+
}
714+
}
711715
return err
712716
}
713717
if len(podContainerChanges.ContainersToUpdate[v1.ResourceMemory]) > 0 || podContainerChanges.UpdatePodResources {

0 commit comments

Comments
 (0)