[cli] Fix: Retry on all 5xx errors (#2094)

## Description

## Tests
This commit is contained in:
Neeraj Gupta
2024-06-11 11:59:14 +05:30
committed by GitHub
2 changed files with 8 additions and 5 deletions

View File

@@ -71,12 +71,15 @@ func NewClient(p Params) *Client {
restClient: enteAPI,
downloadClient: resty.New().
SetRetryCount(3).
SetRetryWaitTime(5 * time.Second).
SetRetryMaxWaitTime(10 * time.Second).
SetRetryWaitTime(10 * time.Second).
SetRetryMaxWaitTime(20 * time.Second).
AddRetryCondition(func(r *resty.Response, err error) bool {
shouldRetry := r.StatusCode() == 429 || r.StatusCode() > 500
shouldRetry := r.StatusCode() == 429 || r.StatusCode() >= 500
if shouldRetry {
log.Printf("retrying download due to %d code", r.StatusCode())
amxRequestID := r.Header().Get("X-Amz-Request-Id")
cfRayID := r.Header().Get("CF-Ray")
wasabiRefID := r.Header().Get("X-Wasabi-Cm-Reference-Id")
log.Printf("Retry scheduled. error statusCode: %d, X-Amz-Request-Id: %s, CF-Ray: %s, X-Wasabi-Cm-Reference-Id: %s", r.StatusCode(), amxRequestID, cfRayID, wasabiRefID)
}
return shouldRetry
}),

View File

@@ -15,7 +15,7 @@ import (
"strings"
)
var AppVersion = "0.1.14"
var AppVersion = "0.1.15"
func main() {
cliDBPath, err := GetCLIConfigPath()