From 7381c84bfb9d586a5a7b87a9d6bcaf3ee15a4256 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Mon, 3 Oct 2016 13:38:01 -0700 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20attempt=20to=20reconnect=20swar?= =?UTF-8?q?m=20on=20failed=20join=20after=20timeout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tonis Tiigi --- daemon/cluster/cluster.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/daemon/cluster/cluster.go b/daemon/cluster/cluster.go index 2b31724396..77b16a4d42 100644 --- a/daemon/cluster/cluster.go +++ b/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)