Fixing a race condition that caused a Panic when deleting overlay network then quickly leaving swarm.

This issue was uncovered in TestOverlayAttachableReleaseResourcesOnFailure.

Signed-off-by: Pradip Dhara <pradipd@microsoft.com>
This commit is contained in:
Pradip Dhara 2017-09-05 14:33:27 -07:00
parent cc08cacfab
commit 495252723d
1 changed files with 7 additions and 0 deletions

View File

@ -916,6 +916,13 @@ func (sb *sandbox) clearNetworkResources(origEp *endpoint) error {
break
}
}
if index == -1 {
logrus.Errorf("Endpoint %s has already been deleted", ep.Name())
sb.Unlock()
return nil
}
heap.Remove(&sb.endpoints, index)
for _, e := range sb.endpoints {
if len(e.Gateway()) > 0 {