From d1951085b2cfe487cabdf7f7671afc13989be1fe Mon Sep 17 00:00:00 2001 From: bobz965 Date: Tue, 28 Nov 2023 15:00:35 +0800 Subject: [PATCH] fix iptables eip Signed-off-by: bobz965 --- pkg/controller/vpc_nat_gw_eip.go | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/pkg/controller/vpc_nat_gw_eip.go b/pkg/controller/vpc_nat_gw_eip.go index 3fd332e498a9..aad88f78c56c 100644 --- a/pkg/controller/vpc_nat_gw_eip.go +++ b/pkg/controller/vpc_nat_gw_eip.go @@ -296,7 +296,7 @@ func (c *Controller) handleUpdateIptablesEip(key string) error { externalNetwork := util.GetExternalNetwork(cachedEip.Spec.ExternalSubnet) // should delete if !cachedEip.DeletionTimestamp.IsZero() { - klog.V(3).Infof("clean eip '%s' in pod", key) + klog.Infof("clean eip %q in pod", key) v4Cidr, err := c.getEipV4Cidr(cachedEip.Status.IP, externalNetwork) if err != nil { klog.Errorf("failed to clean eip %s, %v", key, err) @@ -314,6 +314,11 @@ func (c *Controller) handleUpdateIptablesEip(key string) error { return err } } + if err = c.handleDelIptablesEipFinalizer(key); err != nil { + klog.Errorf("failed to handle del finalizer for eip %s, %v", key, err) + return err + } + c.ipam.ReleaseAddressByPod(key, cachedEip.Spec.ExternalSubnet) return nil } klog.Infof("handle update eip %s", key) @@ -397,19 +402,6 @@ func (c *Controller) handleUpdateIptablesEip(key string) error { func (c *Controller) handleDelIptablesEip(key string) error { klog.Infof("handle delete iptables eip %s", key) - eip, err := c.iptablesEipsLister.Get(key) - if err != nil { - if k8serrors.IsNotFound(err) { - return nil - } - klog.Error(err) - return err - } - if err = c.handleDelIptablesEipFinalizer(key); err != nil { - klog.Errorf("failed to handle del finalizer for eip %s, %v", key, err) - return err - } - c.ipam.ReleaseAddressByPod(key, eip.Spec.ExternalSubnet) return nil }