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

Clear ingress resources on graceful shutdown

Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
Alessandro Boch 2016-09-29 15:01:44 -07:00
parent 59832beb31
commit ded6e1934a

View file

@ -324,27 +324,7 @@ func (c *controller) clusterAgentInit() {
c.agentClose()
c.cleanupServiceBindings("")
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)
}
if n != nil {
if err := n.Delete(); err != nil {
log.Warnf("Could not delete ingress network while leaving: %v", err)
}
}
c.clearIngress(true)
return
}
@ -1108,7 +1088,32 @@ func (c *controller) getIPAMDriver(name string) (ipamapi.Ipam, *ipamapi.Capabili
}
func (c *controller) Stop() {
c.clearIngress(false)
c.closeStores()
c.stopExternalKeyListener()
osl.GC()
}
func (c *controller) clearIngress(clusterLeave bool) {
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 && clusterLeave {
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)
}
}
}