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.
This commit is contained in:
Harshavardhana 2021-02-23 09:23:11 -08:00 committed by GitHub
parent 2a79ea0332
commit aa7244a9a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View File

@ -1367,11 +1367,11 @@ func (s *erasureSets) HealBucket(ctx context.Context, bucket string, opts madmin
SetCount: s.setCount, SetCount: s.setCount,
} }
for _, s := range s.sets { for _, set := range s.sets {
var healResult madmin.HealResultItem var healResult madmin.HealResultItem
healResult, err = s.HealBucket(ctx, bucket, opts) healResult, err = set.HealBucket(ctx, bucket, opts)
if err != nil { if err != nil {
return result, err return result, toObjectErr(err, bucket)
} }
result.Before.Drives = append(result.Before.Drives, healResult.Before.Drives...) result.Before.Drives = append(result.Before.Drives, healResult.Before.Drives...)
result.After.Drives = append(result.After.Drives, healResult.After.Drives...) result.After.Drives = append(result.After.Drives, healResult.After.Drives...)

View File

@ -311,6 +311,8 @@ func initServer(ctx context.Context, newObject ObjectLayer) error {
if errors.Is(err, errDiskNotFound) || if errors.Is(err, errDiskNotFound) ||
errors.Is(err, errConfigNotFound) || errors.Is(err, errConfigNotFound) ||
errors.Is(err, context.DeadlineExceeded) || errors.Is(err, context.DeadlineExceeded) ||
errors.Is(err, errErasureWriteQuorum) ||
errors.Is(err, errErasureReadQuorum) ||
errors.As(err, &rquorum) || errors.As(err, &rquorum) ||
errors.As(err, &wquorum) || errors.As(err, &wquorum) ||
isErrBucketNotFound(err) { isErrBucketNotFound(err) {
@ -355,14 +357,12 @@ func initAllSubsystems(ctx context.Context, newObject ObjectLayer) (err error) {
for index := range buckets { for index := range buckets {
index := index index := index
g.Go(func() error { g.Go(func() error {
if _, berr := newObject.HealBucket(ctx, buckets[index].Name, madmin.HealOpts{Recreate: true}); berr != nil { _, berr := newObject.HealBucket(ctx, buckets[index].Name, madmin.HealOpts{Recreate: true})
return fmt.Errorf("Unable to list buckets to heal: %w", berr) return berr
}
return nil
}, index) }, index)
} }
if err := g.WaitErr(); err != nil { 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) || if errors.Is(err, errDiskNotFound) ||
errors.Is(err, errConfigNotFound) || errors.Is(err, errConfigNotFound) ||
errors.Is(err, context.DeadlineExceeded) || errors.Is(err, context.DeadlineExceeded) ||
errors.Is(err, errErasureWriteQuorum) ||
errors.Is(err, errErasureReadQuorum) ||
errors.As(err, &rquorum) || errors.As(err, &rquorum) ||
errors.As(err, &wquorum) || errors.As(err, &wquorum) ||
isErrBucketNotFound(err) { isErrBucketNotFound(err) {