From 55e38bb57056736324078f27f6281d8c295640aa Mon Sep 17 00:00:00 2001 From: Job Stoit Date: Fri, 26 Apr 2024 22:13:03 +0200 Subject: [PATCH] fix: add reader get part retries --- feature/s3/manager/reader.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/feature/s3/manager/reader.go b/feature/s3/manager/reader.go index edc5d6ee5ad..51eb6e95926 100644 --- a/feature/s3/manager/reader.go +++ b/feature/s3/manager/reader.go @@ -23,6 +23,7 @@ type ObjectReader struct { chunkSize int64 concurrency int clientOptions []func(*s3.Options) + partRetries int input *s3.GetObjectInput } @@ -34,6 +35,7 @@ func (d *Downloader) NewReader(ctx context.Context, input *s3.GetObjectInput) io input: input, chunkSize: d.PartSize, concurrency: d.Concurrency, + partRetries: d.PartBodyMaxRetries, clientOptions: d.ClientOptions, } @@ -176,5 +178,14 @@ func (r *ObjectReader) getObject(ctx context.Context, start, end int64) (*s3.Get copyInput := *r.input copyInput.Range = &byteRange - return r.s3.GetObject(ctx, ©Input, r.clientOptions...) + var output *s3.GetObjectOutput + var err error + for i := 0; i < r.partRetries; i++ { + output, err = r.s3.GetObject(ctx, ©Input, r.clientOptions...) + if err == nil { + return output, nil + } + } + + return output, err }