Browse Source

Merge pull request #1417 from mrjana/agent

Nil check ingressSandbox before deleting
Santhosh Manohar 9 years ago
parent
commit
06a391f013
1 changed files with 7 additions and 4 deletions
  1. 7 4
      libnetwork/controller.go

+ 7 - 4
libnetwork/controller.go

@@ -320,14 +320,17 @@ func (c *controller) clusterAgentInit() {
 			c.agentClose()
 			c.cleanupServiceBindings("")
 
-			if err := c.ingressSandbox.Delete(); err != nil {
-				log.Warnf("Could not delete ingress sandbox while leaving: %v", err)
-			}
-
 			c.Lock()
+			ingressSandbox := c.ingressSandbox
 			c.ingressSandbox = nil
 			c.Unlock()
 
+			if ingressSandbox != nil {
+				if err := ingressSandbox.Delete(); err != nil {
+					log.Warnf("Could not delete ingress sandbox while leaving: %v", err)
+				}
+			}
+
 			n, err := c.NetworkByName("ingress")
 			if err != nil {
 				log.Warnf("Could not find ingress network while leaving: %v", err)