Skip to content

Commit

Permalink
ipam: fix ip not released for non-ovn subnets (#4265)
Browse files Browse the repository at this point in the history
Signed-off-by: zhangzujian <[email protected]>
  • Loading branch information
zhangzujian committed Jul 8, 2024
1 parent e25bf15 commit cfd2bd7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/ipam/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (s *Subnet) getV4RandomAddress(ippoolName, podName, nicName string, mac *st
// After 'macAdd' introduced to support only static mac address, pod restart will run into error mac AddressConflict
// controller will re-enqueue the new pod then wait for old pod deleted and address released.
// here will return only if both ip and mac exist, otherwise only ip without mac returned will trigger CreatePort error.
if s.V4NicToIP[nicName] != nil && s.NicToMac[nicName] != "" {
if s.V4NicToIP[nicName] != nil && (s.NicToMac[nicName] != "" || (mac != nil && *mac == "")) {
if !slices.Contains(skippedAddrs, s.V4NicToIP[nicName].String()) {
return s.V4NicToIP[nicName], nil, s.NicToMac[nicName], nil
}
Expand Down Expand Up @@ -268,7 +268,7 @@ func (s *Subnet) getV6RandomAddress(ippoolName, podName, nicName string, mac *st
// After 'macAdd' introduced to support only static mac address, pod restart will run into error mac AddressConflict
// controller will re-enqueue the new pod then wait for old pod deleted and address released.
// here will return only if both ip and mac exist, otherwise only ip without mac returned will trigger CreatePort error.
if s.V6NicToIP[nicName] != nil && s.NicToMac[nicName] != "" {
if s.V6NicToIP[nicName] != nil && (s.NicToMac[nicName] != "" || (mac != nil && *mac == "")) {
if !slices.Contains(skippedAddrs, s.V6NicToIP[nicName].String()) {
return nil, s.V6NicToIP[nicName], s.NicToMac[nicName], nil
}
Expand Down

0 comments on commit cfd2bd7

Please sign in to comment.