Skip to content

Commit

Permalink
Merge pull request #197 from sunya-ch/v1.3.0
Browse files Browse the repository at this point in the history
fix: ignore built-in ipam on cmdDel
  • Loading branch information
sunya-ch authored Dec 2, 2024
2 parents 770266d + 08d2517 commit e241ed0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cni/plugins/main/multi-nic/multi-nic.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ func cmdAdd(args *skel.CmdArgs) error {
// Invoke ipam del if err to avoid ip leak
defer func() {
if err != nil {
ipam.ExecDel(n.IPAM.Type, args.StdinData)
if !isBuiltInIPAM(n.IPAM.Type) {
ipam.ExecDel(n.IPAM.Type, args.StdinData)
}
}
}()

Expand Down Expand Up @@ -233,7 +235,7 @@ func cmdDel(args *skel.CmdArgs) error {
}
utils.Logger.Debug(fmt.Sprintf("Received an DEL request for: conf=%v", n))
// On chained invocation, IPAM block can be empty
if n.IPAM.Type != "" {
if n.IPAM.Type != "" && !isBuiltInIPAM(n.IPAM.Type) {
injectedStdIn := injectMaster(args.StdinData, n.MasterNetAddrs, n.Masters, n.DeviceIDs)
if n.IPAM.Type != "multi-nic-ipam" {
err = ipam.ExecDel(n.IPAM.Type, injectedStdIn)
Expand Down
5 changes: 5 additions & 0 deletions cni/plugins/main/multi-nic/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,8 @@ func getHostIPConfig(index int, devName string) *current.IPConfig {
}
return ipConf
}

// isBuiltInIPAM returns true if ipam is a built-in IPAM (host-device-ipam)
func isBuiltInIPAM(ipamType string) bool {
return ipamType == HostDeviceIPAMType
}

0 comments on commit e241ed0

Please sign in to comment.