mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-17 15:50:10 +00:00
Allow non-patch-updates to replicas
This commit is contained in:
parent
332edf8bb3
commit
4601ac7643
@ -99,22 +99,20 @@ func ValidatePetSet(petSet *apps.PetSet) field.ErrorList {
|
||||
|
||||
// ValidatePetSetUpdate tests if required fields in the PetSet are set.
|
||||
func ValidatePetSetUpdate(petSet, oldPetSet *apps.PetSet) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
allErrs := apivalidation.ValidateObjectMetaUpdate(&petSet.ObjectMeta, &oldPetSet.ObjectMeta, field.NewPath("metadata"))
|
||||
|
||||
// TODO: For now we're taking the safe route and disallowing all updates to spec except for Spec.Replicas.
|
||||
// Enable on a case by case basis.
|
||||
restoreReplicas := petSet.Spec.Replicas
|
||||
petSet.Spec.Replicas = oldPetSet.Spec.Replicas
|
||||
|
||||
// The generation changes for this update
|
||||
restoreGeneration := petSet.Generation
|
||||
petSet.Generation = oldPetSet.Generation
|
||||
|
||||
if !reflect.DeepEqual(petSet, oldPetSet) {
|
||||
if !reflect.DeepEqual(petSet.Spec, oldPetSet.Spec) {
|
||||
allErrs = append(allErrs, field.Forbidden(field.NewPath("spec"), "updates to petset spec for fields other than 'replicas' are forbidden."))
|
||||
}
|
||||
if !reflect.DeepEqual(petSet.Status, oldPetSet.Status) {
|
||||
allErrs = append(allErrs, field.Forbidden(field.NewPath("status"), "updates to petset status forbidden."))
|
||||
}
|
||||
petSet.Spec.Replicas = restoreReplicas
|
||||
petSet.Generation = restoreGeneration
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(petSet.Spec.Replicas), field.NewPath("spec", "replicas"))...)
|
||||
return allErrs
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user