mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Merge pull request #20956 from derekwaynecarr/cleanup_validation
Auto commit by PR queue bot
This commit is contained in:
commit
c48e94df89
@ -2233,15 +2233,7 @@ func ValidateResourceRequirements(requirements *api.ResourceRequirements, fldPat
|
|||||||
// Check that request <= limit.
|
// Check that request <= limit.
|
||||||
requestQuantity, exists := requirements.Requests[resourceName]
|
requestQuantity, exists := requirements.Requests[resourceName]
|
||||||
if exists {
|
if exists {
|
||||||
var requestValue, limitValue int64
|
if quantity.Cmp(requestQuantity) < 0 {
|
||||||
requestValue = requestQuantity.Value()
|
|
||||||
limitValue = quantity.Value()
|
|
||||||
// Do a more precise comparison if possible (if the value won't overflow).
|
|
||||||
if requestValue <= resource.MaxMilliValue && limitValue <= resource.MaxMilliValue {
|
|
||||||
requestValue = requestQuantity.MilliValue()
|
|
||||||
limitValue = quantity.MilliValue()
|
|
||||||
}
|
|
||||||
if limitValue < requestValue {
|
|
||||||
allErrs = append(allErrs, field.Invalid(fldPath, quantity.String(), "must be greater than or equal to request"))
|
allErrs = append(allErrs, field.Invalid(fldPath, quantity.String(), "must be greater than or equal to request"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user