From bdad3730f7b513b0923dce3b22b5b0add637c865 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 12 Apr 2023 15:44:16 -0700 Subject: [PATCH] fix: do not error out if the local bucket is missing (#17025) --- cmd/peer-s3-client.go | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/cmd/peer-s3-client.go b/cmd/peer-s3-client.go index 3d4566463..e24bb0141 100644 --- a/cmd/peer-s3-client.go +++ b/cmd/peer-s3-client.go @@ -137,16 +137,7 @@ func (sys *S3PeerSys) ListBuckets(ctx context.Context, opts BucketOptions) (resu func (sys *S3PeerSys) GetBucketInfo(ctx context.Context, bucket string, opts BucketOptions) (binfo BucketInfo, err error) { g := errgroup.WithNErrs(len(sys.peerClients)) - bucketInfos := make([]BucketInfo, len(sys.peerClients)+1) - - bucketInfo, err := getBucketInfoLocal(ctx, bucket, opts) - if err != nil { - return BucketInfo{}, err - } - - errs := []error{nil} - bucketInfos[0] = bucketInfo - + bucketInfos := make([]BucketInfo, len(sys.peerClients)) for idx, client := range sys.peerClients { idx := idx client := client @@ -158,19 +149,29 @@ func (sys *S3PeerSys) GetBucketInfo(ctx context.Context, bucket string, opts Buc if err != nil { return err } - bucketInfos[idx+1] = bucketInfo + bucketInfos[idx] = bucketInfo return nil }, idx) } - errs = append(errs, g.Wait()...) + errs := g.Wait() + + bucketInfo, err := getBucketInfoLocal(ctx, bucket, opts) + errs = append(errs, err) + bucketInfos = append(bucketInfos, bucketInfo) quorum := (len(sys.allPeerClients) / 2) if err = reduceReadQuorumErrs(ctx, errs, bucketOpIgnoredErrs, quorum); err != nil { return BucketInfo{}, toObjectErr(err, bucket) } - return bucketInfo, nil + for i, err := range errs { + if err == nil { + return bucketInfos[i], nil + } + } + + return BucketInfo{}, toObjectErr(errVolumeNotFound, bucket) } func (client *peerS3Client) ListBuckets(ctx context.Context, opts BucketOptions) ([]BucketInfo, error) {