From 5371da6b7b8910145fb6a3b2e02f2bc51e9e0fd2 Mon Sep 17 00:00:00 2001 From: Paul Rogers Date: Thu, 5 Sep 2024 13:04:45 -0400 Subject: [PATCH] Hacky way of testing error --- pkg/storage/chunk/client/aws/s3_storage_client.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/storage/chunk/client/aws/s3_storage_client.go b/pkg/storage/chunk/client/aws/s3_storage_client.go index a6d9501616f11..b4a63216d8628 100644 --- a/pkg/storage/chunk/client/aws/s3_storage_client.go +++ b/pkg/storage/chunk/client/aws/s3_storage_client.go @@ -325,6 +325,12 @@ func (a *S3ObjectClient) ObjectExists(ctx context.Context, objectKey string) (bo if lastErr == nil { return true, nil } + // AWS SDK v1 doesn't properly support error unwrapping, so we have to check the error message + // https://github.com/aws/aws-sdk-go/issues/2820#issuecomment-822767966 + if strings.Contains(lastErr.Error(), "NoSuchKey") { + return false, lastErr + } + retries.Wait() }