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

UPSTREAM: 52917: add --selector support to drain,cordon #16445

Conversation

juanvallejo
Copy link
Contributor

@juanvallejo juanvallejo commented Sep 19, 2017

Related Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1466390
Related Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1466382

Adds --selector option to oc adm drain,cordon,uncordon, performing
each action on a list of nodes matching the given label.

If at least one node fails to be cordoned/uncordoned, the command will
continue to operate on any remaining nodes, uninterrupted, reporting
any errors it encounters along the way.

If at least one node fails to be drained, the command will halt, printing
the immediate error encountered, and a list of nodes yet to be drained
(including the node that just failed to be drained).

Work in progress.
TODO

  • add tests

cc @openshift/cli-review @soltysh

@openshift-ci-robot openshift-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 19, 2017
@juanvallejo juanvallejo force-pushed the jvallejo/add-support-multiple-node-selection branch 5 times, most recently from 234ac34 to 6d9241a Compare September 20, 2017 16:13
Do()
SelectorParam(o.Selector)

if len(args) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Move that if before you create the builder and you can then squash the whole builder invocation into one.

return err
}
if len(infos) == 0 {
return fmt.Errorf("error: no nodes matched selector %q", o.Selector)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think we need that message? I haven't seen this being error-ed out anywhere else when applying label selector.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, will remove

@juanvallejo juanvallejo force-pushed the jvallejo/add-support-multiple-node-selection branch from 6d9241a to 445618c Compare September 21, 2017 14:35
@juanvallejo
Copy link
Contributor Author

@soltysh thanks for the review, will open upstream PR

@juanvallejo juanvallejo force-pushed the jvallejo/add-support-multiple-node-selection branch from fb85bc7 to 1e6231d Compare September 21, 2017 19:04
Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

One more comment.

var err error
if len(args) != 1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

With this new if you're swallowing the case where nothing was passed and you should return error. I think the best option would be to:

  1. check args == 0 -> error out
  2. check if args and selector is passed -> error out

@@ -84,6 +85,18 @@ echo "manage-node: ok"
os::test::junit::declare_suite_end

os::test::junit::declare_suite_start "cmd/admin/certs"
# check node-management cmds: drain,cordon,uncordon
# ensure drain fails when both a nodeName and --selector are given
os::cmd::expect_failure_and_text 'oc adm drain fake-node --selector fake=label' 'cannot specify both a node name and a \-\-selector option'
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you also add the other failure, when no parameters are passed?

@soltysh
Copy link
Contributor

soltysh commented Sep 22, 2017

I'm tagging this as do-not-merge, until an actual upstream commit is present. I don't want to end up with this being merged before upstream will be created and approved.

@juanvallejo juanvallejo force-pushed the jvallejo/add-support-multiple-node-selection branch from 1e6231d to ccac83e Compare September 22, 2017 16:05
@juanvallejo juanvallejo changed the title UPSTREAM: 0000: add --selector support to drain,cordon UPSTREAM: 52917: add --selector support to drain,cordon Sep 22, 2017
@juanvallejo juanvallejo force-pushed the jvallejo/add-support-multiple-node-selection branch from ccac83e to b3a05ef Compare September 22, 2017 18:25
@juanvallejo
Copy link
Contributor Author

/test cmd

1 similar comment
@juanvallejo
Copy link
Contributor Author

/test cmd

@soltysh
Copy link
Contributor

soltysh commented Sep 28, 2017

Still waiting for upstream approval.

@juanvallejo
Copy link
Contributor Author

@soltysh thanks, upstream PR has merged

@liggitt
Copy link
Contributor

liggitt commented Oct 5, 2017

hold upstreams for rebase

1 similar comment
@liggitt
Copy link
Contributor

liggitt commented Oct 5, 2017

hold upstreams for rebase

@liggitt liggitt added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 5, 2017
@juanvallejo
Copy link
Contributor Author

@liggitt @soltysh is this good to go?

r := o.Factory.NewBuilder(true).
NamespaceParam(cmdNamespace).DefaultNamespace().
ResourceNames("node", args[0]).
SelectorParam(o.Selector).
Copy link
Contributor

Choose a reason for hiding this comment

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

shoudn't this be ResourceNames("nodes", args...)?

Copy link
Contributor

Choose a reason for hiding this comment

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

the nameArgs := []string{"nodes"} and if strings.Contains(args[0], "/") block above means this command parses resource args differently than other commands...

I'd expect ResourceNames("nodes", args...).SingleResourceType() and a check on the resource type of selected resources to make sure they are nodes

Copy link
Contributor

Choose a reason for hiding this comment

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

link to the upstream PR that resolved this? also, did 52917 go into 1.8?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@juanvallejo juanvallejo force-pushed the jvallejo/add-support-multiple-node-selection branch from b3a05ef to 25351c1 Compare October 12, 2017 19:31
@openshift-merge-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: juanvallejo, liggitt, soltysh

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

@openshift-merge-robot openshift-merge-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 21, 2017
@juanvallejo
Copy link
Contributor Author

/test extended_conformance_gce

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@juanvallejo
Copy link
Contributor Author

/test extended_conformance_install
/test extended_conformance_install_update

@juanvallejo
Copy link
Contributor Author

/test extended_conformance_install_update

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@juanvallejo
Copy link
Contributor Author

/test extended_conformance_install_update

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

2 similar comments
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@juanvallejo
Copy link
Contributor Author

/test extended_conformance_install_update

@juanvallejo juanvallejo force-pushed the jvallejo/add-support-multiple-node-selection branch from 68c59ce to 16fd41a Compare November 16, 2017 15:47
@openshift-merge-robot
Copy link
Contributor

/lgtm cancel //PR changed after LGTM, removing LGTM. @fabianofranz @juanvallejo @liggitt @soltysh

@openshift-merge-robot openshift-merge-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed lgtm Indicates that a PR is ready to be merged. labels Nov 16, 2017
@juanvallejo juanvallejo force-pushed the jvallejo/add-support-multiple-node-selection branch from 16fd41a to 0192ecc Compare November 20, 2017 18:33
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 20, 2017
@juanvallejo juanvallejo force-pushed the jvallejo/add-support-multiple-node-selection branch from 0192ecc to 4dfcc84 Compare November 20, 2017 18:34
@juanvallejo juanvallejo force-pushed the jvallejo/add-support-multiple-node-selection branch from ebec124 to 5c02473 Compare November 20, 2017 20:26
@openshift-ci-robot
Copy link

@juanvallejo: The following tests failed, say /retest to rerun them all:

Test name Commit Details Rerun command
ci/openshift-jenkins/extended_conformance_install_update 68c59ce link /test extended_conformance_install_update
ci/openshift-jenkins/cmd 5c02473 link /test cmd
ci/openshift-jenkins/extended_conformance_gce 5c02473 link /test extended_conformance_gce

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.

@openshift-merge-robot
Copy link
Contributor

@juanvallejo PR needs rebase

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 20, 2017
@juanvallejo
Copy link
Contributor Author

Closing as the current rebase will be introducing these commits to origin

@juanvallejo juanvallejo closed this Dec 6, 2017
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. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. vendor-update Touching vendor dir or related files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants