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

Update v1.Taint parser to accept the form key:effect and key=:effect- #74159

Merged

Conversation

dlipovetsky
Copy link
Contributor

@dlipovetsky dlipovetsky commented Feb 16, 2019

/kind bug

What this PR does / why we need it:
Updates v1.Taint parser to accept the form key:effect, which is the string representation of a v1.Taint that has a nil Value (the empty string).

Also updates the parser to accept the form key=:effect-, since key=:effect is a valid string representation of a v1.Taint with a nil Value.

Which issue(s) this PR fixes:
Fixes #73249

Does this PR introduce a user-facing change?:

Support parsing more v1.Taint forms. `key:effect`, `key=:effect-` are now accepted.

/cc @liggitt

@k8s-ci-robot k8s-ci-robot added the release-note-none Denotes a PR that doesn't merit a release note. label Feb 16, 2019
@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Feb 16, 2019
@dlipovetsky
Copy link
Contributor Author

/sig scheduling

@k8s-ci-robot k8s-ci-robot added sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Feb 16, 2019
@dlipovetsky
Copy link
Contributor Author

/cc @kubernetes/sig-scheduling-bugs
/cc @k82cn
/cc @ravisantoshgudimetla

Copy link
Member

@neolit123 neolit123 left a comment

Choose a reason for hiding this comment

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

thanks @dlipovetsky
/priority important-longterm

could you please add a user facing release note instead of NONE? e.g.

Support parsing v1.Taint forms such as xx, yy

@k8s-ci-robot k8s-ci-robot added priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Feb 16, 2019
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Feb 16, 2019
@dlipovetsky
Copy link
Contributor Author

Thanks @neolit123! Added release note.

@dlipovetsky
Copy link
Contributor Author

I added two new invalid spec tests and fixed a bug in the updated parser. (I also verified that the original parser passed these new tests)

@dlipovetsky
Copy link
Contributor Author

Once the changes to pkg/util/taints/ are finalized, I'll make corresponding changes to pkg/kubectl/cmd/taint/.

Copy link
Member

@Huang-Wei Huang-Wei left a comment

Choose a reason for hiding this comment

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

LGTM for the pkg/util/taints/ part.

@kevin-wangzefeng
Copy link
Member

LGTM for pkg/util/taints/, I think you can go ahead for the rest parts.

@dlipovetsky
Copy link
Contributor Author

Thanks @kevin-wangzefeng and @Huang-Wei.

After I updated parseTaints and parseTaint in pkg/kubectl/cmd/taint/util.go, an existing test in pkg/kubectl/cmd/taint/taint_test.go failed:

--- FAIL: TestTaint (0.03s)
    --- FAIL: TestTaint/node_has_two_taints_with_the_same_key_but_different_effect,_remove_all_of_them_with_wildcard (0.00s)
        taint_test.go:313: Recovered: error: invalid taint spec: dedicated
            See 'taint -h' for help and examples
        taint_test.go:332: node has two taints with the same key but different effect, remove all of them with wildcard: node not tainted

I did not realize that kubectl taint accepts a key with no value or effect to remove a taint; the example in the kubectl usage is:

  # Remove from node 'foo' all the taints with key 'dedicated'
  kubectl taint nodes foo dedicated-

This use case was introduced in #30590. To be backward compatible, this PR should not break this use case.

There was no test in pkg/util/taints for removing a taint using the key- form. The parser prior to this PR accepts this form, but the parser in this PR rejects this form. My plan is to:

  1. Add a test to pkg/util/taints for removing a taint using the key- form
  2. Update the parser in this PR to accept the key- form

@dlipovetsky
Copy link
Contributor Author

The last commit passes the tests in pkg/util/taints and pkg/kubectl/cmd/taint/.

I have changed parseTaint to accept the key form, and ensured in ParseTaints that a taint with no effect cannot be added. The alternative is for parseTaint to continue rejecting this form, and handling the form as a special case in ParseTaints. I prefer the former, because the code already passes around taints without values or effects, which implies that the key form is valid, although it must not be used to create a taint.

@kevin-wangzefeng
Copy link
Member

I'm fine with it. Empty/null value and effect should not block parsing, though taints with only keys indicated should not be used for creating.

@bsalamat
Copy link
Member

bsalamat commented Mar 7, 2019

I reviewed and it looks fine. I have only a few minor comments. If @dlipovetsky addresses them sooner, we can get it merged.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 11, 2019
@dlipovetsky
Copy link
Contributor Author

@bsalamat Thanks a lot for your review. My apologies for taking a while to address your comments. I address them using separate commits for the code in pkg/util/taints and pkg/kubectl/cmd/taint, so that I can easily fixup the original commits for those packages before merging.

@dlipovetsky
Copy link
Contributor Author

I also added a test to verify that the empty string is an invalid Taint spec.

@dlipovetsky
Copy link
Contributor Author

Test failed due to known flake, see #74931

/retest

@bsalamat
Copy link
Member

Thanks, @dlipovetsky! Looks good. Could you please squash commits?

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 11, 2019
@bsalamat
Copy link
Member

I updated the release note. Please check it.

Daniel Lipovetsky added 3 commits March 11, 2019 14:20
… and `key-` forms

Also add missing tests for `key=:value` form.
- Explain that the value is optional.
- Add example of adding a taint with no value to kubectl taint usage.
@dlipovetsky dlipovetsky force-pushed the issue-73249-revise-parsetaint branch from 3402228 to ab6d901 Compare March 11, 2019 21:24
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 11, 2019
@dlipovetsky
Copy link
Contributor Author

@bsalamat Squashed.

As for the release note, I'm not sure it needs to mention the key- form, since that has always been accepted--this PR just changes where its parsed internally (please see #74159 (comment)).

@bsalamat
Copy link
Member

@dlipovetsky Thanks again. I fixed the release notes.

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 11, 2019
@bsalamat
Copy link
Member

@liggitt Back to you for approval.

@dlipovetsky
Copy link
Contributor Author

/assign @liggitt

(So that this PR shows up in your dashboard 😄)

@liggitt
Copy link
Member

liggitt commented Mar 29, 2019

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bsalamat, dlipovetsky, liggitt

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 29, 2019
@dlipovetsky
Copy link
Contributor Author

@ravisantoshgudimetla Please cancel the hold. Thanks!

@ravisantoshgudimetla
Copy link
Contributor

/hold cancel

Done @dlipovetsky. Thanks for working on this PR.

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 1, 2019
@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.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

2 similar comments
@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.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@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.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@k8s-ci-robot k8s-ci-robot merged commit 7d15d41 into kubernetes:master Apr 2, 2019
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. area/kubectl cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. 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.

Taint-to-string method generates string that taint parser considers invalid
10 participants