From cc2137fcccab1ddfc3ec1d77f9c7a7ab2a26b410 Mon Sep 17 00:00:00 2001 From: derekwaynecarr Date: Tue, 9 Feb 2016 21:42:12 -0500 Subject: [PATCH] Fixup validation for containers requests or limits to use quantity comparison --- pkg/api/validation/validation.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/pkg/api/validation/validation.go b/pkg/api/validation/validation.go index ff38e7fa09c..b76bb4fad0d 100644 --- a/pkg/api/validation/validation.go +++ b/pkg/api/validation/validation.go @@ -2211,15 +2211,7 @@ func ValidateResourceRequirements(requirements *api.ResourceRequirements, fldPat // Check that request <= limit. requestQuantity, exists := requirements.Requests[resourceName] if exists { - var requestValue, limitValue int64 - 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 { + if quantity.Cmp(requestQuantity) < 0 { allErrs = append(allErrs, field.Invalid(fldPath, quantity.String(), "must be greater than or equal to request")) } }