Skip to content

Commit

Permalink
Skip communicating with kubernetes api failures
Browse files Browse the repository at this point in the history
Multus is failing when can't communicate with kube-api, which fails
to create pods even in case of not using network attachment, this issue
appeared from commit c976f6b for
Add deviceid in clusterNetwork.

This change makes multus skip the failures of communicating with kube-api
and create the networks of delegates

Signed-off-by: Mamduh Alassi <mamduhala@mellanox.com>
  • Loading branch information
Mmduh-483 committed Feb 1, 2021
1 parent f6df613 commit a382c32
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions pkg/multus/multus.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,8 +549,10 @@ func CmdAdd(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) (c
return nil, cmdErr(k8sArgs, "error getting pod by service unavailable: %v", err)
}
} else {
// Other case, return error
return nil, cmdErr(k8sArgs, "error getting pod: %v", err)
// Other case, print warning and return nil
logging.Debugf("%v", cmdErr(k8sArgs, "error getting pod: %v", err))
kubeClient = nil
err = nil
}
}
}
Expand Down Expand Up @@ -670,7 +672,7 @@ func CmdAdd(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) (c
}

// set the network status annotation in apiserver, only in case Multus as kubeconfig
if n.Kubeconfig != "" && kc != nil {
if n.Kubeconfig != "" && kc != nil && kubeClient != nil {
if !types.CheckSystemNamespaces(string(k8sArgs.K8S_POD_NAME), n.SystemNamespaces) {
err = k8s.SetNetworkStatus(kubeClient, k8sArgs, netStatus, n)
if err != nil {
Expand Down Expand Up @@ -777,8 +779,10 @@ func CmdDel(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) er
// If not found, proceed to remove interface with cache
pod = nil
} else {
// Other case, return error
return cmdErr(k8sArgs, "error getting pod: %v", err)
// Other case, print warning and return nil
logging.Debugf("%v", cmdErr(k8sArgs, "error getting pod: %v", err))
kubeClient = nil
err = nil
}
}
}
Expand Down Expand Up @@ -837,7 +841,7 @@ func CmdDel(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) er
}

// unset the network status annotation in apiserver, only in case Multus as kubeconfig
if in.Kubeconfig != "" {
if in.Kubeconfig != "" && kubeClient != nil {
if netnsfound {
if !types.CheckSystemNamespaces(string(k8sArgs.K8S_POD_NAMESPACE), in.SystemNamespaces) {
err := k8s.SetNetworkStatus(kubeClient, k8sArgs, nil, in)
Expand Down

0 comments on commit a382c32

Please sign in to comment.