diff --git a/pkg/util/resource.go b/pkg/util/resource.go index c3c2f4ac2..f2886a9a3 100644 --- a/pkg/util/resource.go +++ b/pkg/util/resource.go @@ -266,7 +266,7 @@ func LessThanOrEqualCompletely(a corev1.ResourceList, b corev1.ResourceList) boo result := true delta := quotav1.Subtract(a, b) for _, value := range delta { - if value.Value() > 0 { + if value.CmpInt64(0) > 0 { result = false break } diff --git a/pkg/util/resource_test.go b/pkg/util/resource_test.go index 5c358c02b..51a657460 100644 --- a/pkg/util/resource_test.go +++ b/pkg/util/resource_test.go @@ -1099,6 +1099,16 @@ func TestLessThanOrEqualEnhanced(t *testing.T) { }, expect: true, }, + { + name: "a < b, special case: deltaValue.Value() may overflow", + a: corev1.ResourceList{ + corev1.ResourceMemory: resource.MustParse("1000Gi"), + }, + b: corev1.ResourceList{ + corev1.ResourceMemory: resource.MustParse("39999996Gi"), + }, + expect: true, + }, { name: "a > b", a: corev1.ResourceList{