From a93aa2eac1ec406f4ff3d55898e9c2ac9c3ec9b6 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 9 Jun 2021 17:13:00 -0700 Subject: [PATCH] fix: upon failure attempt an undo for all calls in DeleteBucket() (#12480) its possible that, version might exist on second pool such that upon deleteBucket() might have deleted the bucket on pool1 successfully since it doesn't have any objects, undo such operations properly in all any error scenario. Also delete bucket metadata from pool layer rather than sets layer. --- cmd/erasure-server-pool.go | 8 +++----- cmd/erasure-sets.go | 3 --- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/cmd/erasure-server-pool.go b/cmd/erasure-server-pool.go index e10075569..f19936231 100644 --- a/cmd/erasure-server-pool.go +++ b/cmd/erasure-server-pool.go @@ -1248,9 +1248,6 @@ func (z *erasureServerPools) IsTaggingSupported() bool { // even if one of the serverPools fail to delete buckets, we proceed to // undo a successful operation. func (z *erasureServerPools) DeleteBucket(ctx context.Context, bucket string, forceDelete bool) error { - if z.SinglePool() { - return z.serverPools[0].DeleteBucket(ctx, bucket, forceDelete) - } g := errgroup.WithNErrs(len(z.serverPools)) // Delete buckets in parallel across all serverPools. @@ -1267,14 +1264,15 @@ func (z *erasureServerPools) DeleteBucket(ctx context.Context, bucket string, fo // buckets operation by creating all the buckets again. for _, err := range errs { if err != nil { - if _, ok := err.(InsufficientWriteQuorum); ok { + if !z.SinglePool() { undoDeleteBucketServerPools(ctx, bucket, z.serverPools, errs) } - return err } } + deleteBucketMetadata(ctx, z, bucket) + // Success. return nil } diff --git a/cmd/erasure-sets.go b/cmd/erasure-sets.go index 2b4b26304..722d44586 100644 --- a/cmd/erasure-sets.go +++ b/cmd/erasure-sets.go @@ -842,9 +842,6 @@ func (s *erasureSets) DeleteBucket(ctx context.Context, bucket string, forceDele } } - // Delete all bucket metadata. - deleteBucketMetadata(ctx, s, bucket) - // Success. return nil }