From c6fefd4c18b18e48d4c34d4b0b09af4cb6793873 Mon Sep 17 00:00:00 2001 From: bobz965 Date: Sat, 23 Dec 2023 10:19:13 +0800 Subject: [PATCH] fix: calculate usings before removed finalizer (#3570) Signed-off-by: bobz965 --- pkg/controller/subnet.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/pkg/controller/subnet.go b/pkg/controller/subnet.go index 0d495eaa098..62b156207c2 100644 --- a/pkg/controller/subnet.go +++ b/pkg/controller/subnet.go @@ -708,7 +708,6 @@ func (c *Controller) handleAddOrUpdateSubnet(key string) error { return err } klog.V(3).Infof("handle add or update subnet %s", cachedSubnet.Name) - subnet := cachedSubnet.DeepCopy() subnet, err = c.formatSubnet(subnet) if err != nil { @@ -716,15 +715,6 @@ func (c *Controller) handleAddOrUpdateSubnet(key string) error { return err } - deleted, err := c.handleSubnetFinalizer(subnet) - if err != nil { - klog.Errorf("handle subnet finalizer failed %v", err) - return err - } - if deleted { - return nil - } - if err = util.ValidateSubnet(*subnet); err != nil { klog.Errorf("failed to validate subnet %s, %v", subnet.Name, err) c.patchSubnetStatus(subnet, "ValidateLogicalSwitchFailed", err.Error()) @@ -747,6 +737,15 @@ func (c *Controller) handleAddOrUpdateSubnet(key string) error { return err } + deleted, err := c.handleSubnetFinalizer(subnet) + if err != nil { + klog.Errorf("handle subnet finalizer failed %v", err) + return err + } + if deleted { + return nil + } + if !isOvnSubnet(subnet) { // subnet provider is not ovn, and vpc is empty, should not reconcile c.patchSubnetStatus(subnet, "SetNonOvnSubnetSuccess", "")