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)
if err != nil {
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)
}

View File

@ -263,12 +263,14 @@ 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
if n.Kubeconfig != "" && kc.Podnamespace != "kube-system" {
if n.Kubeconfig != "" && kc != nil {
if kc.Podnamespace != "kube-system" {
err = k8s.SetNetworkStatus(kc, netStatus)
if err != nil {
return nil, fmt.Errorf("Multus: Err set the networks status: %v", err)
}
}
}
return result, nil
}
@ -317,12 +319,14 @@ 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 != "" && kc.Podnamespace != "kube-system" {
if in.Kubeconfig != "" && kc != nil {
if kc.Podnamespace != "kube-system" {
err := k8s.SetNetworkStatus(kc, nil)
if err != nil {
return fmt.Errorf("Multus: Err unset the networks status: %v", err)
}
}
}
rt, _ := types.LoadCNIRuntimeConf(args, k8sArgs, "")
return delPlugins(exec, args.IfName, in.Delegates, len(in.Delegates)-1, rt, in.BinDir)