Skip to content

Commit

Permalink
update usingips check when update finalizer for subnet
Browse files Browse the repository at this point in the history
  • Loading branch information
hongzhen-ma committed Mar 22, 2021
1 parent 27fd210 commit 24095d7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/controller/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,13 @@ func (c *Controller) handleSubnetFinalizer(subnet *kubeovnv1.Subnet) (bool, erro
return false, nil
}

if !subnet.DeletionTimestamp.IsZero() && subnet.Status.UsingIPs == 0 {
var usingIps float64
if util.CheckProtocol(subnet.Spec.CIDRBlock) == kubeovnv1.ProtocolIPv6 {
usingIps = subnet.Status.V6UsingIPs
} else {
usingIps = subnet.Status.V4UsingIPs
}
if !subnet.DeletionTimestamp.IsZero() && usingIps == 0 {
subnet.Finalizers = util.RemoveString(subnet.Finalizers, util.ControllerName)
if _, err := c.config.KubeOvnClient.KubeovnV1().Subnets().Update(context.Background(), subnet, metav1.UpdateOptions{}); err != nil {
klog.Errorf("failed to remove finalizer from subnet %s, %v", subnet.Name, err)
Expand Down

0 comments on commit 24095d7

Please sign in to comment.