@@ -1180,11 +1180,11 @@ func validateContainerResourceDivisor(rName string, divisor resource.Quantity, f
1180
1180
switch rName {
1181
1181
case "limits.cpu" , "requests.cpu" :
1182
1182
if ! validContainerResourceDivisorForCPU .Has (divisor .String ()) {
1183
- allErrs = append (allErrs , field .Invalid (fldPath .Child ("divisor" ), rName , fmt . Sprintf ( "only divisor's values 1m and 1 are supported with the cpu resource" ) ))
1183
+ allErrs = append (allErrs , field .Invalid (fldPath .Child ("divisor" ), rName , "only divisor's values 1m and 1 are supported with the cpu resource" ))
1184
1184
}
1185
1185
case "limits.memory" , "requests.memory" :
1186
1186
if ! validContainerResourceDivisorForMemory .Has (divisor .String ()) {
1187
- allErrs = append (allErrs , field .Invalid (fldPath .Child ("divisor" ), rName , fmt . Sprintf ( "only divisor's values 1, 1k, 1M, 1G, 1T, 1P, 1E, 1Ki, 1Mi, 1Gi, 1Ti, 1Pi, 1Ei are supported with the memory resource" ) ))
1187
+ allErrs = append (allErrs , field .Invalid (fldPath .Child ("divisor" ), rName , "only divisor's values 1, 1k, 1M, 1G, 1T, 1P, 1E, 1Ki, 1Mi, 1Gi, 1Ti, 1Pi, 1Ei are supported with the memory resource" ))
1188
1188
}
1189
1189
}
1190
1190
return allErrs
@@ -2768,11 +2768,11 @@ func ValidateResourceRequirements(requirements *api.ResourceRequirements, fldPat
2768
2768
// Check that request <= limit.
2769
2769
requestQuantity , exists := requirements .Requests [resourceName ]
2770
2770
if exists {
2771
- // For GPUs, require that no request be set .
2772
- if resourceName == api .ResourceNvidiaGPU {
2773
- allErrs = append (allErrs , field .Invalid (reqPath , requestQuantity .String (), "cannot be set" ))
2771
+ // For GPUs, not only requests can't exceed limits, they also can't be lower, i.e. must be equal .
2772
+ if resourceName == api .ResourceNvidiaGPU && quantity . Cmp ( requestQuantity ) != 0 {
2773
+ allErrs = append (allErrs , field .Invalid (reqPath , requestQuantity .String (), fmt . Sprintf ( "must be equal to %s limit" , api . ResourceNvidiaGPU ) ))
2774
2774
} else if quantity .Cmp (requestQuantity ) < 0 {
2775
- allErrs = append (allErrs , field .Invalid (fldPath , quantity .String (), "must be greater than or equal to request" ))
2775
+ allErrs = append (allErrs , field .Invalid (limPath , quantity .String (), fmt . Sprintf ( "must be greater than or equal to %s request" , resourceName ) ))
2776
2776
}
2777
2777
}
2778
2778
}
@@ -2936,7 +2936,7 @@ func validateFinalizerName(stringValue string, fldPath *field.Path) field.ErrorL
2936
2936
2937
2937
if len (strings .Split (stringValue , "/" )) == 1 {
2938
2938
if ! api .IsStandardFinalizerName (stringValue ) {
2939
- return append (allErrs , field .Invalid (fldPath , stringValue , fmt . Sprintf ( "name is neither a standard finalizer name nor is it fully qualified" ) ))
2939
+ return append (allErrs , field .Invalid (fldPath , stringValue , "name is neither a standard finalizer name nor is it fully qualified" ))
2940
2940
}
2941
2941
}
2942
2942
0 commit comments