From 064ac7982d880ba3e6a878b714fc3167a64ede3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Tue, 5 Dec 2023 17:05:23 +0100 Subject: [PATCH] s3store fix incomplete part keys 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 ;-) --- pkg/s3store/s3store.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/s3store/s3store.go b/pkg/s3store/s3store.go index bda53dd63..7f8db55f4 100644 --- a/pkg/s3store/s3store.go +++ b/pkg/s3store/s3store.go @@ -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") { @@ -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) @@ -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) @@ -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