Skip to content
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

Merged

Conversation

caesarxuchao
Copy link
Member

@caesarxuchao caesarxuchao commented Aug 24, 2017

Unify the validation rules on initializer names. Fix #51843.

Action required: validation rule on metadata.initializers.pending[x].name is tightened. The initializer name needs to contain at least three segments separated by dots. If you create objects with pending initializers, (i.e., not relying on apiserver adding pending initializers according to initializerconfiguration), you need to update the initializer name in existing objects and in configuration files to comply to the new validation rule.

@caesarxuchao caesarxuchao self-assigned this Aug 24, 2017
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 24, 2017
@caesarxuchao
Copy link
Member Author

/release-note-none
/sig api-machinery

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. labels Aug 24, 2017
@k8s-github-robot k8s-github-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 24, 2017
@caesarxuchao caesarxuchao force-pushed the fix-initializer-validate branch from f43635b to 3230d7f Compare August 24, 2017 19:52
@k8s-github-robot k8s-github-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 24, 2017
@caesarxuchao caesarxuchao changed the title [WIP] Unify initializer name validation Unify initializer name validation Aug 24, 2017
@caesarxuchao caesarxuchao force-pushed the fix-initializer-validate branch from 3230d7f to 538e4fb Compare August 24, 2017 19:53
@k8s-github-robot k8s-github-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 24, 2017
@caesarxuchao caesarxuchao force-pushed the fix-initializer-validate branch 2 times, most recently from 83c66c5 to 05a3241 Compare August 24, 2017 21:43
@caesarxuchao
Copy link
Member Author

/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)...)
Copy link
Contributor

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?

Copy link
Contributor

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, ""))
Copy link
Contributor

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 {
Copy link
Contributor

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

Copy link
Member Author

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, ",")))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

early return?

@caesarxuchao
Copy link
Member Author

Ack on all the comments. Will address them tmr.

@caesarxuchao caesarxuchao added release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Aug 25, 2017
@caesarxuchao caesarxuchao force-pushed the fix-initializer-validate branch from 05a3241 to cf0f87f Compare August 25, 2017 18:44
@caesarxuchao
Copy link
Member Author

Addressed the comments. Added release-note-action-required. PTAL.

@caesarxuchao caesarxuchao force-pushed the fix-initializer-validate branch from cf0f87f to cd6c7c5 Compare August 25, 2017 20:39
@@ -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 {
Copy link
Member Author

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.

@caesarxuchao caesarxuchao force-pushed the fix-initializer-validate branch from cd6c7c5 to 7f55383 Compare August 25, 2017 20:48
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 28, 2017
@BenTheElder
Copy link
Member

/test pull-kubernetes-e2e-gce-gpu
(this is a CI issue, working on it!)

@caesarxuchao caesarxuchao force-pushed the fix-initializer-validate branch from e54ef61 to 85ee09e Compare August 28, 2017 23:18
@caesarxuchao
Copy link
Member Author

/retest

@deads2k
Copy link
Contributor

deads2k commented Aug 30, 2017

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 30, 2017
@smarterclayton
Copy link
Contributor

/approve

@caesarxuchao
Copy link
Member Author

/retest

@caesarxuchao caesarxuchao added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 2, 2017
@caesarxuchao
Copy link
Member Author

Created and linked to an issue. Manually added the "approved" label given by Clayton.

@smarterclayton
Copy link
Contributor

smarterclayton commented Sep 2, 2017 via email

@k8s-github-robot
Copy link

[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 /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@abgworrall abgworrall modified the milestone: v1.8 Sep 2, 2017
@caesarxuchao
Copy link
Member Author

/retest

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to @fejta).

Review the full test history for this PR.

1 similar comment
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to @fejta).

Review the full test history for this PR.

@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 51583, 51283, 51374, 51690, 51716)

@k8s-github-robot k8s-github-robot merged commit 12f96e2 into kubernetes:master Sep 3, 2017
@k8s-ci-robot
Copy link
Contributor

@caesarxuchao: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-kubernetes-e2e-kops-aws 85ee09e link /test pull-kubernetes-e2e-kops-aws

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants