Merge pull request #13 from dougbtv/release-v3-may03-02

[bugfix] Skip clearing the network status annotation if the pod sandbox is not found
This commit is contained in:
OpenShift Merge Robot 2019-05-07 14:30:52 +02:00 committed by GitHub
commit e13c535019
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -415,6 +415,8 @@ func cmdDel(args *skel.CmdArgs, exec invoke.Exec, kubeClient k8s.KubeClient) err
if args.Netns == "" { if args.Netns == "" {
return nil return nil
} }
netnsfound := true
netns, err := ns.GetNS(args.Netns) netns, err := ns.GetNS(args.Netns)
if err != nil { if err != nil {
// if NetNs is passed down by the Cloud Orchestration Engine, or if it called multiple times // 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 // https://github.com/kubernetes/kubernetes/issues/43014#issuecomment-287164444
_, ok := err.(ns.NSPathNotExistErr) _, ok := err.(ns.NSPathNotExistErr)
if ok { if ok {
netnsfound = false
logging.Debugf("cmdDel: WARNING netns may not exist, netns: %s, err: %s", netns, err) logging.Debugf("cmdDel: WARNING netns may not exist, netns: %s, err: %s", netns, err)
} else { } else {
return fmt.Errorf("failed to open netns %q: %v", netns, err) return fmt.Errorf("failed to open netns %q: %v", netns, err)
@ -475,12 +478,16 @@ 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 // unset the network status annotation in apiserver, only in case Multus as kubeconfig
if in.Kubeconfig != "" { if in.Kubeconfig != "" {
if !types.CheckSystemNamespaces(string(k8sArgs.K8S_POD_NAMESPACE), in.SystemNamespaces) { if netnsfound {
err := k8s.SetNetworkStatus(kubeClient, k8sArgs, nil, in) if !types.CheckSystemNamespaces(string(k8sArgs.K8S_POD_NAMESPACE), in.SystemNamespaces) {
if err != nil { err := k8s.SetNetworkStatus(kubeClient, k8sArgs, nil, in)
// error happen but continue to delete if err != nil {
logging.Errorf("Multus: Err unset the networks status: %v", err) // error happen but continue to delete
logging.Errorf("Multus: Err unset the networks status: %v", err)
}
} }
} else {
logging.Debugf("WARNING: Unset SetNetworkStatus skipped due to netns not found.")
} }
} }