diff --git a/components/engine/daemon/cluster/cluster.go b/components/engine/daemon/cluster/cluster.go index 2b31724396..77b16a4d42 100644 --- a/components/engine/daemon/cluster/cluster.go +++ b/components/engine/daemon/cluster/cluster.go @@ -481,8 +481,15 @@ func (c *Cluster) Join(req types.JoinRequest) error { select { case <-time.After(swarmConnectTimeout): - // attempt to connect will continue in background, also reconnecting - go c.reconnectOnFailure(n) + // attempt to connect will continue in background, but reconnect only if it didn't fail + go func() { + select { + case <-n.Ready(): + c.reconnectOnFailure(n) + case <-n.done: + logrus.Errorf("failed to join the cluster: %+v", c.err) + } + }() return ErrSwarmJoinTimeoutReached case <-n.Ready(): go c.reconnectOnFailure(n)