@@ -550,20 +550,14 @@ func containerSucceeded(c *v1.Container, podStatus *kubecontainer.PodStatus) boo
550
550
return cStatus .State == kubecontainer .ContainerStateExited && cStatus .ExitCode == 0
551
551
}
552
552
553
- func IsInPlacePodVerticalScalingAllowed (pod * v1.Pod ) bool {
554
- if ! utilfeature .DefaultFeatureGate .Enabled (features .InPlacePodVerticalScaling ) {
555
- return false
556
- }
557
- if types .IsStaticPod (pod ) {
558
- return false
559
- }
560
- return true
561
- }
562
-
563
553
// computePodResizeAction determines the actions required (if any) to resize the given container.
564
554
// Returns whether to keep (true) or restart (false) the container.
565
555
// TODO(vibansal): Make this function to be agnostic to whether it is dealing with a restartable init container or not (i.e. remove the argument `isRestartableInitContainer`).
566
556
func (m * kubeGenericRuntimeManager ) computePodResizeAction (pod * v1.Pod , containerIdx int , isRestartableInitContainer bool , kubeContainerStatus * kubecontainer.Status , changes * podActions ) (keepContainer bool ) {
557
+ if resizable , _ := IsInPlacePodVerticalScalingAllowed (pod ); ! resizable {
558
+ return true
559
+ }
560
+
567
561
var container v1.Container
568
562
if isRestartableInitContainer {
569
563
container = pod .Spec .InitContainers [containerIdx ]
@@ -997,7 +991,7 @@ func (m *kubeGenericRuntimeManager) computePodActions(ctx context.Context, pod *
997
991
}
998
992
}
999
993
1000
- if IsInPlacePodVerticalScalingAllowed (pod ) {
994
+ if resizable , _ := IsInPlacePodVerticalScalingAllowed (pod ); resizable {
1001
995
changes .ContainersToUpdate = make (map [v1.ResourceName ][]containerToUpdateInfo )
1002
996
}
1003
997
@@ -1092,7 +1086,7 @@ func (m *kubeGenericRuntimeManager) computePodActions(ctx context.Context, pod *
1092
1086
// If the container failed the startup probe, we should kill it.
1093
1087
message = fmt .Sprintf ("Container %s failed startup probe" , container .Name )
1094
1088
reason = reasonStartupProbe
1095
- } else if IsInPlacePodVerticalScalingAllowed ( pod ) && ! m .computePodResizeAction (pod , idx , false , containerStatus , & changes ) {
1089
+ } else if ! m .computePodResizeAction (pod , idx , false , containerStatus , & changes ) {
1096
1090
// computePodResizeAction updates 'changes' if resize policy requires restarting this container
1097
1091
continue
1098
1092
} else {
@@ -1413,7 +1407,7 @@ func (m *kubeGenericRuntimeManager) SyncPod(ctx context.Context, pod *v1.Pod, po
1413
1407
}
1414
1408
1415
1409
// Step 7: For containers in podContainerChanges.ContainersToUpdate[CPU,Memory] list, invoke UpdateContainerResources
1416
- if IsInPlacePodVerticalScalingAllowed (pod ) {
1410
+ if resizable , _ := IsInPlacePodVerticalScalingAllowed (pod ); resizable {
1417
1411
if len (podContainerChanges .ContainersToUpdate ) > 0 || podContainerChanges .UpdatePodResources {
1418
1412
m .doPodResizeAction (pod , podContainerChanges , & result )
1419
1413
}
0 commit comments