mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-18 08:09:58 +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.
|
// ValidatePetSetUpdate tests if required fields in the PetSet are set.
|
||||||
func ValidatePetSetUpdate(petSet, oldPetSet *apps.PetSet) field.ErrorList {
|
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.
|
// 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.
|
// Enable on a case by case basis.
|
||||||
restoreReplicas := petSet.Spec.Replicas
|
restoreReplicas := petSet.Spec.Replicas
|
||||||
petSet.Spec.Replicas = oldPetSet.Spec.Replicas
|
petSet.Spec.Replicas = oldPetSet.Spec.Replicas
|
||||||
|
|
||||||
// The generation changes for this update
|
if !reflect.DeepEqual(petSet.Spec, oldPetSet.Spec) {
|
||||||
restoreGeneration := petSet.Generation
|
|
||||||
petSet.Generation = oldPetSet.Generation
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(petSet, oldPetSet) {
|
|
||||||
allErrs = append(allErrs, field.Forbidden(field.NewPath("spec"), "updates to petset spec for fields other than 'replicas' are forbidden."))
|
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.Spec.Replicas = restoreReplicas
|
||||||
petSet.Generation = restoreGeneration
|
|
||||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(petSet.Spec.Replicas), field.NewPath("spec", "replicas"))...)
|
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(petSet.Spec.Replicas), field.NewPath("spec", "replicas"))...)
|
||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user