Skip to content

Commit

Permalink
Merge pull request #85 from Luap99/silence-enoent-errors
Browse files Browse the repository at this point in the history
Silence ENOENT errors and sync networks if no match is found
  • Loading branch information
openshift-merge-robot authored Mar 1, 2021
2 parents b6cbe99 + cd5167f commit f3789d9
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions pkg/ocicni/ocicni.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,19 @@ func loadNetworks(confDir string, cni *libcni.CNIConfig) (map[string]*cniNetwork
if strings.HasSuffix(confFile, ".conflist") {
confList, err = libcni.ConfListFromFile(confFile)
if err != nil {
logrus.Errorf("Error loading CNI config list file %s: %v", confFile, err)
// do not log ENOENT errors
if !os.IsNotExist(err) {
logrus.Errorf("Error loading CNI config list file %s: %v", confFile, err)
}
continue
}
} else {
conf, err := libcni.ConfFromFile(confFile)
if err != nil {
logrus.Errorf("Error loading CNI config file %s: %v", confFile, err)
// do not log ENOENT errors
if !os.IsNotExist(err) {
logrus.Errorf("Error loading CNI config file %s: %v", confFile, err)
}
continue
}
if conf.Network.Type == "" {
Expand Down Expand Up @@ -489,8 +495,15 @@ func (plugin *cniNetworkPlugin) forEachNetwork(podNetwork *PodNetwork, fromCache
if cniNet == nil {
cniNet, err = plugin.getNetwork(network.Name)
if err != nil {
logrus.Errorf(err.Error())
return err
// try to load the networks again
if err2 := plugin.syncNetworkConfig(); err2 != nil {
logrus.Error(err2)
return err
}
cniNet, err = plugin.getNetwork(network.Name)
if err != nil {
return err
}
}
}

Expand Down

0 comments on commit f3789d9

Please sign in to comment.