From aa7244a9a4ae85900439ebc2e6efd555d1992d87 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 23 Feb 2021 09:23:11 -0800 Subject: [PATCH] fix: make sure to convert the error properly in HealBucket() (#11610) server startup code expects the object layer to properly convert error into a proper type, so that in situations when servers are coming up and quorum is not available servers wait on each other. --- cmd/erasure-sets.go | 6 +++--- cmd/server-main.go | 12 +++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/cmd/erasure-sets.go b/cmd/erasure-sets.go index 3954c653b..ef81e0ab6 100644 --- a/cmd/erasure-sets.go +++ b/cmd/erasure-sets.go @@ -1367,11 +1367,11 @@ func (s *erasureSets) HealBucket(ctx context.Context, bucket string, opts madmin SetCount: s.setCount, } - for _, s := range s.sets { + for _, set := range s.sets { var healResult madmin.HealResultItem - healResult, err = s.HealBucket(ctx, bucket, opts) + healResult, err = set.HealBucket(ctx, bucket, opts) if err != nil { - return result, err + return result, toObjectErr(err, bucket) } result.Before.Drives = append(result.Before.Drives, healResult.Before.Drives...) result.After.Drives = append(result.After.Drives, healResult.After.Drives...) diff --git a/cmd/server-main.go b/cmd/server-main.go index bd103cfd6..44425ea82 100644 --- a/cmd/server-main.go +++ b/cmd/server-main.go @@ -311,6 +311,8 @@ func initServer(ctx context.Context, newObject ObjectLayer) error { if errors.Is(err, errDiskNotFound) || errors.Is(err, errConfigNotFound) || errors.Is(err, context.DeadlineExceeded) || + errors.Is(err, errErasureWriteQuorum) || + errors.Is(err, errErasureReadQuorum) || errors.As(err, &rquorum) || errors.As(err, &wquorum) || isErrBucketNotFound(err) { @@ -355,14 +357,12 @@ func initAllSubsystems(ctx context.Context, newObject ObjectLayer) (err error) { for index := range buckets { index := index g.Go(func() error { - if _, berr := newObject.HealBucket(ctx, buckets[index].Name, madmin.HealOpts{Recreate: true}); berr != nil { - return fmt.Errorf("Unable to list buckets to heal: %w", berr) - } - return nil + _, berr := newObject.HealBucket(ctx, buckets[index].Name, madmin.HealOpts{Recreate: true}) + return berr }, index) } if err := g.WaitErr(); err != nil { - return err + return fmt.Errorf("Unable to list buckets to heal: %w", err) } } @@ -371,6 +371,8 @@ func initAllSubsystems(ctx context.Context, newObject ObjectLayer) (err error) { if errors.Is(err, errDiskNotFound) || errors.Is(err, errConfigNotFound) || errors.Is(err, context.DeadlineExceeded) || + errors.Is(err, errErasureWriteQuorum) || + errors.Is(err, errErasureReadQuorum) || errors.As(err, &rquorum) || errors.As(err, &wquorum) || isErrBucketNotFound(err) {