From d24c5131324ef1139aa61bedbe65d98fe30fc870 Mon Sep 17 00:00:00 2001 From: hzma Date: Thu, 18 Aug 2022 14:36:40 +0800 Subject: [PATCH] update centralized subnet gateway ready patch operation (#1827) --- pkg/controller/subnet.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/pkg/controller/subnet.go b/pkg/controller/subnet.go index 15048523815..226d2206d23 100644 --- a/pkg/controller/subnet.go +++ b/pkg/controller/subnet.go @@ -456,7 +456,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, "") } } @@ -1262,7 +1262,7 @@ func (c *Controller) reconcileOvnRoute(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) @@ -1272,14 +1272,7 @@ func (c *Controller) reconcileOvnRoute(subnet *kubeovnv1.Subnet) error { } subnet.Status.ActivateGateway = newActivateNode - subnet.Status.Ready("ReconcileCentralizedGatewaySuccess", "") - bytes, err := subnet.Status.Bytes() - if err != nil { - return err - } - if _, err := c.config.KubeOvnClient.KubeovnV1().Subnets().Patch(context.Background(), subnet.Name, types.MergePatchType, bytes, metav1.PatchOptions{}, "status"); err != nil { - return err - } + c.patchSubnetStatus(subnet, "ReconcileCentralizedGatewaySuccess", "") } if err := c.deletePolicyRouteByGatewayType(subnet, kubeovnv1.GWDistributedType, false); err != nil {