From cc146b341e60661e0f374d6ec126598f2460e382 Mon Sep 17 00:00:00 2001 From: Tomofumi Hayashi Date: Wed, 4 Dec 2019 19:04:42 +0900 Subject: [PATCH] Change the message in case of missing CNI files This change alters the error message "Missing CNI default network" because it is sometimes a bit unclear to real user. Signed-off-by: Tomofumi Hayashi --- pkg/ocicni/ocicni.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/ocicni/ocicni.go b/pkg/ocicni/ocicni.go index 0cdbf14b..499e2ad4 100644 --- a/pkg/ocicni/ocicni.go +++ b/pkg/ocicni/ocicni.go @@ -3,7 +3,6 @@ package ocicni import ( "context" "encoding/json" - "errors" "fmt" "io/ioutil" "net" @@ -62,7 +61,7 @@ type cniNetwork struct { config *libcni.NetworkConfigList } -var errMissingDefaultNetwork = errors.New("Missing CNI default network") +var errMissingDefaultNetwork = "No CNI configuration file in %s. Has your network provider started?" type podLock struct { // Count of in-flight operations for this pod; when this reaches zero @@ -413,7 +412,7 @@ func (plugin *cniNetworkPlugin) getDefaultNetwork() *cniNetwork { // to attach the pod to. func (plugin *cniNetworkPlugin) networksAvailable(podNetwork *PodNetwork) error { if len(podNetwork.Networks) == 0 && plugin.getDefaultNetwork() == nil { - return errMissingDefaultNetwork + return fmt.Errorf(errMissingDefaultNetwork, plugin.confDir) } return nil } @@ -854,7 +853,7 @@ func buildCNIRuntimeConf(cacheDir string, podNetwork *PodNetwork, ifName string, func (plugin *cniNetworkPlugin) Status() error { if plugin.getDefaultNetwork() == nil { - return errMissingDefaultNetwork + return fmt.Errorf(errMissingDefaultNetwork, plugin.confDir) } return nil }