Merge pull request #42545 from steffengy/master

libnetwork: processEndpointDelete: Fix deadlock between getSvcRecords and processEndpointDelete
This commit is contained in:
Brian Goff 2021-07-29 09:29:34 -07:00 committed by GitHub
commit 3ad9549e70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 4 deletions

View File

@ -402,11 +402,14 @@ func (c *controller) processEndpointDelete(nmap map[string]*netWatch, ep *endpoi
return
}
networkID := n.ID()
endpointID := ep.ID()
c.Lock()
nw, ok := nmap[n.ID()]
nw, ok := nmap[networkID]
if ok {
delete(nw.localEps, ep.ID())
delete(nw.localEps, endpointID)
c.Unlock()
// Update the svc db about local endpoint leave right away
@ -420,9 +423,9 @@ func (c *controller) processEndpointDelete(nmap map[string]*netWatch, ep *endpoi
// This is the last container going away for the network. Destroy
// this network's svc db entry
delete(c.svcRecords, n.ID())
delete(c.svcRecords, networkID)
delete(nmap, n.ID())
delete(nmap, networkID)
}
}
c.Unlock()