Skip to content

Commit

Permalink
Switch cni plugin conf dir first and and then load the default conf f…
Browse files Browse the repository at this point in the history
…rom the dir

Signed-off-by: Yakul Garg <2000yeshu@gmail.com>
  • Loading branch information
2000yeshu committed Mar 27, 2024
1 parent 5f05b58 commit d9f8918
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion cmd/ctr/commands/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,12 @@ var Command = cli.Command{
var network gocni.CNI
if enableCNI {
if cniConfDir != "" {
if network, err = gocni.New(gocni.WithDefaultConf, gocni.WithPluginConfDir(cniConfDir)); err != nil {
network, err = gocni.New(gocni.WithPluginConfDir(cniConfDir))
if err != nil {
return err
}

if err := network.Load(gocni.WithDefaultConf); err != nil {
return err
}
} else if network, err = gocni.New(gocni.WithDefaultConf); err != nil {
Expand Down
7 changes: 6 additions & 1 deletion cmd/ctr/commands/tasks/kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ func RemoveCniNetworkIfExist(ctx context.Context, container containerd.Container
var network gocni.CNI
if networkMetaData.EnableCni {
if networkMetaData.CniConfDir != "" {
if network, err = gocni.New(gocni.WithDefaultConf, gocni.WithPluginConfDir(networkMetaData.CniConfDir)); err != nil {
network, err = gocni.New(gocni.WithPluginConfDir(networkMetaData.CniConfDir))
if err != nil {
return err
}

if err := network.Load(gocni.WithDefaultConf); err != nil {
return err
}
} else {
Expand Down

0 comments on commit d9f8918

Please sign in to comment.