From 5ba70f9092facbfe12e8e745666b6e4903e39b75 Mon Sep 17 00:00:00 2001 From: Tamilmani Manoharan Date: Wed, 18 Oct 2017 17:15:53 -0700 Subject: [PATCH] Made changes in netlink code to ignore interface not found error --- cni/network/network.go | 6 +++--- netlink/link.go | 15 +++++++++------ network/endpoint.go | 3 ++- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/cni/network/network.go b/cni/network/network.go index 458dbd17a..2e51726c0 100644 --- a/cni/network/network.go +++ b/cni/network/network.go @@ -320,8 +320,8 @@ func (plugin *netPlugin) Delete(args *cniSkel.CmdArgs) error { // Delete the endpoint. err = plugin.nm.DeleteEndpoint(networkId, endpointId) if err != nil { - // Log the error but don't return before releasing address - log.Printf("Container Namespace might have been removed. Failed to delete endpoint: %v", err) + err = plugin.Errorf("Failed to delete endpoint: %v", err) + return err } // Call into IPAM plugin to release the endpoint's addresses. @@ -330,7 +330,7 @@ func (plugin *netPlugin) Delete(args *cniSkel.CmdArgs) error { nwCfg.Ipam.Address = address.IP.String() err = plugin.DelegateDel(nwCfg.Ipam.Type, nwCfg) if err != nil { - plugin.Errorf("Failed to release address: %v", err) + err = plugin.Errorf("Failed to release address: %v", err) return err } } diff --git a/netlink/link.go b/netlink/link.go index 3021727bc..7bf3ec893 100644 --- a/netlink/link.go +++ b/netlink/link.go @@ -7,6 +7,7 @@ import ( "fmt" "net" + "github.com/Azure/azure-container-networking/log" "golang.org/x/sys/unix" ) @@ -146,15 +147,17 @@ func AddLink(link Link) error { // DeleteLink deletes a network interface. func DeleteLink(name string) error { if name == "" { - return fmt.Errorf("Invalid link name") - } - - s, err := getSocket() - if err != nil { - return err + log.Printf("[net] Invalid link name. Not returning error") + return nil } iface, err := net.InterfaceByName(name) + if err != nil { + log.Printf("[net] Interface not found. Not returning error") + return nil + } + + s, err := getSocket() if err != nil { return err } diff --git a/network/endpoint.go b/network/endpoint.go index 07ac9eb7e..7b2e74386 100644 --- a/network/endpoint.go +++ b/network/endpoint.go @@ -83,7 +83,8 @@ func (nw *network) deleteEndpoint(endpointId string) error { // Look up the endpoint. ep, err := nw.getEndpoint(endpointId) if err != nil { - return err + log.Printf("[net] Endpoint %v not found. Not Returning error", endpointId) + return nil } // Call the platform implementation.