Never attempt a resize of windows pods

This commit is contained in:
Tim Allclair 2024-12-13 16:40:25 -08:00
parent a5dda5d879
commit 6df3ea46d9

View File

@ -22,6 +22,7 @@ import (
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
"runtime"
"sort" "sort"
"time" "time"
@ -551,19 +552,19 @@ func containerSucceeded(c *v1.Container, podStatus *kubecontainer.PodStatus) boo
} }
func IsInPlacePodVerticalScalingAllowed(pod *v1.Pod) bool { func IsInPlacePodVerticalScalingAllowed(pod *v1.Pod) bool {
if !utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) { return utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) &&
return false !types.IsStaticPod(pod) &&
} runtime.GOOS != "windows"
if types.IsStaticPod(pod) {
return false
}
return true
} }
// computePodResizeAction determines the actions required (if any) to resize the given container. // computePodResizeAction determines the actions required (if any) to resize the given container.
// Returns whether to keep (true) or restart (false) the container. // Returns whether to keep (true) or restart (false) the container.
// 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`). // 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`).
func (m *kubeGenericRuntimeManager) computePodResizeAction(pod *v1.Pod, containerIdx int, isRestartableInitContainer bool, kubeContainerStatus *kubecontainer.Status, changes *podActions) (keepContainer bool) { func (m *kubeGenericRuntimeManager) computePodResizeAction(pod *v1.Pod, containerIdx int, isRestartableInitContainer bool, kubeContainerStatus *kubecontainer.Status, changes *podActions) (keepContainer bool) {
if !IsInPlacePodVerticalScalingAllowed(pod) {
return true
}
var container v1.Container var container v1.Container
if isRestartableInitContainer { if isRestartableInitContainer {
container = pod.Spec.InitContainers[containerIdx] container = pod.Spec.InitContainers[containerIdx]
@ -1092,7 +1093,7 @@ func (m *kubeGenericRuntimeManager) computePodActions(ctx context.Context, pod *
// If the container failed the startup probe, we should kill it. // If the container failed the startup probe, we should kill it.
message = fmt.Sprintf("Container %s failed startup probe", container.Name) message = fmt.Sprintf("Container %s failed startup probe", container.Name)
reason = reasonStartupProbe reason = reasonStartupProbe
} else if IsInPlacePodVerticalScalingAllowed(pod) && !m.computePodResizeAction(pod, idx, false, containerStatus, &changes) { } else if !m.computePodResizeAction(pod, idx, false, containerStatus, &changes) {
// computePodResizeAction updates 'changes' if resize policy requires restarting this container // computePodResizeAction updates 'changes' if resize policy requires restarting this container
continue continue
} else { } else {