From 269f460d72167ba5018a94e95788ccac9588ba37 Mon Sep 17 00:00:00 2001 From: bobz965 Date: Wed, 5 Jul 2023 13:41:23 +0800 Subject: [PATCH] fix vpc already delete while delete policy route (#3005) --- pkg/controller/subnet.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/controller/subnet.go b/pkg/controller/subnet.go index 45e5e74ae5f..c6456c22c40 100644 --- a/pkg/controller/subnet.go +++ b/pkg/controller/subnet.go @@ -2532,6 +2532,11 @@ func (c *Controller) addPolicyRouteForU2OInterconn(subnet *kubeovnv1.Subnet) err } func (c *Controller) deletePolicyRouteForU2OInterconn(subnet *kubeovnv1.Subnet) error { + logicalRouter, err := c.ovnClient.GetLogicalRouter(subnet.Spec.Vpc, true) + if err == nil && logicalRouter == nil { + klog.Infof("logical router %s already deleted", subnet.Spec.Vpc) + return nil + } policies, err := c.ovnClient.ListLogicalRouterPolicies(subnet.Spec.Vpc, -1, map[string]string{ "isU2ORoutePolicy": "true", "vendor": util.CniTypeName, @@ -2608,7 +2613,11 @@ func (c *Controller) addCustomVPCPolicyRoutesForSubnet(subnet *kubeovnv1.Subnet) } func (c *Controller) deleteCustomVPCPolicyRoutesForSubnet(subnet *kubeovnv1.Subnet) error { - + logicalRouter, err := c.ovnClient.GetLogicalRouter(subnet.Spec.Vpc, true) + if err == nil && logicalRouter == nil { + klog.Infof("logical router %s already deleted", subnet.Spec.Vpc) + return nil + } for _, cidr := range strings.Split(subnet.Spec.CIDRBlock, ",") { af := 4 if util.CheckProtocol(cidr) == kubeovnv1.ProtocolIPv6 {