Skip to content

Commit

Permalink
add more informative error message for s3->CopyObject
Browse files Browse the repository at this point in the history
  • Loading branch information
Slach committed Jul 13, 2024
1 parent 7cfccdc commit 9de0176
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/storage/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ func (s *S3) CopyObject(ctx context.Context, srcSize int64, srcBucket, srcKey, d
s.enrichCopyObjectParams(params)
_, err := s.client.CopyObject(ctx, params)
if err != nil {
return 0, err
return 0, fmt.Errorf("S3->CopyObject %s/%s -> %s/%s return error: %v", srcBucket, srcKey, s.Config.Bucket, dstKey, err)
}
return srcSize, nil
}
Expand All @@ -491,7 +491,7 @@ func (s *S3) CopyObject(ctx context.Context, srcSize int64, srcBucket, srcKey, d
s.enrichCreateMultipartUploadParams(createMultipartUploadParams)
initResp, err := s.client.CreateMultipartUpload(ctx, createMultipartUploadParams)
if err != nil {
return 0, err
return 0, fmt.Errorf("S3->CopyObject %s/%s -> %s/%s, CreateMultipartUpload return error: %v", srcBucket, srcKey, s.Config.Bucket, dstKey, err)
}

// Get the upload ID
Expand Down Expand Up @@ -545,7 +545,7 @@ func (s *S3) CopyObject(ctx context.Context, srcSize int64, srcBucket, srcKey, d
}
partResp, err := s.client.UploadPartCopy(ctx, uploadPartParams)
if err != nil {
return err
return fmt.Errorf("S3->CopyObject %s/%s -> %s/%s, UploadPartCopy start=%d, end=%d return error: %v", srcBucket, srcKey, s.Config.Bucket, dstKey, start, end-1, err)
}
mu.Lock()
parts = append(parts, s3types.CompletedPart{
Expand Down Expand Up @@ -573,7 +573,7 @@ func (s *S3) CopyObject(ctx context.Context, srcSize int64, srcBucket, srcKey, d
if abortErr != nil {
return 0, fmt.Errorf("aborting CopyObject multipart upload: %v, original error was: %v", abortErr, wgWaitErr)
}
return 0, fmt.Errorf("one of CopyObject go-routine return error: %v", wgWaitErr)
return 0, fmt.Errorf("one of CopyObject/Multipart go-routine return error: %v", wgWaitErr)
}
// Parts must be ordered by part number.
sort.Slice(parts, func(i int, j int) bool {
Expand Down

0 comments on commit 9de0176

Please sign in to comment.