From f2a6d37388a66faf37ccf037fbf9a906b9e5167b Mon Sep 17 00:00:00 2001 From: allencloud Date: Wed, 19 Oct 2016 14:35:05 +0800 Subject: [PATCH] change join node role judge Signed-off-by: allencloud --- command/swarm/join.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/command/swarm/join.go b/command/swarm/join.go index 72f97c015e..004313b4c6 100644 --- a/command/swarm/join.go +++ b/command/swarm/join.go @@ -2,7 +2,6 @@ package swarm import ( "fmt" - "strings" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/cli" @@ -61,15 +60,10 @@ func runJoin(dockerCli *command.DockerCli, opts joinOptions) error { return err } - _, _, err = client.NodeInspectWithRaw(ctx, info.Swarm.NodeID) - if err != nil { - // TODO(aaronl): is there a better way to do this? - if strings.Contains(err.Error(), "This node is not a swarm manager.") { - fmt.Fprintln(dockerCli.Out(), "This node joined a swarm as a worker.") - } - } else { + if info.Swarm.ControlAvailable { fmt.Fprintln(dockerCli.Out(), "This node joined a swarm as a manager.") + } else { + fmt.Fprintln(dockerCli.Out(), "This node joined a swarm as a worker.") } - return nil }