From b09fe0e50eb71669cb4e958e84463618ee3dbdec Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 25 Apr 2023 14:16:35 -0700 Subject: [PATCH] fix: DeleteBucket for peers() must recreate bucket upon errors (#17079) --- cmd/peer-s3-client.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/cmd/peer-s3-client.go b/cmd/peer-s3-client.go index 2bc831d66..b3b9c81d9 100644 --- a/cmd/peer-s3-client.go +++ b/cmd/peer-s3-client.go @@ -273,9 +273,24 @@ func (sys *S3PeerSys) DeleteBucket(ctx context.Context, bucket string, opts Dele errs := g.Wait() errs = append(errs, deleteBucketLocal(ctx, bucket, opts)) - quorum := (len(sys.allPeerClients) / 2) + 1 - err := reduceWriteQuorumErrs(ctx, errs, bucketOpIgnoredErrs, quorum) - return toObjectErr(err, bucket) + var errReturn error + for _, err := range errs { + if errReturn == nil && err != nil { + // always return first error + errReturn = toObjectErr(err, bucket) + break + } + } + + for _, err := range errs { + if err == nil && errReturn != nil { + // re-create successful deletes, since we are return an error. + sys.MakeBucket(ctx, bucket, MakeBucketOptions{}) + break + } + } + + return errReturn } // DeleteBucket deletes bucket on a peer