diff --git a/cni/network/network.go b/cni/network/network.go index 093d812426..5150989336 100644 --- a/cni/network/network.go +++ b/cni/network/network.go @@ -805,10 +805,12 @@ func (plugin *netPlugin) Delete(args *cniSkel.CmdArgs) error { // Query the network. if nwInfo, err = plugin.nm.GetNetworkInfo(networkId); err != nil { - // attempt to release address associated with this Endpoint id - // This is to ensure clean up is done even in failure cases - if err = plugin.DelegateDel(nwCfg.Ipam.Type, nwCfg); err != nil { - log.Printf("Network not found, attempted to release address with error: %v", err) + if !nwCfg.MultiTenancy { + // attempt to release address associated with this Endpoint id + // This is to ensure clean up is done even in failure cases + if err = plugin.DelegateDel(nwCfg.Ipam.Type, nwCfg); err != nil { + log.Printf("Network not found, attempted to release address with error: %v", err) + } } // Log the error but return success if the endpoint being deleted is not found. @@ -820,10 +822,12 @@ func (plugin *netPlugin) Delete(args *cniSkel.CmdArgs) error { // Query the endpoint. if epInfo, err = plugin.nm.GetEndpointInfo(networkId, endpointId); err != nil { - // attempt to release address associated with this Endpoint id - // This is to ensure clean up is done even in failure cases - if err = plugin.DelegateDel(nwCfg.Ipam.Type, nwCfg); err != nil { - log.Printf("Endpoint not found, attempted to release address with error: %v", err) + if !nwCfg.MultiTenancy { + // attempt to release address associated with this Endpoint id + // This is to ensure clean up is done even in failure cases + if err = plugin.DelegateDel(nwCfg.Ipam.Type, nwCfg); err != nil { + log.Printf("Endpoint not found, attempted to release address with error: %v", err) + } } // Log the error but return success if the endpoint being deleted is not found.