Skip to content

Commit f859b73

Browse files
Marcelo Guerrerosqueed
authored andcommitted
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 062b3fc commit f859b73

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
@@ -156,8 +156,9 @@ CONTINUE:
156156
}
157157

158158
// Waits for global IPV6 addresses to be added by the kernel.
159-
maxRetry := 10
160-
for {
159+
backoffBase := 10 * time.Millisecond
160+
maxRetries := 8
161+
for retryCount := 0; retryCount <= maxRetries; retryCount++ {
161162
routesVRFTable, err := netlinksafe.RouteListFiltered(
162163
netlink.FAMILY_ALL,
163164
&netlink.Route{
@@ -178,12 +179,13 @@ CONTINUE:
178179
break
179180
}
180181

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

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

0 commit comments

Comments
 (0)