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

feat(cli): add selector and field-selector option to the stop command. #4853

Merged
merged 5 commits into from Jan 17, 2021

Conversation

noahingh
Copy link
Contributor

Checklist:

I add the selector and field-selector option to the stop command, it can stop workflows that are matched by labels and field. it is related to #3962.

@@ -784,6 +784,54 @@ func (s *CLISuite) TestWorkflowRetry() {
})
}

func (s *CLISuite) TestWorkflowStop() {
Copy link
Contributor

Choose a reason for hiding this comment

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

this is the first time anyone new to the project has submitted complete tests!

cmd/argo/commands/stop.go Show resolved Hide resolved
cmd/argo/commands/stop.go Outdated Show resolved Hide resolved
cmd/argo/commands/stop.go Outdated Show resolved Hide resolved
@@ -33,29 +58,55 @@ func NewStopCommand() *cobra.Command {
argo stop @latest
`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 && !o.isList() {
Copy link
Contributor

Choose a reason for hiding this comment

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

it should be ok to have no args, e.g. if you were to do

kubectl get wf -o name | xargs argo stop

That should be fine, even if kubectl returned zero workflows.

What happens with both list options AND args? Should that be an error?

Is this consistent with argo list and argo delete?

Copy link
Contributor Author

@noahingh noahingh Jan 17, 2021

Choose a reason for hiding this comment

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

When we use the xargs command it works fine, because the xargs command generates and executes lines. Indeed, kubectl get wf -o name | xargs argo stop works, but argo stop returns the help message.

At now it works only with the list option when we use both list options and args, and it is not consistent with argo delete, so I need to fix it. But in my opinion, Argo should block using both because it makes the user confused. In kubectl it returns the error when we use both list options and args like the below.

k get pods -l selector=true foo
error: name cannot be provided when a selector is specified

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've fixed it to be consistent with the delete & list command.

@alexec alexec self-assigned this Jan 11, 2021
Copy link
Contributor

@alexec alexec left a comment

Choose a reason for hiding this comment

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

See comments.

Signed-off-by: hanjunlee <opsdownn@gmail.com>
Signed-off-by: hanjunlee <opsdownn@gmail.com>
Signed-off-by: hanjunlee <opsdownn@gmail.com>
Signed-off-by: hanjunlee <opsdownn@gmail.com>
@noahingh noahingh requested a review from alexec January 17, 2021 11:43
Copy link
Contributor

@alexec alexec left a comment

Choose a reason for hiding this comment

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

LGTM

@alexec alexec merged commit 53f7998 into argoproj:master Jan 17, 2021
@alexec alexec added this to the v3.0 milestone Jan 17, 2021
@alexec
Copy link
Contributor

alexec commented Jan 17, 2021

@hanjunlee this is failing builds on master, so I'm going to use admin privileges to revert this merge. Can you please re-submit the PR?:

Failing build

exit status 1workflow node-suspend stopped
time="2021-01-17T18:21:53.299Z" level=fatal msg="rpc error: code = Unknown desc = currently, set only targets suspend nodes: no suspend nodes matching nodeFieldSelector: inputs.parameters.tag.value=suspend2-tag1"

    --- FAIL: TestCLIWithServerOverGRPCSuite/TestNodeSuspendResume (6.76s)
        cli_test.go:474: 
            	Error Trace:	cli_test.go:474
            	            				when.go:307
            	            				when.go:316
            	            				cli_test.go:473
            	Error:      	Received unexpected error:
            	            	exit status 1
            	Test:       	TestCLIWithServerOverGRPCSuite/TestNodeSuspendResume

=== FAIL: test/e2e TestCLIWithServerOverGRPCSuite (173.65s)
time="2021-01-17T18:21:06Z" level=info msg="config map" name=workflow-controller-configmap
time="2021-01-17T18:21:06Z" level=info msg="Creating DB session"
time="2021-01-17T18:21:06Z" level=info msg="Node status offloading config" ttl=5m0s

=== FAIL: test/e2e TestCLIWithServerOverHTTP1Suite/TestNodeSuspendResume (6.53s)
mode: HTTP1
Submitting workflow node-suspend 
Waiting 30s for workflow metadata.name=node-suspend suspended node
Condition met after 4s
../../dist/argo -n argo resume node-suspend --node-field-selector inputs.parameters.tag.value=suspend1-tag1
workflow node-suspend resumed

Waiting 30s for workflow metadata.name=node-suspend suspended node
Condition met after 1s
../../dist/argo -n argo stop node-suspend --node-field-selector inputs.parameters.tag.value=suspend2-tag1 --message because
exit status 1workflow node-suspend stopped
time="2021-01-17T18:24:42.799Z" level=fatal msg="rpc error: code = Unknown desc = currently, set only targets suspend nodes: no suspend nodes matching nodeFieldSelector: inputs.parameters.tag.value=suspend2-tag1"

    --- FAIL: TestCLIWithServerOverHTTP1Suite/TestNodeSuspendResume (6.53s)
        cli_test.go:474: 
            	Error Trace:	cli_test.go:474
            	            				when.go:307
            	            				when.go:316
            	            				cli_test.go:473
            	Error:      	Received unexpected error:
            	            	exit status 1
            	Test:       	TestCLIWithServerOverHTTP1Suite/TestNodeSuspendResume

alexec added a commit that referenced this pull request Jan 17, 2021
… command. (#4853)"

This reverts commit 53f7998.

Signed-off-by: Alex Collins <alex_collins@intuit.com>
@noahingh noahingh deleted the cli/stop-options branch January 18, 2021 00:27
This was referenced Jan 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants