Skip to content

Commit d883fdd

Browse files
committed
make sure ip in subnet using range (#6005)
Signed-off-by: zbb88888 <jmdxjsjgcxy@gmail.com>
1 parent 68b9dce commit d883fdd

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

pkg/controller/vpc_nat_gw_eip.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,13 @@ func (c *Controller) enqueueUpdateIptablesEip(oldObj, newObj any) {
3838
klog.Infof("enqueue update iptables eip %s", key)
3939
c.updateIptablesEipQueue.Add(key)
4040
}
41-
externalNetwork := util.GetExternalNetwork(newEip.Spec.ExternalSubnet)
42-
c.updateSubnetStatusQueue.Add(externalNetwork)
41+
42+
// Trigger subnet status update when EIP CR is updated
43+
// This ensures both CR labels and IPAM state are synced before status calculation
44+
if oldEip.Status.IP != newEip.Status.IP || oldEip.Status.Ready != newEip.Status.Ready {
45+
externalNetwork := util.GetExternalNetwork(newEip.Spec.ExternalSubnet)
46+
c.updateSubnetStatusQueue.Add(externalNetwork)
47+
}
4348
}
4449

4550
func (c *Controller) enqueueDelIptablesEip(obj any) {
@@ -62,6 +67,9 @@ func (c *Controller) enqueueDelIptablesEip(obj any) {
6267
key := cache.MetaObjectToName(eip).String()
6368
klog.Infof("enqueue del iptables eip %s", key)
6469
c.delIptablesEipQueue.Add(key)
70+
71+
// Trigger subnet status update when EIP is deleted
72+
// This ensures subnet status reflects the IP release
6573
externalNetwork := util.GetExternalNetwork(eip.Spec.ExternalSubnet)
6674
c.updateSubnetStatusQueue.Add(externalNetwork)
6775
}
@@ -157,6 +165,7 @@ func (c *Controller) handleAddIptablesEip(key string) error {
157165
klog.Errorf("failed to update eip %s, %v", key, err)
158166
return err
159167
}
168+
160169
return nil
161170
}
162171

@@ -239,6 +248,7 @@ func (c *Controller) handleUpdateIptablesEip(key string) error {
239248
return err
240249
}
241250
c.ipam.ReleaseAddressByPod(key, cachedEip.Spec.ExternalSubnet)
251+
242252
return nil
243253
}
244254
klog.Infof("handle update eip %s", key)

0 commit comments

Comments
 (0)