From c12c5722704d804106322ba2150ab5f814fe67ba Mon Sep 17 00:00:00 2001 From: changluyi <47097611+changluyi@users.noreply.github.com> Date: Mon, 8 Jul 2024 10:45:50 +0800 Subject: [PATCH] fix invalid subnet not sync route (#4262) Signed-off-by: clyi Conflicts: pkg/daemon/controller_linux.go --- pkg/controller/subnet.go | 6 +++++- pkg/daemon/controller_linux.go | 2 +- pkg/daemon/controller_windows.go | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/controller/subnet.go b/pkg/controller/subnet.go index 5fff022cb26..c63641e5271 100644 --- a/pkg/controller/subnet.go +++ b/pkg/controller/subnet.go @@ -514,7 +514,11 @@ func (c *Controller) handleSubnetFinalizer(subnet *kubeovnv1.Subnet) (bool, erro func (c Controller) patchSubnetStatus(subnet *kubeovnv1.Subnet, reason, errStr string) { if errStr != "" { subnet.Status.SetError(reason, errStr) - subnet.Status.NotValidated(reason, errStr) + if reason == "ValidateLogicalSwitchFailed" { + subnet.Status.NotValidated(reason, errStr) + } else { + subnet.Status.Validated(reason, "") + } subnet.Status.NotReady(reason, errStr) c.recorder.Eventf(subnet, v1.EventTypeWarning, reason, errStr) } else { diff --git a/pkg/daemon/controller_linux.go b/pkg/daemon/controller_linux.go index 6784a46878f..5e7a7fb321d 100644 --- a/pkg/daemon/controller_linux.go +++ b/pkg/daemon/controller_linux.go @@ -279,7 +279,7 @@ func (c *Controller) reconcileRouters(event *subnetEvent) error { for _, subnet := range subnets { // The route for overlay subnet cidr via ovn0 should not be deleted even though subnet.Status has changed to not ready if (subnet.Spec.Vlan != "" && !subnet.Spec.LogicalGateway) || subnet.Spec.Vpc != c.config.ClusterRouter || - (subnet.Name != c.config.NodeSwitch && !subnet.Status.IsReady()) { + !subnet.Status.IsValidated() { continue } diff --git a/pkg/daemon/controller_windows.go b/pkg/daemon/controller_windows.go index b00b2b0597d..b5cdd9e436f 100644 --- a/pkg/daemon/controller_windows.go +++ b/pkg/daemon/controller_windows.go @@ -56,7 +56,7 @@ func (c *Controller) reconcileRouters(_ *subnetEvent) error { // The route for overlay subnet cidr via ovn0 should not be deleted even though subnet.Status has changed to not ready if (subnet.Spec.Vlan != "" && !subnet.Spec.LogicalGateway) || subnet.Spec.Vpc != c.config.ClusterRouter || - (subnet.Name != c.config.NodeSwitch && !subnet.Status.IsReady()) { + !subnet.Status.IsValidated() { continue }