mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 18:00:08 +00:00
fix error message for pod resize validation failure
This commit is contained in:
parent
07ca0b09bb
commit
ce0f4597d3
@ -5485,6 +5485,9 @@ func ValidatePodEphemeralContainersUpdate(newPod, oldPod *core.Pod, opts PodVali
|
|||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ValidatePodResize tests that a user update to pod container resources is valid.
|
||||||
|
// newPod and oldPod must only differ in their Containers[*].Resources and
|
||||||
|
// Containers[*].ResizePolicy field.
|
||||||
func ValidatePodResize(newPod, oldPod *core.Pod, opts PodValidationOptions) field.ErrorList {
|
func ValidatePodResize(newPod, oldPod *core.Pod, opts PodValidationOptions) field.ErrorList {
|
||||||
// Part 1: Validate newPod's spec and updates to metadata
|
// Part 1: Validate newPod's spec and updates to metadata
|
||||||
fldPath := field.NewPath("metadata")
|
fldPath := field.NewPath("metadata")
|
||||||
@ -5501,7 +5504,7 @@ func ValidatePodResize(newPod, oldPod *core.Pod, opts PodValidationOptions) fiel
|
|||||||
// newPod.Spec.Containers[].Resources are allowed.
|
// newPod.Spec.Containers[].Resources are allowed.
|
||||||
specPath := field.NewPath("spec")
|
specPath := field.NewPath("spec")
|
||||||
if qos.GetPodQOS(oldPod) != qos.ComputePodQOS(newPod) {
|
if qos.GetPodQOS(oldPod) != qos.ComputePodQOS(newPod) {
|
||||||
allErrs = append(allErrs, field.Invalid(specPath, newPod.Status.QOSClass, "Pod QoS is immutable"))
|
allErrs = append(allErrs, field.Invalid(specPath, newPod.Status.QOSClass, "Pod QOS Class must not change"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that only CPU and memory resources are mutable.
|
// Ensure that only CPU and memory resources are mutable.
|
||||||
|
@ -25315,7 +25315,7 @@ func TestValidatePodResize(t *testing.T) {
|
|||||||
Requests: getResourceLimits("100m", "100Mi"),
|
Requests: getResourceLimits("100m", "100Mi"),
|
||||||
}))),
|
}))),
|
||||||
),
|
),
|
||||||
err: "Pod QoS is immutable",
|
err: "Pod QOS Class must not change",
|
||||||
test: "Pod QoS change, guaranteed -> burstable",
|
test: "Pod QoS change, guaranteed -> burstable",
|
||||||
}, {
|
}, {
|
||||||
new: *podtest.MakePod("pod",
|
new: *podtest.MakePod("pod",
|
||||||
@ -25331,7 +25331,7 @@ func TestValidatePodResize(t *testing.T) {
|
|||||||
Requests: getResourceLimits("100m", "100Mi"),
|
Requests: getResourceLimits("100m", "100Mi"),
|
||||||
}))),
|
}))),
|
||||||
),
|
),
|
||||||
err: "Pod QoS is immutable",
|
err: "Pod QOS Class must not change",
|
||||||
test: "Pod QoS change, burstable -> guaranteed",
|
test: "Pod QoS change, burstable -> guaranteed",
|
||||||
}, {
|
}, {
|
||||||
new: *podtest.MakePod("pod",
|
new: *podtest.MakePod("pod",
|
||||||
@ -25342,7 +25342,7 @@ func TestValidatePodResize(t *testing.T) {
|
|||||||
}))),
|
}))),
|
||||||
),
|
),
|
||||||
old: *podtest.MakePod("pod"),
|
old: *podtest.MakePod("pod"),
|
||||||
err: "Pod QoS is immutable",
|
err: "Pod QOS Class must not change",
|
||||||
test: "Pod QoS change, besteffort -> burstable",
|
test: "Pod QoS change, besteffort -> burstable",
|
||||||
}, {
|
}, {
|
||||||
new: *podtest.MakePod("pod"),
|
new: *podtest.MakePod("pod"),
|
||||||
@ -25353,7 +25353,7 @@ func TestValidatePodResize(t *testing.T) {
|
|||||||
Requests: getResourceLimits("100m", "100Mi"),
|
Requests: getResourceLimits("100m", "100Mi"),
|
||||||
}))),
|
}))),
|
||||||
),
|
),
|
||||||
err: "Pod QoS is immutable",
|
err: "Pod QOS Class must not change",
|
||||||
test: "Pod QoS change, burstable -> besteffort",
|
test: "Pod QoS change, burstable -> besteffort",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user