fix: add error handler if we max out our retries
This commit is contained in:
parent
c1915321e1
commit
dc9b3b4fda
|
@ -3,7 +3,9 @@ package renter
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"git.lumeweb.com/LumeWeb/portal/cron"
|
"git.lumeweb.com/LumeWeb/portal/cron"
|
||||||
|
"github.com/google/uuid"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
rhpv2 "go.sia.tech/core/rhp/v2"
|
rhpv2 "go.sia.tech/core/rhp/v2"
|
||||||
"go.sia.tech/renterd/api"
|
"go.sia.tech/renterd/api"
|
||||||
|
@ -167,7 +169,8 @@ func (r *RenterDefault) MultipartUpload(params MultiPartUploadParams) error {
|
||||||
if end > size {
|
if end > size {
|
||||||
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{
|
job := r.cron.RetryableTask(cron.RetryableTaskParams{
|
||||||
Name: fileName + "-part-" + strconv.FormatUint(i, 10),
|
Name: fileName + "-part-" + strconv.FormatUint(i, 10),
|
||||||
|
@ -189,10 +192,16 @@ func (r *RenterDefault) MultipartUpload(params MultiPartUploadParams) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
next <- struct{}{}
|
nextChan <- struct{}{}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
Limit: 10,
|
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)
|
_, err = r.cron.CreateJob(job)
|
||||||
|
@ -205,7 +214,12 @@ func (r *RenterDefault) MultipartUpload(params MultiPartUploadParams) error {
|
||||||
PartNumber: int(i),
|
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)
|
_, err = r.busClient.CompleteMultipartUpload(ctx, bucket, fileName, upload.UploadID, uploadParts)
|
||||||
|
|
Loading…
Reference in New Issue