diff --git a/pkg/controller/subnet.go b/pkg/controller/subnet.go index 6391deacc70..5e03ab56ea5 100644 --- a/pkg/controller/subnet.go +++ b/pkg/controller/subnet.go @@ -890,9 +890,19 @@ func (c *Controller) handleUpdateSubnetStatus(key string) error { } if util.CheckProtocol(subnet.Spec.CIDRBlock) == kubeovnv1.ProtocolDual { - return calcDualSubnetStatusIP(subnet, c) + err = calcDualSubnetStatusIP(subnet, c) + } else { + err = calcSubnetStatusIP(subnet, c) + } + if err != nil { + klog.Error(err) + return err + } + if err := c.checkSubnetUsingIPs(subnet); err != nil { + klog.Errorf("inconsistency detected in status of subnet %s : %v", subnet.Name, err) + return err } - return calcSubnetStatusIP(subnet, c) + return nil } func (c *Controller) handleDeleteLogicalSwitch(key string) (err error) { @@ -2073,11 +2083,6 @@ func calcDualSubnetStatusIP(subnet *kubeovnv1.Subnet, c *Controller) error { subnet.Status.V4AvailableIPRange = v4AvailableIPStr subnet.Status.V6AvailableIPRange = v6AvailableIPStr - if err := c.checkSubnetUsingIPs(subnet); err != nil { - klog.Errorf("inconsistency detected in status of subnet %s : %v", subnet.Name, err) - return err - } - bytes, err := subnet.Status.Bytes() if err != nil { klog.Error(err) @@ -2188,11 +2193,6 @@ func calcSubnetStatusIP(subnet *kubeovnv1.Subnet, c *Controller) error { return nil } - if err := c.checkSubnetUsingIPs(subnet); err != nil { - klog.Errorf("inconsistency detected in status of subnet %s : %v", subnet.Name, err) - return err - } - bytes, err := subnet.Status.Bytes() if err != nil { klog.Error(err)