Skip to content

Commit d2b9aa2

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request kubernetes#54919 from tianshapjq/validate-limit-range
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. validation to GPU and hugepages in creating LimitRange **What this PR does / why we need it**: validate if default and defaultRequest match when creating LimitRange for GPU and hugepages. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes kubernetes#54917 **Special notes for your reviewer**: **Release note**: ```release-note validate if default and defaultRequest match when creating LimitRange for GPU and hugepages. ```
2 parents ce910f2 + 005485b commit d2b9aa2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pkg/api/validation/validation.go

+5
Original file line numberDiff line numberDiff line change
@@ -3859,6 +3859,11 @@ func ValidateLimitRange(limitRange *api.LimitRange) field.ErrorList {
38593859
allErrs = append(allErrs, field.Invalid(idxPath.Child("maxLimitRequestRatio").Key(string(k)), maxRatio, fmt.Sprintf("ratio %s is greater than max/min = %f", maxRatio.String(), maxRatioLimit)))
38603860
}
38613861
}
3862+
3863+
// for GPU and hugepages, the default value and defaultRequest value must match if both are specified
3864+
if !helper.IsOvercommitAllowed(api.ResourceName(k)) && defaultQuantityFound && defaultRequestQuantityFound && defaultQuantity.Cmp(defaultRequestQuantity) != 0 {
3865+
allErrs = append(allErrs, field.Invalid(idxPath.Child("defaultRequest").Key(string(k)), defaultRequestQuantity, fmt.Sprintf("default value %s must equal to defaultRequest value %s in %s", defaultQuantity.String(), defaultRequestQuantity.String(), k)))
3866+
}
38623867
}
38633868
}
38643869

0 commit comments

Comments
 (0)