Skip to content

Commit

Permalink
check if there are available addresses before adding ippool from name…
Browse files Browse the repository at this point in the history
…space

Signed-off-by: Karol Szwaj <[email protected]>
  • Loading branch information
cnvergence committed Dec 19, 2024
1 parent ffa397b commit 0b75532
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/controller/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -1629,6 +1629,23 @@ func (c *Controller) acquireAddress(pod *v1.Pod, podNet *kubeovnNet) (string, st
klog.Errorf("failed to get ippool %s: %v", ipPoolName, err)
return "", "", "", podNet.Subnet, err
}

switch podNet.Subnet.Spec.Protocol {
case kubeovnv1.ProtocolDual:
if ippool.Status.V4AvailableIPs.Int64() == 0 && ippool.Status.V6AvailableIPs.Int64() == 0 {
continue
}
case kubeovnv1.ProtocolIPv4:
if ippool.Status.V4AvailableIPs.Int64() == 0 {
continue
}

default:
if ippool.Status.V6AvailableIPs.Int64() == 0 {
continue
}
}

if ippool.Spec.Subnet == podNet.Subnet.Name {
ippoolStr = ippool.Name
}
Expand Down

0 comments on commit 0b75532

Please sign in to comment.