1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Do not clear ingress network in libnetwork

- Now that docker has the code to release the ingress
  network, have docker do the release on cluster leave
  and on graceful daemon shutdown.
  This is a cleaner approach in line with the cleanup
  triggered by who created the resource and will avoid
  races on ingress network removal as revealed by the
  docker tests.

Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
Alessandro Boch 2017-03-28 13:36:15 -07:00
parent b670a16ba7
commit b04b258243

View file

@ -337,9 +337,6 @@ func (c *controller) clusterAgentInit() {
// service bindings // service bindings
c.agentClose() c.agentClose()
c.cleanupServiceBindings("") c.cleanupServiceBindings("")
c.clearIngress(true)
return return
} }
} }
@ -1153,46 +1150,7 @@ func (c *controller) getIPAMDriver(name string) (ipamapi.Ipam, *ipamapi.Capabili
} }
func (c *controller) Stop() { func (c *controller) Stop() {
c.clearIngress(false)
c.closeStores() c.closeStores()
c.stopExternalKeyListener() c.stopExternalKeyListener()
osl.GC() osl.GC()
} }
func (c *controller) clearIngress(clusterLeave bool) {
c.Lock()
ingressSandbox := c.ingressSandbox
c.ingressSandbox = nil
c.Unlock()
var n *network
if ingressSandbox != nil {
for _, ep := range ingressSandbox.getConnectedEndpoints() {
if nw := ep.getNetwork(); nw.ingress {
n = nw
break
}
}
if err := ingressSandbox.Delete(); err != nil {
logrus.Warnf("Could not delete ingress sandbox while leaving: %v", err)
}
}
if n == nil {
for _, nw := range c.Networks() {
if nw.Info().Ingress() {
n = nw.(*network)
break
}
}
}
if n == nil && clusterLeave {
logrus.Warnf("Could not find ingress network while leaving")
}
if n != nil {
if err := n.Delete(); err != nil {
logrus.Warnf("Could not delete ingress network while leaving: %v", err)
}
}
}