-
Notifications
You must be signed in to change notification settings - Fork 18.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
stack rm should accept multiple arguments #32110
stack rm should accept multiple arguments #32110
Conversation
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.
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 😉 ). |
|
||
func namespaceFromFilters(filters filters.Args) string { | ||
label := filters.Get("label")[0] | ||
return strings.TrimPrefix(label, convert.LabelNamespace+"=") |
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.
This should probably use convert.Namespace().Descope()
in cli/compose/convert/compose.go
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, you're right. Descope doesn't do what you want. It's good as-is.
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. I left it as-is in the PR update.
cli/command/stack/client_test.go
Outdated
|
||
func serviceFromName(name string) swarm.Service { | ||
return swarm.Service{ | ||
ID: name, |
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 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 👍 |
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.
LGTM 🐯
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.
LGTM
/cc @thaJeztah for docs review 👼 |
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! 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
} | ||
|
||
func newRemoveCommand(dockerCli *command.DockerCli) *cobra.Command { | ||
func newRemoveCommand(dockerCli command.Cli) *cobra.Command { | ||
var opts removeOptions | ||
|
||
cmd := &cobra.Command{ | ||
Use: "rm STACK", |
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 update the usage description to;
Use: "rm STACK [STACK...]",
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.
Thank you for the review. I will update the PR.
cli/command/stack/remove.go
Outdated
} | ||
|
||
func newRemoveCommand(dockerCli *command.DockerCli) *cobra.Command { | ||
func newRemoveCommand(dockerCli command.Cli) *cobra.Command { | ||
var opts removeOptions | ||
|
||
cmd := &cobra.Command{ | ||
Use: "rm STACK", | ||
Aliases: []string{"remove", "down"}, | ||
Short: "Remove the stack", |
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
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.
LGTM, thanks!
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)