-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
Unify initializer name validation #51283
Unify initializer name validation #51283
Conversation
/release-note-none |
f43635b
to
3230d7f
Compare
3230d7f
to
538e4fb
Compare
83c66c5
to
05a3241
Compare
/retest |
for _, msg := range validation.IsQualifiedName(initializer.Name) { | ||
allErrs = append(allErrs, field.Invalid(fldPath.Child("pending").Index(i), initializer.Name, msg)) | ||
} | ||
allErrs = append(allErrs, ValidateInitializerName(fldPath.Child("pending").Index(i).Child("name"), initializer.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.
Was it possible for me to submit an object that contained a pending initializer before (not rely on admission to set it)? If so, an action-required release note is probably in order, since tightening validation may accidentally block deletion (finalizers), right?
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 is an alpha feature, but yes, worth at least reminding people that alpha features can wedge your cluster.
func ValidateInitializerName(fldPath *field.Path, name string) field.ErrorList { | ||
var allErrors field.ErrorList | ||
if len(name) == 0 { | ||
allErrors = append(allErrors, field.Required(fldPath, "")) |
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.
early return here?
if errs := validationutil.IsDNS1123Subdomain(name); len(errs) > 0 { | ||
allErrors = append(allErrors, field.Invalid(fldPath, name, strings.Join(errs, ","))) | ||
} | ||
if len(strings.Split(name, ".")) < 3 { |
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.
two dots
is hard to translate - I think most people would expect to see three or more segments
or parts
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.
changed to "should be a domain with at least three segments separated by dots"
allErrors = append(allErrors, field.Required(fldPath, "")) | ||
} | ||
if errs := validationutil.IsDNS1123Subdomain(name); len(errs) > 0 { | ||
allErrors = append(allErrors, field.Invalid(fldPath, name, strings.Join(errs, ","))) |
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.
early return?
Ack on all the comments. Will address them tmr. |
05a3241
to
cf0f87f
Compare
Addressed the comments. Added release-note-action-required. PTAL. |
cf0f87f
to
cd6c7c5
Compare
@@ -67,6 +69,21 @@ func IsQualifiedName(value string) []string { | |||
return errs | |||
} | |||
|
|||
// IsFullyQualifiedName checks if the name is fully qualified. | |||
func IsFullyQualifiedName(fldPath *field.Path, name string) field.ErrorList { |
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.
I renamed the function as it's used by the admission webhook validation as well.
cd6c7c5
to
7f55383
Compare
/test pull-kubernetes-e2e-gce-gpu |
e54ef61
to
85ee09e
Compare
/retest |
/lgtm |
/approve |
/retest |
Created and linked to an issue. Manually added the "approved" label given by Clayton. |
/approve no-issue
Just in case
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: caesarxuchao, deads2k, smarterclayton Associated issue: 51843 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/retest |
/retest Review the full test history for this PR. |
1 similar comment
/retest Review the full test history for this PR. |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue (batch tested with PRs 51583, 51283, 51374, 51690, 51716) |
@caesarxuchao: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Unify the validation rules on initializer names. Fix #51843.