mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-01 18:58:18 +00:00
Merge pull request #127744 from carlory/fix-126662
Tighten validation on the qosClass field of pod status
This commit is contained in:
@@ -5382,6 +5382,9 @@ func ValidatePodStatusUpdate(newPod, oldPod *core.Pod, opts PodValidationOptions
|
||||
}
|
||||
}
|
||||
|
||||
// Pod QoS is immutable
|
||||
allErrs = append(allErrs, ValidateImmutableField(newPod.Status.QOSClass, oldPod.Status.QOSClass, fldPath.Child("qosClass"))...)
|
||||
|
||||
// If pod should not restart, make sure the status update does not transition
|
||||
// any terminated containers to a non-terminated state.
|
||||
allErrs = append(allErrs, ValidateContainerStateTransition(newPod.Status.ContainerStatuses, oldPod.Status.ContainerStatuses, fldPath.Child("containerStatuses"), oldPod.Spec.RestartPolicy)...)
|
||||
|
||||
@@ -14454,6 +14454,32 @@ func TestValidatePodStatusUpdate(t *testing.T) {
|
||||
),
|
||||
"",
|
||||
"restartable init container can restart if RestartPolicyAlways",
|
||||
}, {
|
||||
*podtest.MakePod("foo",
|
||||
podtest.SetStatus(core.PodStatus{
|
||||
QOSClass: core.PodQOSBurstable,
|
||||
}),
|
||||
),
|
||||
*podtest.MakePod("foo",
|
||||
podtest.SetStatus(core.PodStatus{
|
||||
QOSClass: core.PodQOSGuaranteed,
|
||||
}),
|
||||
),
|
||||
"tatus.qosClass: Invalid value: \"Burstable\": field is immutable",
|
||||
"qosClass can not be changed",
|
||||
}, {
|
||||
*podtest.MakePod("foo",
|
||||
podtest.SetStatus(core.PodStatus{
|
||||
QOSClass: core.PodQOSBurstable,
|
||||
}),
|
||||
),
|
||||
*podtest.MakePod("foo",
|
||||
podtest.SetStatus(core.PodStatus{
|
||||
QOSClass: core.PodQOSBurstable,
|
||||
}),
|
||||
),
|
||||
"",
|
||||
"qosClass no change",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user