Explorar o código

agentSetup to first check if clusterProvider is nil

- concurrent swarm join and daemon stop seen in
  integration tests may cause agentSetup to access
  a nil clusterProvider, resulting in a panic

Signed-off-by: Alessandro Boch <aboch@docker.com>
Alessandro Boch %!s(int64=8) %!d(string=hai) anos
pai
achega
46ebc9613e
Modificáronse 1 ficheiros con 7 adicións e 0 borrados
  1. 7 0
      libnetwork/agent.go

+ 7 - 0
libnetwork/agent.go

@@ -187,6 +187,13 @@ func (c *controller) agentSetup() error {
 	clusterProvider := c.cfg.Daemon.ClusterProvider
 	agent := c.agent
 	c.Unlock()
+
+	if clusterProvider == nil {
+		msg := "Aborting initialization of Libnetwork Agent because cluster provider is now unset"
+		logrus.Errorf(msg)
+		return fmt.Errorf(msg)
+	}
+
 	bindAddr := clusterProvider.GetLocalAddress()
 	advAddr := clusterProvider.GetAdvertiseAddress()
 	remote := clusterProvider.GetRemoteAddress()