From d99e8561e8432292613434b1a1f0cf4e96804f3a Mon Sep 17 00:00:00 2001 From: Hongliang Liu Date: Wed, 25 May 2022 14:16:24 +0800 Subject: [PATCH] Fix error loop caused by failure to delete a non-existing route When a LoadBalancer with ingress IP is created, corresponding route for the ingress IP is also installed. When deleting the LoadBalancer, corresponding route should be also uninstalled. Before uninstalling the route, if the route is removed, then deleting the route will get a failure and return an error. The error will trigger LoadBalancer deletion again, and obviously, deleting the route will get a failure and return an error another time, resulting in an error loop. This PR fixes error loop by printing log instead of returning error when getting the error "no such process" (such error means that the route expected to be deleted doesn't exist). Signed-off-by: Hongliang Liu --- pkg/agent/route/route_linux.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/agent/route/route_linux.go b/pkg/agent/route/route_linux.go index d1bd9782d45..f77edb1ec75 100644 --- a/pkg/agent/route/route_linux.go +++ b/pkg/agent/route/route_linux.go @@ -1298,7 +1298,11 @@ func (c *Client) deleteLoadBalancerIngressIPRoute(svcIPStr string) error { route := generateRoute(svcIP, mask, gw, linkIndex, netlink.SCOPE_UNIVERSE) if err := netlink.RouteDel(route); err != nil { - return fmt.Errorf("failed to delete routing entry for LoadBalancer ingress IP %s: %w", svcIP.String(), err) + if err.Error() == "no such process" { + klog.InfoS("Failed to delete LoadBalancer ingress IP route since the route has been deleted", "route", route) + } else { + return fmt.Errorf("failed to delete routing entry for LoadBalancer ingress IP %s: %w", svcIP.String(), err) + } } klog.V(4).InfoS("Deleted LoadBalancer ingress IP route", "route", route) c.serviceRoutes.Delete(svcIP.String())