Merge pull request #36241 from kargakis/validate-pds-against-mrs

Automatic merge from submit-queue

extensions: invalidate progress deadline less than minreadyseconds

@kubernetes/deployment ptal
This commit is contained in:
Kubernetes Submit Queue 2016-11-09 04:28:11 -08:00 committed by GitHub
commit 052b31a989
2 changed files with 10 additions and 0 deletions

View File

@ -264,6 +264,9 @@ func ValidateDeploymentSpec(spec *extensions.DeploymentSpec, fldPath *field.Path
}
if spec.ProgressDeadlineSeconds != nil {
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(*spec.ProgressDeadlineSeconds), fldPath.Child("progressDeadlineSeconds"))...)
if *spec.ProgressDeadlineSeconds <= spec.MinReadySeconds {
allErrs = append(allErrs, field.Invalid(fldPath.Child("progressDeadlineSeconds"), spec.ProgressDeadlineSeconds, "must be greater than minReadySeconds."))
}
}
return allErrs
}

View File

@ -666,6 +666,13 @@ func TestValidateDeployment(t *testing.T) {
invalidRollbackRevisionDeployment.Spec.RollbackTo.Revision = -3
errorCases["must be greater than or equal to 0"] = invalidRollbackRevisionDeployment
// ProgressDeadlineSeconds should be greater than MinReadySeconds
invalidProgressDeadlineDeployment := validDeployment()
seconds := int32(600)
invalidProgressDeadlineDeployment.Spec.ProgressDeadlineSeconds = &seconds
invalidProgressDeadlineDeployment.Spec.MinReadySeconds = seconds
errorCases["must be greater than minReadySeconds"] = invalidProgressDeadlineDeployment
for k, v := range errorCases {
errs := ValidateDeployment(v)
if len(errs) == 0 {