55 "encoding/json"
66 "errors"
77 "fmt"
8+ "io/fs"
89 "net"
910 "os"
1011 "path"
@@ -330,7 +331,7 @@ func loadNetworks(ctx context.Context, confDir string, cni *libcni.CNIConfig) (n
330331 confList , err = libcni .ConfListFromFile (confFile )
331332 if err != nil {
332333 // do not log ENOENT errors
333- if ! os . IsNotExist (err ) {
334+ if ! errors . Is (err , fs . ErrNotExist ) {
334335 logrus .Errorf ("Error loading CNI config list file %s: %v" , confFile , err )
335336 }
336337
@@ -347,7 +348,7 @@ func loadNetworks(ctx context.Context, confDir string, cni *libcni.CNIConfig) (n
347348 conf , err := libcni .NetworkPluginConfFromBytes (bytes )
348349 if err != nil {
349350 // do not log ENOENT errors
350- if ! os . IsNotExist (err ) {
351+ if ! errors . Is (err , fs . ErrNotExist ) {
351352 logrus .Errorf ("Error loading CNI config file %s: %v" , confFile , err )
352353 }
353354
@@ -372,7 +373,7 @@ func loadNetworks(ctx context.Context, confDir string, cni *libcni.CNIConfig) (n
372373 // Validation on CNI config should be done to pre-check presence
373374 // of plugins which are necessary.
374375 if _ , err := cni .ValidateNetworkList (ctx , confList ); err != nil {
375- logrus .Warningf ("Error validating CNI config file %s: %v" , confFile , err )
376+ logrus .Warnf ("Error validating CNI config file %s: %v" , confFile , err )
376377
377378 continue
378379 }
@@ -606,7 +607,7 @@ func (plugin *cniNetworkPlugin) forEachNetwork(ctx context.Context, podNetwork *
606607 cniNet , newRt , err = plugin .loadNetworkFromCache (network .Name , rt )
607608 if err != nil {
608609 logrus .Errorf ("Error loading cached network config: %v" , err )
609- logrus .Warningf ("Falling back to loading from existing plugins on disk" )
610+ logrus .Warnf ("Falling back to loading from existing plugins on disk" )
610611 } else {
611612 // Use the updated RuntimeConf
612613 rt = newRt
@@ -732,7 +733,7 @@ func (plugin *cniNetworkPlugin) getCachedNetworkInfo(containerID string) ([]NetA
732733 }
733734
734735 if cachedInfo .Kind != libcni .CNICacheV1 {
735- logrus .Warningf ("Unknown CNI cache file %s kind %q" , cacheFile , cachedInfo .Kind )
736+ logrus .Warnf ("Unknown CNI cache file %s kind %q" , cacheFile , cachedInfo .Kind )
736737
737738 continue
738739 }
@@ -746,7 +747,7 @@ func (plugin *cniNetworkPlugin) getCachedNetworkInfo(containerID string) ([]NetA
746747 }
747748
748749 if cachedInfo .IfName == "" || cachedInfo .NetName == "" {
749- logrus .Warningf ("Missing CNI cache file %s ifname %q or netname %q" , cacheFile , cachedInfo .IfName , cachedInfo .NetName )
750+ logrus .Warnf ("Missing CNI cache file %s ifname %q or netname %q" , cacheFile , cachedInfo .IfName , cachedInfo .NetName )
750751
751752 continue
752753 }
@@ -963,7 +964,7 @@ func (network *cniNetwork) checkNetwork(ctx context.Context, rt *libcni.RuntimeC
963964 }
964965
965966 if cniInterface == nil || len (ips ) == 0 {
966- return nil , fmt .Errorf ("neither IPv4 nor IPv6 found when retrieving network status: %v " , errs )
967+ return nil , fmt .Errorf ("neither IPv4 nor IPv6 found when retrieving network status: %w " , errors . Join ( errs ... ) )
967968 }
968969
969970 result = & cniv1.Result {
@@ -998,7 +999,7 @@ func buildCNIRuntimeConf(podNetwork *PodNetwork, ifName string, runtimeConfig *R
998999 runtimeConfig = & RuntimeConfig {}
9991000 }
10001001
1001- logrus .Infof ("Got pod network %+v" , podNetwork )
1002+ logrus .Debugf ("Got pod network %+v" , podNetwork )
10021003
10031004 rt := & libcni.RuntimeConf {
10041005 ContainerID : podNetwork .ID ,
0 commit comments