Skip to content

Commit

Permalink
distinguish ippool process for dualstack and normal ippool situation (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
hongzhen-ma committed Dec 31, 2022
1 parent 098a821 commit 4f08d94
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions pkg/controller/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -1289,16 +1289,25 @@ func (c *Controller) acquireAddress(pod *v1.Pod, podNet *kubeovnNet) (string, st
if !isStsPod {
for _, net := range nsNets {
for _, staticIPs := range ipPool {
ipProtocol := util.CheckProtocol(staticIPs)
for _, staticIP := range strings.Split(staticIPs, ",") {
if assignedPod, ok := c.ipam.IsIPAssignedToOtherPod(staticIP, net.Subnet.Name, key); ok {
klog.Errorf("static address %s for %s has been assigned to %", staticIP, key, assignedPod)
klog.Errorf("static address %s for %s has been assigned to %s", staticIP, key, assignedPod)
continue
}
}

v4IP, v6IP, mac, err = c.acquireStaticAddress(key, portName, staticIPs, macStr, net.Subnet.Name, net.AllowLiveMigration)
if err == nil {
return v4IP, v6IP, mac, net.Subnet, nil
if ipProtocol != kubeovnv1.ProtocolDual {
v4IP, v6IP, mac, err = c.acquireStaticAddress(key, portName, staticIP, macStr, net.Subnet.Name, net.AllowLiveMigration)
if err == nil {
return v4IP, v6IP, mac, net.Subnet, nil
}
}
}
if ipProtocol == kubeovnv1.ProtocolDual {
v4IP, v6IP, mac, err = c.acquireStaticAddress(key, portName, staticIPs, macStr, net.Subnet.Name, net.AllowLiveMigration)
if err == nil {
return v4IP, v6IP, mac, net.Subnet, nil
}
}
}
}
Expand Down

0 comments on commit 4f08d94

Please sign in to comment.