Skip to content

Commit 6e36515

Browse files
committed
Fix CNI plugin to care DNS changes in latest CNI
1 parent a8d4e0a commit 6e36515

4 files changed

Lines changed: 4 additions & 18 deletions

File tree

plugins/ipam/host-local/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func cmdAdd(args *skel.CmdArgs) error {
6767
if err != nil {
6868
return err
6969
}
70-
result.DNS = *dns
70+
result.DNS = dns
7171
}
7272

7373
store, err := disk.New(ipamConf.Name, ipamConf.DataDir)

plugins/ipam/static/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ func cmdAdd(args *skel.CmdArgs) error {
263263

264264
result := &current.Result{
265265
CNIVersion: current.ImplementedSpecVersion,
266-
DNS: ipamConf.DNS,
266+
DNS: &ipamConf.DNS,
267267
Routes: ipamConf.Routes,
268268
}
269269
for _, v := range ipamConf.Addresses {

plugins/main/bridge/bridge.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ func cmdAdd(args *skel.CmdArgs) error {
734734

735735
// Use incoming DNS settings if provided, otherwise use the
736736
// settings that were already configued by the IPAM plugin
737-
if dnsConfSet(n.DNS) {
737+
if n.DNS != nil {
738738
result.DNS = n.DNS
739739
}
740740

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

746-
func dnsConfSet(dnsConf types.DNS) bool {
747-
return dnsConf.Nameservers != nil ||
748-
dnsConf.Search != nil ||
749-
dnsConf.Options != nil ||
750-
dnsConf.Domain != ""
751-
}
752-
753746
func cmdDel(args *skel.CmdArgs) error {
754747
n, _, err := loadNetConf(args.StdinData, args.Args)
755748
if err != nil {

plugins/main/ptp/ptp.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,20 +241,13 @@ func cmdAdd(args *skel.CmdArgs) error {
241241
// Only override the DNS settings in the previous result if any DNS fields
242242
// were provided to the ptp plugin. This allows, for example, IPAM plugins
243243
// to specify the DNS settings instead of the ptp plugin.
244-
if dnsConfSet(conf.DNS) {
244+
if conf.DNS != nil {
245245
result.DNS = conf.DNS
246246
}
247247

248248
return types.PrintResult(result, conf.CNIVersion)
249249
}
250250

251-
func dnsConfSet(dnsConf types.DNS) bool {
252-
return dnsConf.Nameservers != nil ||
253-
dnsConf.Search != nil ||
254-
dnsConf.Options != nil ||
255-
dnsConf.Domain != ""
256-
}
257-
258251
func cmdDel(args *skel.CmdArgs) error {
259252
conf := NetConf{}
260253
if err := json.Unmarshal(args.StdinData, &conf); err != nil {

0 commit comments

Comments
 (0)