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

Fix always listing nodes in docker stack ps command #1093

Merged
merged 2 commits into from
May 30, 2018

Conversation

silvin-lubecki
Copy link
Contributor

- What I did

  • Fixed the docker stack ps command on Kubernetes which always failed with a user without node listing privilege.
  • Fixed double error message output on docker stack rm command.

- How to verify it

  1. Create a user on Kubernetes with only read access on a namespace
  2. Deploy a stack on this namespace
  3. With this user's credentials, execute a docker stack ps on this namespace -> it should not fail and list all the containers

- Description for the changelog

  • Fix always listing nodes during docker stack ps command on Kubernetes.
  • Fix outputting twice the docker stack rm error message

- A picture of a cute animal (not mandatory but encouraged)

image

…. A user without node listing rights could not use this command as it always fails.

Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

small nit, otherwise LGTM

@@ -20,8 +20,7 @@ func RunRemove(dockerCli *KubeCli, opts options.Remove) error {
fmt.Fprintf(dockerCli.Out(), "Removing stack: %s\n", stack)
err := stacks.Delete(stack)
if err != nil {
fmt.Fprintf(dockerCli.Out(), "Failed to remove stack %s: %s\n", stack, err)
return err
return fmt.Errorf("Failed to remove stack %s: %s", stack, err)
Copy link
Member

Choose a reason for hiding this comment

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

nit; probably better to use;

return errors.Wrapf(err, "Failed to remove stack %s", stack)

Can also put the err inside the if;

if err := stacks.Delete(stack); err != nil {
	return errors.Wrapf(err, "Failed to remove stack %s", stack)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PTAL

Copy link
Collaborator

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

LGTM 🐯

Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@thaJeztah thaJeztah merged commit a8ee42a into docker:master May 30, 2018
@GordonTheTurtle GordonTheTurtle added this to the 18.06.0 milestone May 30, 2018
@silvin-lubecki silvin-lubecki deleted the fix-listing-nodes branch May 30, 2018 14:05
fmt.Fprintf(dockerCli.Out(), "Failed to remove stack %s: %s\n", stack, err)
return err
if err := stacks.Delete(stack); err != nil {
return errors.Wrapf(err, "Failed to remove stack %s", stack)
Copy link
Member

Choose a reason for hiding this comment

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

nit: shouldn't error messages be all lowercase?

Copy link
Member

Choose a reason for hiding this comment

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

Was looking at that, but this is printed on the CLI, and other messages (non-error) were also capitalised ("Removing stack ..." and so on)

Copy link
Member

Choose a reason for hiding this comment

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

Fair enough even if the other messages are not errors but printed directly to dockerCli.Out().

Copy link
Member

Choose a reason for hiding this comment

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

We should have a look through all messages to check for consistency though 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants