Skip to content

Commit 6499e2f

Browse files
author
Marcelo Guerrero
committed
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>
1 parent 35831f3 commit 6499e2f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

plugins/meta/vrf/vrf.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,9 @@ CONTINUE:
154154
}
155155

156156
// Waits for global IPV6 addresses to be added by the kernel.
157-
maxRetry := 10
158-
for {
157+
backoffBase := 10 * time.Millisecond
158+
maxRetries := 8
159+
for retryCount := 0; retryCount <= maxRetries; retryCount++ {
159160
routesVRFTable, err := netlink.RouteListFiltered(
160161
netlink.FAMILY_ALL,
161162
&netlink.Route{
@@ -176,12 +177,13 @@ CONTINUE:
176177
break
177178
}
178179

179-
maxRetry--
180-
if maxRetry <= 0 {
180+
if retryCount == maxRetries {
181181
return fmt.Errorf("failed getting local/host addresses for %s in table %d with dst %s", intf, vrf.Table, toFind.IPNet.String())
182182
}
183183

184-
time.Sleep(10 * time.Millisecond)
184+
// Exponential backoff - 10ms, 20m, 40ms, 80ms, 160ms, 320ms, 640ms, 1280ms
185+
// Approx 2,5 seconds total
186+
time.Sleep(backoffBase * time.Duration(1<<retryCount))
185187
}
186188
}
187189

0 commit comments

Comments
 (0)