소스 검색

Merge pull request #27123 from tonistiigi/fix-join-reconnect

Don’t attempt to reconnect swarm on failed join after timeout
Aaron Lehmann 8 년 전
부모
커밋
0ccbae0437
1개의 변경된 파일9개의 추가작업 그리고 2개의 파일을 삭제
  1. 9 2
      daemon/cluster/cluster.go

+ 9 - 2
daemon/cluster/cluster.go

@@ -498,8 +498,15 @@ func (c *Cluster) Join(req types.JoinRequest) error {
 
 
 	select {
 	select {
 	case <-time.After(swarmConnectTimeout):
 	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
 		return ErrSwarmJoinTimeoutReached
 	case <-n.Ready():
 	case <-n.Ready():
 		go c.reconnectOnFailure(n)
 		go c.reconnectOnFailure(n)