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 <marguerr@redhat.com>
This commit is contained in:
Marcelo Guerrero
2025-03-28 18:21:36 +01:00
committed by Casey Callendrello
parent 062b3fceb4
commit f859b730da

View File

@@ -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<<retryCount))
}
}