Skip to content

Commit c20d9c0

Browse files
authored
Fix dcl upload max retries (#68)
1 parent 3446efa commit c20d9c0

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

pkg/uploader/uploader.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,19 @@ func (up *Uploader) Do(ctx context.Context, dstURL string) error {
6363
return up.logResponse(resp, u.String())
6464
}
6565

66-
const maxRetries = 9
67-
68-
var RetryPeriod = 10 * time.Second
66+
const maxRetries = 12 // max 3min
67+
var RetryPeriod = 15 * time.Second
6968

7069
func (up *Uploader) DoWithRetries(ctx context.Context, dstURL string, body []byte, maxRetries int) (*http.Response, error) {
7170
resp, err := up.do(ctx, dstURL, body)
7271
if err != nil {
7372
return nil, fmt.Errorf("DCL upload request unsuccessful: %w", err)
7473
}
75-
retries := 0
76-
for resp.StatusCode == http.StatusUnauthorized && retries < maxRetries {
74+
for retries := 0; resp.StatusCode == http.StatusUnauthorized && retries < maxRetries; retries++ {
7775
if err := drainResponseBody(resp.Body); err != nil {
7876
return nil, fmt.Errorf("cannot drain response body: %w", err)
7977
}
80-
up.Log.Info("certificate is not accepted (yet), retrying after %s...", RetryPeriod.String())
78+
up.Log.Info("certificate is not accepted (yet), retrying after %s...", RetryPeriod.String())
8179
time.Sleep(RetryPeriod)
8280
resp, err = up.do(ctx, dstURL, body)
8381
if err != nil {

0 commit comments

Comments
 (0)