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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion cli/command/stack/kubernetes/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func printTasks(dockerCli command.Cli, options options.PS, namespace string, cli
names := map[string]string{}
nodes := map[string]string{}

n, err := client.Nodes().List(metav1.ListOptions{})
n, err := listNodes(client, options.NoResolve)
if err != nil {
return err
}
Expand Down Expand Up @@ -103,3 +103,10 @@ func resolveNode(name string, nodes *apiv1.NodeList, noResolve bool) (string, er
}
return name, nil
}

func listNodes(client corev1.NodesGetter, noResolve bool) (*apiv1.NodeList, error) {
if noResolve {
return client.Nodes().List(metav1.ListOptions{})
}
return nil, nil
}
7 changes: 3 additions & 4 deletions cli/command/stack/kubernetes/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

"github.com/docker/cli/cli/command/stack/options"
"github.com/pkg/errors"
)

// RunRemove is the kubernetes implementation of docker stack remove
Expand All @@ -18,10 +19,8 @@ func RunRemove(dockerCli *KubeCli, opts options.Remove) error {
}
for _, stack := range opts.Namespaces {
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
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 👍

}
}
return nil
Expand Down