From ac9d72875dfb726a07050fb366e0ccd816e90059 Mon Sep 17 00:00:00 2001 From: Murali Reddy Date: Tue, 7 May 2019 20:30:11 +0530 Subject: [PATCH] ignore the error on IPAM delete for the container with 0 addresses --- plugin/net/cni.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugin/net/cni.go b/plugin/net/cni.go index 04d2de4e42..4a0ba1e757 100644 --- a/plugin/net/cni.go +++ b/plugin/net/cni.go @@ -6,6 +6,7 @@ import ( "fmt" "net" "os" + "strings" "github.com/containernetworking/cni/pkg/ipam" "github.com/containernetworking/cni/pkg/skel" @@ -206,7 +207,13 @@ func (c *CNIPlugin) CmdDel(args *skel.CmdArgs) error { err = ipam.ExecDel(conf.IPAM.Type, args.StdinData) } if err != nil { + if strings.Contains(err.Error(), fmt.Sprintf("Delete: no addresses for %s", args.ContainerID)) { + // ignore the error in the case where there are no IP addresses associated with container + fmt.Fprintln(os.Stderr, "weave-cni:", fmt.Sprintf("Delete: no addresses for %s", args.ContainerID)) + return nil + } logOnStderr(fmt.Errorf("unable to release IP address: %s", err)) + return err } return nil }