Skip to content

Commit 3ec2c8b

Browse files
committed
Add exponential backoff and retries to destinationRequest loop
1 parent c4fad97 commit 3ec2c8b

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

pkg/runner/chunk_runner.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -647,16 +647,24 @@ func (r *ChunkRunner) process(continues <-chan struct{}, chunk *v1alpha1.Chunk)
647647
i := i
648648
dr := drs[i]
649649
g.Go(func() error {
650-
etag, retry, err := r.destinationRequest(ctx, &dest, dr, contentLength)
651-
if err != nil {
652-
if !retry {
653-
return err
650+
var err error
651+
var etag string
652+
var retry bool
653+
waitTime := 5 * time.Second
654+
655+
for i := 0; i < 5; i++ {
656+
etag, retry, err = r.destinationRequest(ctx, &dest, dr, contentLength)
657+
if err == nil {
658+
break
654659
}
655-
time.Sleep(time.Second)
656-
etag, _, err = r.destinationRequest(ctx, &dest, dr, contentLength)
657-
if err != nil {
660+
if !retry {
658661
return err
659662
}
663+
time.Sleep(waitTime)
664+
waitTime *= 2
665+
}
666+
if err != nil {
667+
return err
660668
}
661669
etags[i] = etag
662670
return nil

0 commit comments

Comments
 (0)