ignore the error on IPAM delete for the container with 0 addresses

This commit is contained in:
Murali Reddy committed 2019-05-10 17:25:58 +05:30
1 parent 690b6ff2cd
commit ac9d72875d
1 file changed
+7
+7
View File
@@ -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
}