Skip to content

Commit

Permalink
Change the message in case of missing CNI files
Browse files Browse the repository at this point in the history
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 <tohayash@redhat.com>
  • Loading branch information
s1061123 committed Dec 4, 2019
1 parent deac903 commit cc146b3
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pkg/ocicni/ocicni.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package ocicni
import (
"context"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}

0 comments on commit cc146b3

Please # to comment.