Merge pull request #1093 from silvin-lubecki/fix-listing-nodes

Fix always listing nodes in docker stack ps command
This commit is contained in:
Sebastiaan van Stijn 2018-05-30 16:05:14 +02:00 committed by GitHub
commit a8ee42ad53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 5 deletions

View File

@ -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
}
@ -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
}

View File

@ -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
@ -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)
}
}
return nil