-
Notifications
You must be signed in to change notification settings - Fork 38.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix validation of resources (cpu, memory, storage) for limit range types. #22766
Fix validation of resources (cpu, memory, storage) for limit range types. #22766
Conversation
@kubernetes/rh-cluster-infra @derekwaynecarr |
Labelling this PR as size/M |
GCE e2e build/test passed for commit a46c5c8. |
The author of this PR is not in the whitelist for merge, can one of the admins add the 'ok-to-merge' label? |
@@ -2044,6 +2055,9 @@ func ValidateLimitRange(limitRange *api.LimitRange) field.ErrorList { | |||
for i := range limitRange.Spec.Limits { | |||
idxPath := fldPath.Index(i) | |||
limit := &limitRange.Spec.Limits[i] | |||
if !validation.IsQualifiedName(string(limit.Type)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this to a separate function and have it check for standard limit types and then require that things that are not standard limit types are qualified (i.e. they have a / ) similar to validateResourceName?
One request then this is LGTM, thanks @aveshagarwal ! |
a46c5c8
to
4277743
Compare
@derekwaynecarr Updated this PR with validation of standard limit types and non standard limit types (should be fully qualified) and also added a test case. PTAL. |
return append(allErrs, field.Invalid(fldPath, value, qualifiedNameErrorMsg)) | ||
} | ||
|
||
if len(strings.Split(value, "/")) == 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use strings.Contains?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or do you really want exactly 1 slash?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that in the function IsQualifiedName and also as per this document:
https://github.com/kubernetes/kubernetes/blob/master/docs/design/resources.md
only one slash is expected to be a qualified name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With more than one slash, IsQualifiedName fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i am biased to stay consistent, so this lgtm.
Labelling this PR as size/L |
GCE e2e build/test passed for commit 4277743. |
LGTM |
I am marking this as a cherry-pick-candidate for release 1.2. Downstream in OpenShift, we are storing constraints for other resources in our server on the shared limit range in the namespace. For example, we will let you constraint the size of an |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
GCE e2e build/test passed for commit 4277743. |
Automatic merge from submit-queue |
…tion-fix Auto commit by PR queue bot
…ges-validation-fix Auto commit by PR queue bot
…ges-validation-fix Auto commit by PR queue bot
…ges-validation-fix Auto commit by PR queue bot
No description provided.