-
Notifications
You must be signed in to change notification settings - Fork 4.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
UPSTREAM: 52917: add --selector support to drain,cordon #16445
UPSTREAM: 52917: add --selector support to drain,cordon #16445
Conversation
234ac34
to
6d9241a
Compare
Do() | ||
SelectorParam(o.Selector) | ||
|
||
if len(args) > 0 { |
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.
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) |
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.
Do you think we need that message? I haven't seen this being error-ed out anywhere else when applying label selector.
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.
Thanks, will remove
6d9241a
to
445618c
Compare
@soltysh thanks for the review, will open upstream PR |
fb85bc7
to
1e6231d
Compare
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.
One more comment.
var err error | ||
if len(args) != 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.
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:
- check args == 0 -> error out
- check if args and selector is passed -> error out
test/cmd/admin.sh
Outdated
@@ -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' |
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 also add the other failure, when no parameters are passed?
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. |
1e6231d
to
ccac83e
Compare
ccac83e
to
b3a05ef
Compare
/test cmd |
1 similar comment
/test cmd |
Still waiting for upstream approval. |
@soltysh thanks, upstream PR has merged |
hold upstreams for rebase |
1 similar comment
hold upstreams for rebase |
r := o.Factory.NewBuilder(true). | ||
NamespaceParam(cmdNamespace).DefaultNamespace(). | ||
ResourceNames("node", args[0]). | ||
SelectorParam(o.Selector). |
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.
shoudn't this be ResourceNames("nodes", args...)
?
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.
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
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.
link to the upstream PR that resolved this? also, did 52917 go into 1.8?
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.
Upstream patch: kubernetes/kubernetes#54083
52917 is not in 1.8: https://github.com/kubernetes/kubernetes/blob/release-1.8/pkg/kubectl/cmd/drain.go
b3a05ef
to
25351c1
Compare
[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 |
/test extended_conformance_gce |
/retest Please review the full test history for this PR and help us cut down flakes. |
/test extended_conformance_install |
/test extended_conformance_install_update |
/retest Please review the full test history for this PR and help us cut down flakes. |
1 similar comment
/retest Please review the full test history for this PR and help us cut down flakes. |
/test extended_conformance_install_update |
/retest Please review the full test history for this PR and help us cut down flakes. |
2 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/test extended_conformance_install_update |
68c59ce
to
16fd41a
Compare
/lgtm cancel //PR changed after LGTM, removing LGTM. @fabianofranz @juanvallejo @liggitt @soltysh |
16fd41a
to
0192ecc
Compare
0192ecc
to
4dfcc84
Compare
ebec124
to
5c02473
Compare
@juanvallejo: The following tests 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. |
@juanvallejo PR needs rebase |
Closing as the current rebase will be introducing these commits to origin |
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 tooc adm drain,cordon,uncordon
, performingeach 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
cc @openshift/cli-review @soltysh