diff --git a/pkg/kubelet/network/cni/cni.go b/pkg/kubelet/network/cni/cni.go index 540be4b70cf..15724afc486 100644 --- a/pkg/kubelet/network/cni/cni.go +++ b/pkg/kubelet/network/cni/cni.go @@ -273,7 +273,9 @@ func (plugin *cniNetworkPlugin) deleteFromNetwork(network *cniNetwork, podName s netConf, cniNet := network.NetworkConfig, network.CNIConfig glog.V(4).Infof("About to del CNI network %v (type=%v)", netConf.Name, netConf.Plugins[0].Network.Type) err = cniNet.DelNetworkList(netConf, rt) - if err != nil { + // The pod may not get deleted successfully at the first time. + // Ignore "no such file or directory" error in case the network has already been deleted in previous attempts. + if err != nil && !strings.Contains(err.Error(), "no such file or directory") { glog.Errorf("Error deleting network: %v", err) return err } diff --git a/pkg/kubelet/network/kubenet/kubenet_linux.go b/pkg/kubelet/network/kubenet/kubenet_linux.go index f41c59d843e..35e0a1b0cc7 100644 --- a/pkg/kubelet/network/kubenet/kubenet_linux.go +++ b/pkg/kubelet/network/kubenet/kubenet_linux.go @@ -765,7 +765,10 @@ func (plugin *kubenetNetworkPlugin) delContainerFromNetwork(config *libcni.Netwo } glog.V(3).Infof("Removing %s/%s from '%s' with CNI '%s' plugin and runtime: %+v", namespace, name, config.Network.Name, config.Network.Type, rt) - if err := plugin.cniConfig.DelNetwork(config, rt); err != nil { + err = plugin.cniConfig.DelNetwork(config, rt) + // The pod may not get deleted successfully at the first time. + // Ignore "no such file or directory" error in case the network has already been deleted in previous attempts. + if err != nil && !strings.Contains(err.Error(), "no such file or directory") { return fmt.Errorf("Error removing container from network: %v", err) } return nil