From 122754aa5a677d6fc42c0fccbd00f5d92c07b247 Mon Sep 17 00:00:00 2001 From: hzma Date: Thu, 18 Aug 2022 13:16:16 +0800 Subject: [PATCH] update centralized subnet gateway ready patch operation --- pkg/controller/subnet.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) 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