Explorar o código

Allow endpoint delete if sandbox identifier is stale

There are cases as seen in https://github.com/docker/docker/issues/17984
the sandbox could be stale in endpoint structure, when the actual
sandbox is removed during the cleanup phase. Hence instead of just
validating for sandboxID, make sure if it is actually present in the
sandboxes DB managed by the controller.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
Madhu Venugopal %!s(int64=9) %!d(string=hai) anos
pai
achega
1aa88fa870
Modificáronse 2 ficheiros con 3 adicións e 2 borrados
  1. 2 1
      libnetwork/endpoint.go
  2. 1 1
      libnetwork/test/integration/dnet/multi.bats

+ 2 - 1
libnetwork/endpoint.go

@@ -584,7 +584,8 @@ func (ep *endpoint) Delete() error {
 	ep.Lock()
 	ep.Lock()
 	epid := ep.id
 	epid := ep.id
 	name := ep.name
 	name := ep.name
-	if ep.sandboxID != "" {
+	sb, _ := n.getController().SandboxByID(ep.sandboxID)
+	if sb != nil {
 		ep.Unlock()
 		ep.Unlock()
 		return &ActiveContainerError{name: name, id: epid}
 		return &ActiveContainerError{name: name, id: epid}
 	}
 	}

+ 1 - 1
libnetwork/test/integration/dnet/multi.bats

@@ -112,7 +112,7 @@ function is_network_exist() {
 
 
 	for j in `seq 1 3`;
 	for j in `seq 1 3`;
 	do
 	do
-	    run dnet_cmd $(inst_id2port 2) service unpublish ${osvc}.${oname}
+	    run dnet_cmd $(inst_id2port $i) service unpublish ${osvc}.${oname}
 	    echo ${output}
 	    echo ${output}
 	    [ "$status" -ne 0 ]
 	    [ "$status" -ne 0 ]
 	    run dnet_cmd $(inst_id2port $j) network rm ${oname}
 	    run dnet_cmd $(inst_id2port $j) network rm ${oname}