Skip to content
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions sysdig/internal/client/v2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,23 @@ func newHTTPClient(cfg *config) *http.Client {
transport := http.DefaultTransport.(*http.Transport).Clone()
transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: cfg.insecure}
httpClient.HTTPClient = &http.Client{Transport: transport}

// Configure retry logic for 409 Conflict errors
httpClient.RetryMax = 5
httpClient.CheckRetry = func(ctx context.Context, resp *http.Response, err error) (bool, error) {
// Use default retry logic for connection errors and 5xx
shouldRetry, checkErr := retryablehttp.DefaultRetryPolicy(ctx, resp, err)
if shouldRetry || checkErr != nil {
return shouldRetry, checkErr
}

// Additionally retry on 409 Conflict
if resp != nil && resp.StatusCode == http.StatusConflict {
return true, nil
}

return false, nil
}

return httpClient.StandardClient()
}
Loading