Skip to content

Commit ec3f447

Browse files
committed
fix: subnet not count ip after ip exist or deletion
Signed-off-by: zbb88888 <[email protected]>
1 parent 4e5a8f7 commit ec3f447

File tree

1 file changed

+8
-26
lines changed

1 file changed

+8
-26
lines changed

pkg/controller/ip.go

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ func (c *Controller) enqueueAddIP(obj any) {
3030
if strings.HasPrefix(ipObj.Name, util.U2OInterconnName[0:19]) {
3131
return
3232
}
33-
klog.V(3).Infof("enqueue update status subnet %s", ipObj.Spec.Subnet)
34-
c.updateSubnetStatusQueue.Add(ipObj.Spec.Subnet)
35-
for _, as := range ipObj.Spec.AttachSubnets {
36-
klog.V(3).Infof("enqueue update attach status for subnet %s", as)
37-
c.updateSubnetStatusQueue.Add(as)
38-
}
39-
4033
key := cache.MetaObjectToName(ipObj).String()
4134
klog.V(3).Infof("enqueue add ip %s", key)
4235
c.addIPQueue.Add(key)
@@ -162,25 +155,6 @@ func (c *Controller) handleAddReservedIP(key string) error {
162155
return err
163156
}
164157

165-
portName := ovs.PodNameToPortName(ip.Spec.PodName, ip.Spec.Namespace, subnet.Spec.Provider)
166-
if portName != ip.Name {
167-
// invalid ip or node ip, no need to handle it here
168-
klog.V(3).Infof("port name %s is not equal to ip name %s", portName, ip.Name)
169-
return nil
170-
}
171-
172-
// not handle add the ip, which created in pod process, lsp created before ip
173-
lsp, err := c.OVNNbClient.GetLogicalSwitchPort(portName, true)
174-
if err != nil {
175-
klog.Errorf("failed to list logical switch ports %s, %v", portName, err)
176-
return err
177-
}
178-
if lsp != nil {
179-
// port already exists means the ip already created
180-
klog.V(3).Infof("ip %s is ready", portName)
181-
return nil
182-
}
183-
184158
// v6 ip address can not use upper case
185159
if util.ContainsUppercase(ip.Spec.V6IPAddress) {
186160
err := fmt.Errorf("ip %s v6 ip address %s can not contain upper case", ip.Name, ip.Spec.V6IPAddress)
@@ -220,6 +194,14 @@ func (c *Controller) handleAddReservedIP(key string) error {
220194
return err
221195
}
222196
}
197+
198+
klog.V(3).Infof("enqueue update status subnet %s", ip.Spec.Subnet)
199+
c.updateSubnetStatusQueue.Add(ip.Spec.Subnet)
200+
for _, as := range ip.Spec.AttachSubnets {
201+
klog.V(3).Infof("enqueue update attach status for subnet %s", as)
202+
c.updateSubnetStatusQueue.Add(as)
203+
}
204+
223205
return nil
224206
}
225207

0 commit comments

Comments
 (0)