浏览代码

Cleanup ingress network and sandbox on leave

When a node leaves the swarm cluster, we should cleanup the ingress
network and sandbox. This makes sure that when the next time the node
joins the swarm it will be able to update the cluster with the right
information.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
Jana Radhakrishnan 9 年之前
父节点
当前提交
4b80c3411d
共有 1 个文件被更改,包括 18 次插入0 次删除
  1. 18 0
      libnetwork/controller.go

+ 18 - 0
libnetwork/controller.go

@@ -308,6 +308,24 @@ func (c *controller) clusterAgentInit() {
 			c.clusterConfigAvailable = false
 			c.agentInitDone = make(chan struct{})
 			c.Unlock()
+
+			if err := c.ingressSandbox.Delete(); err != nil {
+				log.Warnf("Could not delete ingress sandbox while leaving: %v", err)
+			}
+
+			c.ingressSandbox = nil
+
+			n, err := c.NetworkByName("ingress")
+			if err != nil {
+				log.Warnf("Could not find ingress network while leaving: %v", err)
+			}
+
+			if n != nil {
+				if err := n.Delete(); err != nil {
+					log.Warnf("Could not delete ingress network while leaving: %v", err)
+				}
+			}
+
 			c.agentClose()
 			return
 		}