fixing multus runtime error for network status without pod network annotation

This commit is contained in:
rkamudhan 2018-08-01 14:54:10 +01:00 committed by Kuralamudhan Ramakrishnan
parent 02255b40fa
commit d71fe3447f
2 changed files with 14 additions and 9 deletions

View File

@ -380,7 +380,8 @@ func TryLoadK8sDelegates(k8sArgs *types.K8sArgs, conf *types.NetConf, kubeClient
delegates, err := GetK8sNetwork(kubeClient, k8sArgs, conf.ConfDir) delegates, err := GetK8sNetwork(kubeClient, k8sArgs, conf.ConfDir)
if err != nil { if err != nil {
if _, ok := err.(*NoK8sNetworkError); ok { if _, ok := err.(*NoK8sNetworkError); ok {
return 0, nil, nil return 0, clientInfo, nil
//return 0, nil, nil
} }
return 0, nil, fmt.Errorf("Multus: Err in getting k8s network from pod: %v", err) return 0, nil, fmt.Errorf("Multus: Err in getting k8s network from pod: %v", err)
} }

View File

@ -263,10 +263,12 @@ func cmdAdd(args *skel.CmdArgs, exec invoke.Exec, kubeClient k8s.KubeClient) (cn
} }
//set the network status annotation in apiserver, only in case Multus as kubeconfig //set the network status annotation in apiserver, only in case Multus as kubeconfig
if n.Kubeconfig != "" && kc.Podnamespace != "kube-system" { if n.Kubeconfig != "" && kc != nil {
err = k8s.SetNetworkStatus(kc, netStatus) if kc.Podnamespace != "kube-system" {
if err != nil { err = k8s.SetNetworkStatus(kc, netStatus)
return nil, fmt.Errorf("Multus: Err set the networks status: %v", err) if err != nil {
return nil, fmt.Errorf("Multus: Err set the networks status: %v", err)
}
} }
} }
@ -317,10 +319,12 @@ 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 != "" && kc.Podnamespace != "kube-system" { if in.Kubeconfig != "" && kc != nil {
err := k8s.SetNetworkStatus(kc, nil) if kc.Podnamespace != "kube-system" {
if err != nil { err := k8s.SetNetworkStatus(kc, nil)
return fmt.Errorf("Multus: Err unset the networks status: %v", err) if err != nil {
return fmt.Errorf("Multus: Err unset the networks status: %v", err)
}
} }
} }