Skip to content

Commit

Permalink
Fix CNI plugin to care DNS changes in latest CNI
Browse files Browse the repository at this point in the history
  • Loading branch information
s1061123 committed Oct 26, 2023
1 parent a8d4e0a commit 6e36515
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 18 deletions.
2 changes: 1 addition & 1 deletion plugins/ipam/host-local/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func cmdAdd(args *skel.CmdArgs) error {
if err != nil {
return err
}
result.DNS = *dns
result.DNS = dns

Check failure on line 70 in plugins/ipam/host-local/main.go

View workflow job for this annotation

GitHub Actions / Lint

cannot use dns (variable of type *"github.com/containernetworking/cni/pkg/types".DNS) as "github.com/containernetworking/cni/pkg/types".DNS value in assignment (typecheck)
}

store, err := disk.New(ipamConf.Name, ipamConf.DataDir)
Expand Down
2 changes: 1 addition & 1 deletion plugins/ipam/static/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func cmdAdd(args *skel.CmdArgs) error {

result := &current.Result{
CNIVersion: current.ImplementedSpecVersion,
DNS: ipamConf.DNS,
DNS: &ipamConf.DNS,

Check failure on line 266 in plugins/ipam/static/main.go

View workflow job for this annotation

GitHub Actions / Lint

cannot use &ipamConf.DNS (value of type *"github.com/containernetworking/cni/pkg/types".DNS) as "github.com/containernetworking/cni/pkg/types".DNS value in struct literal (typecheck)
Routes: ipamConf.Routes,
}
for _, v := range ipamConf.Addresses {
Expand Down
9 changes: 1 addition & 8 deletions plugins/main/bridge/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ func cmdAdd(args *skel.CmdArgs) error {

// Use incoming DNS settings if provided, otherwise use the
// settings that were already configued by the IPAM plugin
if dnsConfSet(n.DNS) {
if n.DNS != nil {

Check failure on line 737 in plugins/main/bridge/bridge.go

View workflow job for this annotation

GitHub Actions / Lint

invalid operation: n.DNS != nil (mismatched types "github.com/containernetworking/cni/pkg/types".DNS and untyped nil) (typecheck)
result.DNS = n.DNS
}

Expand All @@ -743,13 +743,6 @@ func cmdAdd(args *skel.CmdArgs) error {
return types.PrintResult(result, cniVersion)
}

func dnsConfSet(dnsConf types.DNS) bool {
return dnsConf.Nameservers != nil ||
dnsConf.Search != nil ||
dnsConf.Options != nil ||
dnsConf.Domain != ""
}

func cmdDel(args *skel.CmdArgs) error {
n, _, err := loadNetConf(args.StdinData, args.Args)
if err != nil {
Expand Down
9 changes: 1 addition & 8 deletions plugins/main/ptp/ptp.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,20 +241,13 @@ func cmdAdd(args *skel.CmdArgs) error {
// Only override the DNS settings in the previous result if any DNS fields
// were provided to the ptp plugin. This allows, for example, IPAM plugins
// to specify the DNS settings instead of the ptp plugin.
if dnsConfSet(conf.DNS) {
if conf.DNS != nil {

Check failure on line 244 in plugins/main/ptp/ptp.go

View workflow job for this annotation

GitHub Actions / Lint

invalid operation: conf.DNS != nil (mismatched types "github.com/containernetworking/cni/pkg/types".DNS and untyped nil) (typecheck)
result.DNS = conf.DNS
}

return types.PrintResult(result, conf.CNIVersion)
}

func dnsConfSet(dnsConf types.DNS) bool {
return dnsConf.Nameservers != nil ||
dnsConf.Search != nil ||
dnsConf.Options != nil ||
dnsConf.Domain != ""
}

func cmdDel(args *skel.CmdArgs) error {
conf := NetConf{}
if err := json.Unmarshal(args.StdinData, &conf); err != nil {
Expand Down

0 comments on commit 6e36515

Please sign in to comment.