From 8e3e9924945db6c28ff221b8981fd1a09de54752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E6=B4=AA=E8=B4=9E?= Date: Fri, 30 Dec 2022 17:41:03 +0800 Subject: [PATCH] distinguish ippool process for dualstack and normal ippool situation --- pkg/controller/pod.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/pkg/controller/pod.go b/pkg/controller/pod.go index bb802758df1..967e3e1b3fc 100644 --- a/pkg/controller/pod.go +++ b/pkg/controller/pod.go @@ -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 + } } } }