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

[WIP]Fix CNI plugin to care DNS changes in latest CNI #964

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
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 @@
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
@@ -1,4 +1,4 @@
// Copyright 2018 CNI authors

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

View workflow job for this annotation

GitHub Actions / Lint

: # github.com/containernetworking/plugins/plugins/ipam/static [github.com/containernetworking/plugins/plugins/ipam/static.test]
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -263,7 +263,7 @@

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
@@ -1,4 +1,4 @@
// Copyright 2014 CNI authors

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

View workflow job for this annotation

GitHub Actions / Lint

: # github.com/containernetworking/plugins/plugins/main/bridge [github.com/containernetworking/plugins/plugins/main/bridge.test]
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -734,7 +734,7 @@

// 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 @@
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
@@ -1,4 +1,4 @@
// Copyright 2015 CNI authors

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

View workflow job for this annotation

GitHub Actions / Lint

: # github.com/containernetworking/plugins/plugins/main/ptp [github.com/containernetworking/plugins/plugins/main/ptp.test]
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -241,20 +241,13 @@
// 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
Loading