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 9, 2024
1 parent f151e32 commit 1e53391
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 @@ -210,7 +210,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 !util.ContainsString(skippedAddrs, s.V4NicToIP[nicName].String()) {
return s.V4NicToIP[nicName], nil, s.NicToMac[nicName], nil
}
Expand Down Expand Up @@ -264,7 +264,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 !util.ContainsString(skippedAddrs, s.V6NicToIP[nicName].String()) {
return nil, s.V6NicToIP[nicName], s.NicToMac[nicName], nil
}
Expand Down

0 comments on commit 1e53391

Please sign in to comment.