stack rm should accept multiple arguments#32110
Conversation
vdemeester
left a comment
There was a problem hiding this comment.
Design LGTM, just wonder if we should do the same as container rm or not ? (i.e. print errors at the end, but try to delete all namespace — if the first one fail, we keep the error, and return it at the end, but we still try to remove the 2nd one).
stack rm should accept multiple labels
stack rm should accept multiple arguments or stack rm should accept multiple namespaces. Label is not the right term here I feel.
/cc @thaJeztah @dnephin
|
If the design is acceptable, would it be a good idea if I submit separate PRs to add unit tests that cover more of the stack package? |
|
@adshmh ❤️ for more unit tests. I don't think there is too much need to create a separate PR, could just be in another commit, but it's not a strong opinion from my part (so feel free to do what you feel makes more sence 😉 ). |
cli/command/stack/client_test.go
Outdated
There was a problem hiding this comment.
This should probably use convert.Namespace().Descope() in cli/compose/convert/compose.go
There was a problem hiding this comment.
Thank you for the review. Since getServices() adds convert.LabelNamespace to the filters, I need to trim it and then use Namespace().Descope() in belongToNamespace(). Would this be acceptable?
There was a problem hiding this comment.
Oh, you're right. Descope doesn't do what you want. It's good as-is.
There was a problem hiding this comment.
Thanks. I left it as-is in the PR update.
cli/command/stack/client_test.go
Outdated
There was a problem hiding this comment.
The ID string is not going to be same as the name. To avoid tests that pass incorrectly maybe we should append pr prepend some other string (ID-) so that if we differentiate between the ID and the name.
Thanks, I will change the PR so it attempts to remove all specified namespaces. |
fdceedd to
9ba614f
Compare
|
Oh, looks like this needs a rebase now @adshmh 😢 |
ad2cd5e to
8bf1f4e
Compare
|
The Windows build error does not seem to be due to the changes made by the PR:
|
|
Yup, that's not related, looks like a node was out of disk space. I restarted the build 👍 |
|
@vdemeester @dnephin ptal 👍 |
|
/cc @thaJeztah for docs review 👼 |
thaJeztah
left a comment
There was a problem hiding this comment.
Thanks! I left some comments inline; it would also be good to have one or two examples added to the CLI docs; https://github.com/docker/docker/blob/master/docs/reference/commandline/stack_rm.md
The examples section should have its own header, you can use the rm.md page for inspiration 😄 https://github.com/docker/docker/blob/master/docs/reference/commandline/rm.md#examples
cli/command/stack/remove.go
Outdated
There was a problem hiding this comment.
can you update the usage description to;
Use: "rm STACK [STACK...]",There was a problem hiding this comment.
Thank you for the review. I will update the PR.
cli/command/stack/remove.go
Outdated
There was a problem hiding this comment.
Can you change this to;
Short: "Remove one or more stacks",to be consistent with other commands that accept multiple options
There was a problem hiding this comment.
Thank you. I will change that line.
Perhaps I need to create a PR on docker/docker.github.io as well, after the changes to the CLI docs are approved?
There was a problem hiding this comment.
the CLI reference documentation on docs.docker.com is generated from this output, in combination with the markdown in this repo (#32110 (review)), so perhaps no changes are needed, but you could check if there's other markdown files (here, and in the docs repo) that include the USAGE output
|
Also ping @albers @sdurrheimer (this may need an update to the completion scripts) |
Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
8bf1f4e to
ff0899a
Compare
|
I have updated the PR with changes to the stack rm command's usage message and the CLI docs. |
|
Wow, nice test, good docs update. |
|
LGTM |
…t-multiple-labels stack rm should accept multiple arguments
stack rm should accept multiple arguments (addresses item 2 from #30977).
Signed-off-by: Arash Deshmeh adeshmeh@ca.ibm.com
- What I did
Added the ability to supply multiple stack labels to the 'docker stack rm' command.
- How I did it
A loop is added to the stack rm code to go through the list of stacks specified as input. Unit tests were also added to cover the stack rm code.
- How to verify it
$ docker stack deploy -c ./stack.yml stack1
Creating network stack1_frontend
Creating network stack1_default
Creating service stack1_redis
Creating service stack1_lb
Creating service stack1_web
$ docker stack deploy -c ./stack.yml stack2
Creating network stack2_default
Creating network stack2_frontend
Creating service stack2_redis
Creating service stack2_lb
Creating service stack2_web
$ docker stack remove stack1 stack2
Removing service stack1_redis
Removing service stack1_web
Removing service stack1_lb
Removing network stack1_default
Removing network stack1_frontend
Removing service stack2_web
Removing service stack2_redis
Removing service stack2_lb
Removing network stack2_frontend
Removing network stack2_default
- Description for the changelog
'docker stack rm' command now accepts multiple stack labels as input.
- A picture of a cute animal (not mandatory but encouraged)