From f1b75976610e66a6e5807cd282972fd109d74d6c Mon Sep 17 00:00:00 2001 From: Chris Telfer Date: Fri, 6 Jul 2018 16:42:01 -0400 Subject: [PATCH] Get err type in removeNetworks() w/ errors.Cause() Commit c0bc14e8 wrapped the return value of nw.Delete() with some extra information. However, this breaks the code in containerAdaptor.removeNetworks() which ignores certain specific libnetwork error return codes. Said codes actually don't represent errors, but just regular conditions to be expected in normal operation. The removeNetworks() call checked for these errors by type assertions which the errors.Wrap(err...) breaks. This has a cascading effect, because controller.Remove() invokes containerAdaptor.removeNetworks() and if the latter returns an error, then Remove() fails to remove the container itself. This is not necessarily catastrophic since the container reaper apparently will purge the container later, but it is clearly not the behavior we want. Signed-off-by: Chris Telfer Upstream-commit: 6225d1f15c5fd916c3e0ef3afe022f6cc14ac696 Component: engine --- .../engine/daemon/cluster/executor/container/adapter.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/engine/daemon/cluster/executor/container/adapter.go b/components/engine/daemon/cluster/executor/container/adapter.go index 6b222f202d..f4b97ce660 100644 --- a/components/engine/daemon/cluster/executor/container/adapter.go +++ b/components/engine/daemon/cluster/executor/container/adapter.go @@ -4,7 +4,6 @@ import ( "context" "encoding/base64" "encoding/json" - "errors" "fmt" "io" "os" @@ -28,6 +27,7 @@ import ( "github.com/docker/swarmkit/log" gogotypes "github.com/gogo/protobuf/types" "github.com/opencontainers/go-digest" + "github.com/pkg/errors" "github.com/sirupsen/logrus" "golang.org/x/time/rate" ) @@ -172,7 +172,7 @@ func (c *containerAdapter) createNetworks(ctx context.Context) error { func (c *containerAdapter) removeNetworks(ctx context.Context) error { for name, v := range c.container.networksAttachments { if err := c.backend.DeleteManagedNetwork(v.Network.ID); err != nil { - switch err.(type) { + switch errors.Cause(err).(type) { case *libnetwork.ActiveEndpointsError: continue case libnetwork.ErrNoSuchNetwork: