Skip to content

Commit

Permalink
Merge pull request #583 from aojea/cmdadddel
Browse files Browse the repository at this point in the history
clarify cmdAdd error
  • Loading branch information
dougbtv committed Nov 19, 2020
2 parents 957e266 + 1b58bed commit 6a23d65
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions multus/multus.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
)

var version = "master@git"
var commit = "unknown commit"
var date = "unknown date"
var (
version = "master@git"
commit = "unknown commit"
date = "unknown date"
)

var pollDuration = 1000 * time.Millisecond
var pollTimeout = 45 * time.Second
var (
pollDuration = 1000 * time.Millisecond
pollTimeout = 45 * time.Second
)

func printVersionString() string {
return fmt.Sprintf("multus-cni version:%s, commit:%s, date:%s",
Expand Down Expand Up @@ -608,7 +612,7 @@ func cmdAdd(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) (c
result = tmpResult
}

//create the network status, only in case Multus as kubeconfig
// create the network status, only in case Multus as kubeconfig
if n.Kubeconfig != "" && kc != nil {
if !types.CheckSystemNamespaces(string(k8sArgs.K8S_POD_NAME), n.SystemNamespaces) {
delegateNetStatus, err := nadutils.CreateNetworkStatus(tmpResult, delegate.Name, delegate.MasterPlugin)
Expand All @@ -621,11 +625,14 @@ 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
// set the network status annotation in apiserver, only in case Multus as kubeconfig
if n.Kubeconfig != "" && kc != nil {
if !types.CheckSystemNamespaces(string(k8sArgs.K8S_POD_NAME), n.SystemNamespaces) {
err = k8s.SetNetworkStatus(kubeClient, k8sArgs, netStatus, n)
if err != nil {
if strings.Contains(err.Error(), "failed to query the pod") {
return nil, cmdErr(k8sArgs, "error setting the networks status, pod was already deleted: %v", err)
}
return nil, cmdErr(k8sArgs, "error setting the networks status: %v", err)
}
}
Expand Down Expand Up @@ -803,7 +810,6 @@ func cmdDel(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) er
}

func main() {

// Init command line flags to clear vendored packages' one, especially in init()
flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError)

Expand Down

0 comments on commit 6a23d65

Please sign in to comment.