From f859b730dadd19663388da3f06f861cf258d4814 Mon Sep 17 00:00:00 2001 From: Marcelo Guerrero Date: Fri, 28 Mar 2025 18:21:36 +0100 Subject: [PATCH] Implement exponential backoff in vrf plugin The current max waiting time for global IPV6 addresses to be present in the kernel after reinserting them is not sufficient for all use cases. SRIOV + VRF takes around 1.2s. These changes increase the maximum waiting time to approximately 2.5s. An exponential backoff is implemented to reduce cpu overload. Signed-off-by: Marcelo Guerrero --- plugins/meta/vrf/vrf.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/meta/vrf/vrf.go b/plugins/meta/vrf/vrf.go index fb1ff92a..226e5c67 100644 --- a/plugins/meta/vrf/vrf.go +++ b/plugins/meta/vrf/vrf.go @@ -156,8 +156,9 @@ CONTINUE: } // Waits for global IPV6 addresses to be added by the kernel. - maxRetry := 10 - for { + backoffBase := 10 * time.Millisecond + maxRetries := 8 + for retryCount := 0; retryCount <= maxRetries; retryCount++ { routesVRFTable, err := netlinksafe.RouteListFiltered( netlink.FAMILY_ALL, &netlink.Route{ @@ -178,12 +179,13 @@ CONTINUE: break } - maxRetry-- - if maxRetry <= 0 { + if retryCount == maxRetries { return fmt.Errorf("failed getting local/host addresses for %s in table %d with dst %s", intf, vrf.Table, toFind.IPNet.String()) } - time.Sleep(10 * time.Millisecond) + // Exponential backoff - 10ms, 20m, 40ms, 80ms, 160ms, 320ms, 640ms, 1280ms + // Approx 2,5 seconds total + time.Sleep(backoffBase * time.Duration(1<