Skip to content

Commit dff657a

Browse files
authored
Merge pull request kubernetes#128623 from AnishShah/ippr-windows
[FG:InPlacePodVerticalScaling] Drop InPlacePodVerticalScaling support in windows
2 parents 7faac24 + 207842d commit dff657a

File tree

4 files changed

+48
-14
lines changed

4 files changed

+48
-14
lines changed

pkg/apis/core/validation/validation.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5503,6 +5503,11 @@ func ValidatePodResize(newPod, oldPod *core.Pod, opts PodValidationOptions) fiel
55035503
return field.ErrorList{field.Forbidden(field.NewPath(""), "static pods cannot be resized")}
55045504
}
55055505

5506+
// windows pods are not supported.
5507+
if oldPod.Spec.OS != nil && oldPod.Spec.OS.Name == core.Windows {
5508+
return field.ErrorList{field.Forbidden(field.NewPath(""), "windows pods cannot be resized")}
5509+
}
5510+
55065511
// Part 2: Validate that the changes between oldPod.Spec.Containers[].Resources and
55075512
// newPod.Spec.Containers[].Resources are allowed.
55085513
specPath := field.NewPath("spec")

pkg/apis/core/validation/validation_test.go

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25075,22 +25075,20 @@ func TestValidateSELinuxChangePolicy(t *testing.T) {
2507525075
}
2507625076

2507725077
func TestValidatePodResize(t *testing.T) {
25078-
mkPod := func(req, lim core.ResourceList, tweaks ...podtest.TweakContainer) *core.Pod {
25079-
return podtest.MakePod("pod",
25078+
mkPod := func(req, lim core.ResourceList, tweaks ...podtest.Tweak) *core.Pod {
25079+
return podtest.MakePod("pod", append(tweaks,
2508025080
podtest.SetContainers(
2508125081
podtest.MakeContainer(
2508225082
"container",
25083-
append(tweaks,
25084-
podtest.SetContainerResources(
25085-
core.ResourceRequirements{
25086-
Requests: req,
25087-
Limits: lim,
25088-
},
25089-
),
25090-
)...,
25083+
podtest.SetContainerResources(
25084+
core.ResourceRequirements{
25085+
Requests: req,
25086+
Limits: lim,
25087+
},
25088+
),
2509125089
),
2509225090
),
25093-
)
25091+
)...)
2509425092
}
2509525093

2509625094
tests := []struct {
@@ -25179,6 +25177,16 @@ func TestValidatePodResize(t *testing.T) {
2517925177
old: mkPod(getResources("100m", "100Mi", "", ""), getResources("200m", "200Mi", "", "")),
2518025178
new: mkPod(core.ResourceList{}, core.ResourceList{}),
2518125179
err: "Pod QOS Class may not change as a result of resizing",
25180+
}, {
25181+
test: "windows pod, no resource change",
25182+
old: mkPod(core.ResourceList{}, getResources("100m", "0", "1Gi", ""), podtest.SetOS(core.Windows)),
25183+
new: mkPod(core.ResourceList{}, getResources("100m", "0", "1Gi", ""), podtest.SetOS(core.Windows)),
25184+
err: "Forbidden: windows pods cannot be resized",
25185+
}, {
25186+
test: "windows pod, resource change",
25187+
old: mkPod(core.ResourceList{}, getResources("100m", "0", "1Gi", ""), podtest.SetOS(core.Windows)),
25188+
new: mkPod(core.ResourceList{}, getResources("200m", "0", "1Gi", ""), podtest.SetOS(core.Windows)),
25189+
err: "Forbidden: windows pods cannot be resized",
2518225190
},
2518325191
}
2518425192

pkg/kubelet/kubelet.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,13 @@ var (
243243
topologymanager.ErrorTopologyAffinity,
244244
nodeshutdown.NodeShutdownNotAdmittedReason,
245245
)
246+
247+
// This is exposed for unit tests.
248+
goos = sysruntime.GOOS
246249
)
247250

248251
func getContainerEtcHostsPath() string {
249-
if sysruntime.GOOS == "windows" {
252+
if goos == "windows" {
250253
return windowsEtcHostsPath
251254
}
252255
return linuxEtcHostsPath
@@ -940,7 +943,7 @@ func NewMainKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
940943
opt(klet)
941944
}
942945

943-
if sysruntime.GOOS == "linux" {
946+
if goos == "linux" {
944947
// AppArmor is a Linux kernel security module and it does not support other operating systems.
945948
klet.appArmorValidator = apparmor.NewValidator()
946949
klet.admitHandlers.AddPodAdmitHandler(lifecycle.NewAppArmorAdmitHandler(klet.appArmorValidator))
@@ -1564,7 +1567,7 @@ func (kl *Kubelet) initializeModules() error {
15641567
}
15651568
}
15661569

1567-
if sysruntime.GOOS == "windows" {
1570+
if goos == "windows" {
15681571
// On Windows we should not allow other users to read the logs directory
15691572
// to avoid allowing non-root containers from reading the logs of other containers.
15701573
if err := utilfs.Chmod(ContainerLogsDir, 0750); err != nil {
@@ -2865,6 +2868,10 @@ func (kl *Kubelet) handlePodResourcesResize(pod *v1.Pod, podStatus *kubecontaine
28652868
// Pod allocation does not need to be updated.
28662869
return allocatedPod, nil
28672870
}
2871+
if goos == "windows" {
2872+
kl.statusManager.SetPodResizeStatus(pod.UID, v1.PodResizeStatusInfeasible)
2873+
return allocatedPod, nil
2874+
}
28682875

28692876
kl.podResizeMutex.Lock()
28702877
defer kl.podResizeMutex.Unlock()

pkg/kubelet/kubelet_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2676,6 +2676,7 @@ func TestHandlePodResourcesResize(t *testing.T) {
26762676
newRequestsAllocated bool // Whether the new requests have already been allocated (but not actuated)
26772677
expectedAllocations v1.ResourceList
26782678
expectedResize v1.PodResizeStatus
2679+
goos string
26792680
}{
26802681
{
26812682
name: "Request CPU and memory decrease - expect InProgress",
@@ -2741,10 +2742,23 @@ func TestHandlePodResourcesResize(t *testing.T) {
27412742
expectedAllocations: v1.ResourceList{v1.ResourceCPU: cpu1000m, v1.ResourceMemory: mem1000M},
27422743
expectedResize: "",
27432744
},
2745+
{
2746+
name: "windows node, expect Infeasible",
2747+
pod: testPod2,
2748+
newRequests: v1.ResourceList{v1.ResourceCPU: cpu500m, v1.ResourceMemory: mem500M},
2749+
expectedAllocations: v1.ResourceList{v1.ResourceCPU: cpu1000m, v1.ResourceMemory: mem1000M},
2750+
expectedResize: v1.PodResizeStatusInfeasible,
2751+
goos: "windows",
2752+
},
27442753
}
27452754

27462755
for _, tt := range tests {
27472756
t.Run(tt.name, func(t *testing.T) {
2757+
oldGOOS := goos
2758+
defer func() { goos = oldGOOS }()
2759+
if tt.goos != "" {
2760+
goos = tt.goos
2761+
}
27482762
kubelet.statusManager = status.NewFakeManager()
27492763

27502764
newPod := tt.pod.DeepCopy()

0 commit comments

Comments
 (0)