From a16ca4f45596c62511bfb8e6dbc710350c66ae58 Mon Sep 17 00:00:00 2001 From: Wouter Verlaek Date: Fri, 6 Oct 2023 14:28:14 +0200 Subject: [PATCH] Check s3 DeleteObjects response for errors (#18885) --- components/content-service/pkg/storage/s3.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/content-service/pkg/storage/s3.go b/components/content-service/pkg/storage/s3.go index 0f36c5b795f773..9f74b002b923df 100644 --- a/components/content-service/pkg/storage/s3.go +++ b/components/content-service/pkg/storage/s3.go @@ -127,7 +127,7 @@ func (rs *PresignedS3Storage) DeleteObject(ctx context.Context, bucket string, q return nil } - _, err := rs.client.DeleteObjects(ctx, &s3.DeleteObjectsInput{ + resp, err := rs.client.DeleteObjects(ctx, &s3.DeleteObjectsInput{ Bucket: &rs.Config.Bucket, Delete: &types.Delete{ Objects: objects, @@ -137,6 +137,13 @@ func (rs *PresignedS3Storage) DeleteObject(ctx context.Context, bucket string, q if err != nil { return err } + if len(resp.Errors) > 0 { + var errs []string + for _, e := range resp.Errors { + errs = append(errs, fmt.Sprintf("%s: %s", aws.ToString(e.Key), aws.ToString(e.Message))) + } + return xerrors.Errorf("cannot delete objects: %s", strings.Join(errs, ", ")) + } return nil }