mirror of
https://github.com/k8snetworkplumbingwg/multus-cni.git
synced 2025-08-25 19:44:28 +00:00
[bugfix] Skipped clearing the network status annotation if the pod sandbox is not found
This commit is contained in:
parent
05ba224c08
commit
31d87f615d
@ -415,6 +415,8 @@ func cmdDel(args *skel.CmdArgs, exec invoke.Exec, kubeClient k8s.KubeClient) err
|
||||
if args.Netns == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
netnsfound := true
|
||||
netns, err := ns.GetNS(args.Netns)
|
||||
if err != nil {
|
||||
// if NetNs is passed down by the Cloud Orchestration Engine, or if it called multiple times
|
||||
@ -422,6 +424,7 @@ func cmdDel(args *skel.CmdArgs, exec invoke.Exec, kubeClient k8s.KubeClient) err
|
||||
// https://github.com/kubernetes/kubernetes/issues/43014#issuecomment-287164444
|
||||
_, ok := err.(ns.NSPathNotExistErr)
|
||||
if ok {
|
||||
netnsfound = false
|
||||
logging.Debugf("cmdDel: WARNING netns may not exist, netns: %s, err: %s", netns, err)
|
||||
} else {
|
||||
return fmt.Errorf("failed to open netns %q: %v", netns, err)
|
||||
@ -475,6 +478,7 @@ func cmdDel(args *skel.CmdArgs, exec invoke.Exec, kubeClient k8s.KubeClient) err
|
||||
|
||||
// unset the network status annotation in apiserver, only in case Multus as kubeconfig
|
||||
if in.Kubeconfig != "" {
|
||||
if netnsfound {
|
||||
if !types.CheckSystemNamespaces(string(k8sArgs.K8S_POD_NAMESPACE), in.SystemNamespaces) {
|
||||
err := k8s.SetNetworkStatus(kubeClient, k8sArgs, nil, in)
|
||||
if err != nil {
|
||||
@ -482,6 +486,9 @@ func cmdDel(args *skel.CmdArgs, exec invoke.Exec, kubeClient k8s.KubeClient) err
|
||||
logging.Errorf("Multus: Err unset the networks status: %v", err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logging.Debugf("WARNING: Unset SetNetworkStatus skipped due to netns not found.")
|
||||
}
|
||||
}
|
||||
|
||||
rt := types.CreateCNIRuntimeConf(args, k8sArgs, "", in.RuntimeConfig)
|
||||
|
Loading…
Reference in New Issue
Block a user