Merge pull request #11317 from johngmyers/warmpool-negative

Disallow negative warmpool sizes
This commit is contained in:
Kubernetes Prow Robot 2021-04-24 22:35:00 -07:00 committed by GitHub
commit 29f8da1156
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -155,11 +155,16 @@ func ValidateInstanceGroup(g *kops.InstanceGroup, cloud fi.Cloud) field.ErrorLis
allErrs = append(allErrs, field.Forbidden(field.NewPath("spec", "warmPool"), "warm pool cannot be used with spot instances"))
}
if warmPool.MaxSize != nil {
if warmPool.MinSize > *warmPool.MaxSize {
if *warmPool.MaxSize < 0 {
allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "warmPool", "maxSize"), *warmPool.MaxSize, "warm pool maxSize cannot be negative"))
} else if warmPool.MinSize > *warmPool.MaxSize {
allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "warmPool", "maxSize"), fi.Int64Value(warmPool.MaxSize), "warm pool maxSize cannot be set to lower than minSize"))
}
}
if warmPool.MinSize < 0 {
allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "warmPool", "minSize"), warmPool.MinSize, "warm pool minSize cannot be negative"))
}
}
return allErrs
}