Skip to content

Commit afef79d

Browse files
Add exponential backoff
1 parent 975979c commit afef79d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

sysdig/internal/client/v2/client.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"net/http"
1313
"net/http/httputil"
1414
"strings"
15+
"time"
1516

1617
"github.com/draios/terraform-provider-sysdig/buildinfo"
1718
"github.com/hashicorp/go-retryablehttp"
@@ -186,8 +187,12 @@ func newHTTPClient(cfg *config) *http.Client {
186187
transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: cfg.insecure}
187188
httpClient.HTTPClient = &http.Client{Transport: transport}
188189

189-
// Configure retry logic for 409 Conflict errors
190+
// Configure retry logic for 409 Conflict errors with exponential backoff
190191
httpClient.RetryMax = 5
192+
httpClient.RetryWaitMin = 1 * time.Second
193+
httpClient.RetryWaitMax = 30 * time.Second
194+
httpClient.Backoff = retryablehttp.DefaultBackoff // Exponential backoff strategy
195+
191196
httpClient.CheckRetry = func(ctx context.Context, resp *http.Response, err error) (bool, error) {
192197
// Use default retry logic for connection errors and 5xx
193198
shouldRetry, checkErr := retryablehttp.DefaultRetryPolicy(ctx, resp, err)

0 commit comments

Comments
 (0)