Skip to content

Commit

Permalink
change subnet check using ip location to avoid ipam init err
Browse files Browse the repository at this point in the history
Signed-off-by: bobz965 <[email protected]>
  • Loading branch information
zbb88888 committed Apr 30, 2024
1 parent dd9a25d commit 9c8acd5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
5 changes: 4 additions & 1 deletion pkg/controller/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,6 @@ func (c *Controller) createOrUpdateIPCR(ipCRName, podName, ip, mac, subnetName,
klog.Errorf("failed to handle add ip finalizer %v", err)
return err
}

return nil
}

Expand All @@ -566,6 +565,10 @@ func (c *Controller) subnetCountIP(subnet *kubeovnv1.Subnet) error {
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 nil
}

Expand Down
32 changes: 18 additions & 14 deletions pkg/controller/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,11 @@ func (c *Controller) handleAddOrUpdateSubnet(key string) error {
return err
}

if err := c.checkSubnetUsingIPs(subnet); err != nil {
klog.Errorf("inconsistency detected in status of subnet %s : %v", subnet.Name, err)
return err
}

deleted, err := c.handleSubnetFinalizer(subnet)
if err != nil {
klog.Errorf("handle subnet finalizer failed %v", err)
Expand Down Expand Up @@ -947,10 +952,15 @@ func (c *Controller) handleUpdateSubnetStatus(key string) error {
klog.Error(err)
return err
}
return nil
} else {
if _, err = c.calcSubnetStatusIP(subnet); err != nil {
klog.Error(err)
return err
}
}
if _, err = c.calcSubnetStatusIP(subnet); err != nil {
klog.Error(err)

if err := c.checkSubnetUsingIPs(subnet); err != nil {
klog.Errorf("inconsistency detected in status of subnet %s : %v", subnet.Name, err)
return err
}
return nil
Expand Down Expand Up @@ -1970,6 +1980,11 @@ func (c *Controller) reconcileU2OInterconnectionIP(subnet *kubeovnv1.Subnet) err
}
}
}

if err := c.checkSubnetUsingIPs(subnet); err != nil {
klog.Errorf("inconsistency detected in status of subnet %s : %v", subnet.Name, err)
return err
}
return nil
}

Expand Down Expand Up @@ -2085,12 +2100,6 @@ func (c *Controller) calcDualSubnetStatusIP(subnet *kubeovnv1.Subnet) (*kubeovnv
subnet.Status.V6UsingIPRange = v6UsingIPStr
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 nil, err
}

bytes, err := subnet.Status.Bytes()
if err != nil {
klog.Error(err)
Expand Down Expand Up @@ -2221,11 +2230,6 @@ func (c *Controller) calcSubnetStatusIP(subnet *kubeovnv1.Subnet) (*kubeovnv1.Su
return subnet, nil
}

if err := c.checkSubnetUsingIPs(subnet); err != nil {
klog.Errorf("inconsistency detected in status of subnet %s : %v", subnet.Name, err)
return nil, err
}

bytes, err := subnet.Status.Bytes()
if err != nil {
klog.Error(err)
Expand Down

0 comments on commit 9c8acd5

Please sign in to comment.