Skip to content

Commit

Permalink
fix subnet check ip in using to avoid ipam init (#3964)
Browse files Browse the repository at this point in the history
Signed-off-by: bobz965 <zhangbingbing2_yewu@cmss.chinamobile.com>
  • Loading branch information
bobz965 committed Apr 30, 2024
1 parent 954df53 commit 8e962a0
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions pkg/controller/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8e962a0

Please sign in to comment.