Skip to content

Commit 137e941

Browse files
CNI Delete to ignore network not found error (#1293)
* not to return error for network not found in delete call * added comments
1 parent 311eba6 commit 137e941

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

cni/network/network.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -976,21 +976,14 @@ func (plugin *NetPlugin) Delete(args *cniSkel.CmdArgs) error {
976976

977977
// Query the network.
978978
if nwInfo, err = plugin.nm.GetNetworkInfo(networkID); err != nil {
979-
980979
if !nwCfg.MultiTenancy {
981-
// attempt to release address associated with this Endpoint id
982-
// This is to ensure clean up is done even in failure cases
983-
log.Errorf("[cni-net] Failed to query network: %v", err)
984-
telemetry.LogAndSendEvent(plugin.tb, fmt.Sprintf("Release ip by ContainerID (network not found):%v", args.ContainerID))
985-
err = plugin.ipamInvoker.Delete(nil, nwCfg, args, nwInfo.Options)
986-
if err != nil {
987-
return plugin.RetriableError(fmt.Errorf("failed to release address(no network): %w", err))
988-
}
980+
log.Printf("[cni-net] Failed to query network: %v", err)
981+
// Log the error but return success if the network is not found.
982+
// if cni hits this, mostly state file would be missing and it can be reboot scenario where
983+
// container runtime tries to delete and create pods which existed before reboot.
984+
err = nil
985+
return err
989986
}
990-
991-
// Log the error but return success if the endpoint being deleted is not found.
992-
err = nil
993-
return err
994987
}
995988

996989
endpointID := GetEndpointID(args)

0 commit comments

Comments
 (0)