Skip to content

Commit

Permalink
s3store fix incomplete part keys
Browse files Browse the repository at this point in the history
When using a different prefix for metadata files uploads break because the code sometimes uses `metadataKeyWithPrefix` when it should use `keyWithPrefix`.

Unless I understood something completely wrong and failed to understand what the debug session was trying to tell me ;-)
  • Loading branch information
butonic authored Dec 5, 2023
1 parent c856f72 commit 064ac79
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/s3store/s3store.go
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ func (store S3Store) downloadIncompletePartForUpload(ctx context.Context, upload
func (store S3Store) getIncompletePartForUpload(ctx context.Context, uploadId string) (*s3.GetObjectOutput, error) {
obj, err := store.Service.GetObject(ctx, &s3.GetObjectInput{
Bucket: aws.String(store.Bucket),
Key: store.metadataKeyWithPrefix(uploadId + ".part"),
Key: store.keyWithPrefix(uploadId + ".part"),
})

if err != nil && (isAwsError[*types.NoSuchKey](err) || isAwsError[*types.NotFound](err) || isAwsErrorCode(err, "AccessDenied")) || isAwsErrorCode(err, "Forbidden") {
Expand All @@ -1110,7 +1110,7 @@ func (store S3Store) headIncompletePartForUpload(ctx context.Context, uploadId s
t := time.Now()
obj, err := store.Service.HeadObject(ctx, &s3.HeadObjectInput{
Bucket: aws.String(store.Bucket),
Key: store.metadataKeyWithPrefix(uploadId + ".part"),
Key: store.keyWithPrefix(uploadId + ".part"),
})
store.observeRequestDuration(t, metricHeadPartObject)

Expand All @@ -1128,7 +1128,7 @@ func (store S3Store) putIncompletePartForUpload(ctx context.Context, uploadId st
t := time.Now()
_, err := store.Service.PutObject(ctx, &s3.PutObjectInput{
Bucket: aws.String(store.Bucket),
Key: store.metadataKeyWithPrefix(uploadId + ".part"),
Key: store.keyWithPrefix(uploadId + ".part"),
Body: file,
})
store.observeRequestDuration(t, metricPutPartObject)
Expand All @@ -1139,7 +1139,7 @@ func (store S3Store) deleteIncompletePartForUpload(ctx context.Context, uploadId
t := time.Now()
_, err := store.Service.DeleteObject(ctx, &s3.DeleteObjectInput{
Bucket: aws.String(store.Bucket),
Key: store.metadataKeyWithPrefix(uploadId + ".part"),
Key: store.keyWithPrefix(uploadId + ".part"),
})
store.observeRequestDuration(t, metricPutPartObject)
return err
Expand Down

0 comments on commit 064ac79

Please sign in to comment.