From 040137e88af0300e65c9d05719a84472e0b3ff4f Mon Sep 17 00:00:00 2001 From: rakeshgm Date: Mon, 22 Jan 2024 18:04:51 +0530 Subject: [PATCH] addressing comments Signed-off-by: rakeshgm --- controllers/s3utils.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/controllers/s3utils.go b/controllers/s3utils.go index a192fa245..1e3fa4bc2 100644 --- a/controllers/s3utils.go +++ b/controllers/s3utils.go @@ -597,8 +597,13 @@ func (s *s3ObjectStore) DeleteObject(key string) error { Bucket: aws.String(s.s3Bucket), Key: aws.String(key), }) + if err != nil { + errMsgPrefix := fmt.Errorf("failed to delete object %s", *aws.String(key)) + + return processAwsError(errMsgPrefix, err) + } - return err + return nil } // DeleteObjectsWithKeyPrefix deletes from the bucket any objects that @@ -643,9 +648,16 @@ func (s *s3ObjectStore) DeleteObjects(keys ...string) error { ctx, cancel := context.WithDeadline(context.TODO(), time.Now().Add(s3Timeout)) defer cancel() - return s.batchDeleter.Delete(ctx, &s3manager.DeleteObjectsIterator{ + err := s.batchDeleter.Delete(ctx, &s3manager.DeleteObjectsIterator{ Objects: delObjects, }) + if err != nil { + errMsgPrefix := fmt.Errorf("unable to process batch delete") + + return processAwsError(errMsgPrefix, err) + } + + return nil } // isAwsErrCodeNoSuchBucket returns true if the given input `err` has wrapped