diff --git a/pkg/controller/init.go b/pkg/controller/init.go index 511f626ec47..f44790bcfd1 100644 --- a/pkg/controller/init.go +++ b/pkg/controller/init.go @@ -575,6 +575,10 @@ func (c *Controller) syncIPCR() error { for _, ipCR := range ips { ip := ipCR.DeepCopy() + if ip.DeletionTimestamp != nil && util.ContainsString(ip.Finalizers, util.ControllerName) { + klog.Infof("enqueue update for deleting ip %s", ip.Name) + c.updateIPQueue.Add(ip.Name) + } changed := false if ipMap.Has(ip.Name) && ip.Spec.PodType == "" { ip.Spec.PodType = util.VM diff --git a/pkg/controller/ip.go b/pkg/controller/ip.go index d4307da7eba..0593accdb93 100644 --- a/pkg/controller/ip.go +++ b/pkg/controller/ip.go @@ -281,6 +281,7 @@ func (c *Controller) handleUpdateIP(key string) error { return err } if !cachedIP.DeletionTimestamp.IsZero() { + klog.Infof("handle deleting ip %s", cachedIP.Name) subnet, err := c.subnetsLister.Get(cachedIP.Spec.Subnet) if err != nil { klog.Errorf("failed to get subnet %s: %v", cachedIP.Spec.Subnet, err) @@ -321,8 +322,9 @@ func (c *Controller) handleUpdateIP(key string) error { } } if cleanIPAM { - klog.V(3).Infof("release ipam address %s for deleted ip %s from subnet %s", cachedIP.Spec.IPAddress, cachedIP.Name, cachedIP.Spec.Subnet) - c.ipam.ReleaseAddressByPod(cachedIP.Name, cachedIP.Spec.Subnet) + podKey := fmt.Sprintf("%s/%s", cachedIP.Spec.Namespace, cachedIP.Spec.PodName) + klog.Infof("ip cr %s release ipam pod key %s from subnet %s", cachedIP.Name, podKey, cachedIP.Spec.Subnet) + c.ipam.ReleaseAddressByPod(podKey, cachedIP.Spec.Subnet) } if err = c.handleDelIPFinalizer(cachedIP, util.ControllerName); err != nil { klog.Errorf("failed to handle del ip finalizer %v", err) @@ -333,7 +335,7 @@ func (c *Controller) handleUpdateIP(key string) error { } func (c *Controller) handleDelIP(ip *kubeovnv1.IP) error { - klog.V(3).Infof("handle delete ip %s from subnet %s", ip.Name, ip.Spec.Subnet) + klog.Infof("deleting ip %s enqueue update status subnet %s", ip.Name, ip.Spec.Subnet) c.updateSubnetStatusQueue.Add(ip.Spec.Subnet) for _, as := range ip.Spec.AttachSubnets { klog.V(3).Infof("enqueue update attach status for subnet %s", as)