mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 15:58:37 +00:00
Don't allow resize policy mutation
This commit is contained in:
parent
a1595d9dca
commit
e52274a9e2
@ -5710,7 +5710,6 @@ func dropCPUMemoryResourcesFromContainer(container *core.Container, oldPodSpecCo
|
||||
lim := dropCPUMemoryUpdates(container.Resources.Limits, oldPodSpecContainer.Resources.Limits)
|
||||
req := dropCPUMemoryUpdates(container.Resources.Requests, oldPodSpecContainer.Resources.Requests)
|
||||
container.Resources = core.ResourceRequirements{Limits: lim, Requests: req}
|
||||
container.ResizePolicy = oldPodSpecContainer.ResizePolicy // +k8s:verify-mutation:reason=clone
|
||||
}
|
||||
|
||||
// isPodResizeRequestSupported checks whether the pod is running on a node with InPlacePodVerticalScaling enabled.
|
||||
|
@ -26073,6 +26073,16 @@ func TestValidatePodResize(t *testing.T) {
|
||||
old: mkPodWithInitContainers(getResources("100m", "0", "1Gi", ""), core.ResourceList{}, core.ContainerRestartPolicyAlways),
|
||||
new: mkPodWithInitContainers(getResources("100m", "0", "2Gi", ""), core.ResourceList{}, core.ContainerRestartPolicyAlways),
|
||||
err: "spec: Forbidden: only cpu and memory resources for sidecar containers are mutable",
|
||||
}, {
|
||||
test: "change resize restart policy",
|
||||
old: mkPod(getResources("100m", "0", "1Gi", ""), core.ResourceList{}, resizePolicy(core.ResourceCPU, core.NotRequired)),
|
||||
new: mkPod(getResources("100m", "0", "2Gi", ""), core.ResourceList{}, resizePolicy(core.ResourceCPU, core.RestartContainer)),
|
||||
err: "spec: Forbidden: only cpu and memory resources are mutable",
|
||||
}, {
|
||||
test: "change sidecar container resize restart policy",
|
||||
old: mkPodWithInitContainers(getResources("100m", "0", "1Gi", ""), core.ResourceList{}, core.ContainerRestartPolicyAlways, resizePolicy(core.ResourceMemory, core.RestartContainer)),
|
||||
new: mkPodWithInitContainers(getResources("100m", "0", "2Gi", ""), core.ResourceList{}, core.ContainerRestartPolicyAlways, resizePolicy(core.ResourceMemory, core.NotRequired)),
|
||||
err: "spec: Forbidden: only cpu and memory resources are mutable",
|
||||
},
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user