From dc9b3b4fdafa21b43a5491ca9c997c3af895ba9c Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Thu, 1 Feb 2024 19:26:23 -0500 Subject: [PATCH] fix: add error handler if we max out our retries --- renter/renter.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/renter/renter.go b/renter/renter.go index 2e7a8e7..e50bb0d 100644 --- a/renter/renter.go +++ b/renter/renter.go @@ -3,7 +3,9 @@ package renter import ( "context" "errors" + "fmt" "git.lumeweb.com/LumeWeb/portal/cron" + "github.com/google/uuid" "github.com/spf13/viper" rhpv2 "go.sia.tech/core/rhp/v2" "go.sia.tech/renterd/api" @@ -167,7 +169,8 @@ func (r *RenterDefault) MultipartUpload(params MultiPartUploadParams) error { if end > size { end = size } - next := make(chan struct{}, 0) + nextChan := make(chan struct{}, 0) + errChan := make(chan error, 0) job := r.cron.RetryableTask(cron.RetryableTaskParams{ Name: fileName + "-part-" + strconv.FormatUint(i, 10), @@ -189,10 +192,16 @@ func (r *RenterDefault) MultipartUpload(params MultiPartUploadParams) error { return err } - next <- struct{}{} + nextChan <- struct{}{} return nil }, Limit: 10, + Error: func(jobID uuid.UUID, jobName string, err error) { + if errors.Is(err, cron.ErrRetryLimitReached) { + r.logger.Error("failed to upload part", zap.String("jobName", jobName), zap.Error(err)) + errChan <- err + } + }, }) _, err = r.cron.CreateJob(job) @@ -205,7 +214,12 @@ func (r *RenterDefault) MultipartUpload(params MultiPartUploadParams) error { PartNumber: int(i), } - <-next + select { + case err = <-errChan: + return fmt.Errorf("failed to upload part %d: %s", i, err.Error()) + case <-nextChan: + } + } _, err = r.busClient.CompleteMultipartUpload(ctx, bucket, fileName, upload.UploadID, uploadParts)