From 4ed45ce5436fa64f15a37f7ebbb6de997e1feed6 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 5 Jan 2021 13:24:22 -0800 Subject: [PATCH] fix: healing buckets during pool expansion (#11224) fixes #11209 --- cmd/erasure-healing.go | 8 ++++---- cmd/server-main.go | 2 +- pkg/madmin/heal-commands.go | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/erasure-healing.go b/cmd/erasure-healing.go index 0a8efa17f..b01573f7c 100644 --- a/cmd/erasure-healing.go +++ b/cmd/erasure-healing.go @@ -45,12 +45,12 @@ func (er erasureObjects) HealBucket(ctx context.Context, bucket string, opts mad writeQuorum := getWriteQuorum(len(storageDisks)) // Heal bucket. - return healBucket(ctx, storageDisks, storageEndpoints, bucket, writeQuorum, opts.DryRun) + return healBucket(ctx, storageDisks, storageEndpoints, bucket, writeQuorum, opts) } // Heal bucket - create buckets on disks where it does not exist. func healBucket(ctx context.Context, storageDisks []StorageAPI, storageEndpoints []string, bucket string, writeQuorum int, - dryRun bool) (res madmin.HealResultItem, err error) { + opts madmin.HealOpts) (res madmin.HealResultItem, err error) { // Initialize sync waitgroup. g := errgroup.WithNErrs(len(storageDisks)) @@ -84,7 +84,7 @@ func healBucket(ctx context.Context, storageDisks []StorageAPI, storageEndpoints afterState[index] = madmin.DriveStateMissing // mutate only if not a dry-run - if dryRun { + if opts.DryRun { return nil } @@ -99,7 +99,7 @@ func healBucket(ctx context.Context, storageDisks []StorageAPI, storageEndpoints errs := g.Wait() reducedErr := reduceWriteQuorumErrs(ctx, errs, bucketOpIgnoredErrs, writeQuorum-1) - if reducedErr == errVolumeNotFound { + if errors.Is(reducedErr, errVolumeNotFound) && !opts.Recreate { return res, nil } diff --git a/cmd/server-main.go b/cmd/server-main.go index 732d36d02..39ddb1321 100644 --- a/cmd/server-main.go +++ b/cmd/server-main.go @@ -336,7 +336,7 @@ func initAllSubsystems(ctx context.Context, newObject ObjectLayer) (err error) { } } for _, bucket := range buckets { - if _, err = newObject.HealBucket(ctx, bucket.Name, madmin.HealOpts{}); err != nil { + if _, err = newObject.HealBucket(ctx, bucket.Name, madmin.HealOpts{Recreate: true}); err != nil { return fmt.Errorf("Unable to list buckets to heal: %w", err) } } diff --git a/pkg/madmin/heal-commands.go b/pkg/madmin/heal-commands.go index 2311cf7c9..80cd2c74d 100644 --- a/pkg/madmin/heal-commands.go +++ b/pkg/madmin/heal-commands.go @@ -42,6 +42,7 @@ type HealOpts struct { Recursive bool `json:"recursive"` DryRun bool `json:"dryRun"` Remove bool `json:"remove"` + Recreate bool `json:"recreate"` // only used when bucket needs to be healed ScanMode HealScanMode `json:"scanMode"` }