diff --git a/pkg/controller/subnet.go b/pkg/controller/subnet.go index a805f99eb4e..0f6a0d2b44f 100644 --- a/pkg/controller/subnet.go +++ b/pkg/controller/subnet.go @@ -411,7 +411,7 @@ func (c Controller) patchSubnetStatus(subnet *kubeovnv1.Subnet, reason string, e c.recorder.Eventf(subnet, v1.EventTypeWarning, reason, errStr) } else { subnet.Status.Validated(reason, "") - if reason == "SetPrivateLogicalSwitchSuccess" || reason == "ResetLogicalSwitchAclSuccess" { + if reason == "SetPrivateLogicalSwitchSuccess" || reason == "ResetLogicalSwitchAclSuccess" || reason == "ReconcileCentralizedGatewaySuccess" { subnet.Status.Ready(reason, "") } } @@ -979,7 +979,7 @@ func (c *Controller) reconcileGateway(subnet *kubeovnv1.Subnet) error { if _, err = c.config.KubeOvnClient.KubeovnV1().Subnets().Patch(context.Background(), subnet.Name, types.MergePatchType, bytes, metav1.PatchOptions{}, "status"); err != nil { klog.Errorf("failed to patch subnet %s NoReadyGateway status: %v", subnet.Name, err) } - return fmt.Errorf("all subnet %s gws are not ready", subnet.Name) + return err } nextHop := getNextHopByTunnelIP(nodeTunlIPAddr) @@ -998,13 +998,7 @@ func (c *Controller) reconcileGateway(subnet *kubeovnv1.Subnet) error { } } - bytes, err := subnet.Status.Bytes() - subnet.Status.Ready("ReconcileCentralizedGatewaySuccess", "") - if err != nil { - return err - } - _, err = c.config.KubeOvnClient.KubeovnV1().Subnets().Patch(context.Background(), subnet.Name, types.MergePatchType, bytes, metav1.PatchOptions{}, "status") - return err + c.patchSubnetStatus(subnet, "ReconcileCentralizedGatewaySuccess", "") } } return nil