Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silence ENOENT errors and sync networks if no match is found #85

Merged
merged 2 commits into from
Mar 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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