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", "")