From 495252723d2f923c9c401672c2c81bd64a37a5a5 Mon Sep 17 00:00:00 2001 From: Pradip Dhara Date: Tue, 5 Sep 2017 14:33:27 -0700 Subject: [PATCH] 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 --- libnetwork/sandbox.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libnetwork/sandbox.go b/libnetwork/sandbox.go index 6f4c2508b2..c8f5a8abcb 100644 --- a/libnetwork/sandbox.go +++ b/libnetwork/sandbox.go @@ -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 {