mirror of
https://github.com/minio/minio.git
synced 2025-02-05 02:38:07 -05:00
Merge buckets list from different nodes in ListBuckets() call (#16357)
This commit is contained in:
parent
b197623ed2
commit
7883e55da2
@ -81,7 +81,7 @@ func NewS3PeerSys(endpoints EndpointServerPools) *S3PeerSys {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListBuckets lists buckets across all servers and returns a possible consistent view
|
// ListBuckets lists buckets across all servers and returns a possible consistent view
|
||||||
func (sys *S3PeerSys) ListBuckets(ctx context.Context, opts BucketOptions) (buckets []BucketInfo, err error) {
|
func (sys *S3PeerSys) ListBuckets(ctx context.Context, opts BucketOptions) (result []BucketInfo, err error) {
|
||||||
g := errgroup.WithNErrs(len(sys.peerClients))
|
g := errgroup.WithNErrs(len(sys.peerClients))
|
||||||
|
|
||||||
localBuckets, err := listBucketsLocal(ctx, opts)
|
localBuckets, err := listBucketsLocal(ctx, opts)
|
||||||
@ -116,13 +116,21 @@ func (sys *S3PeerSys) ListBuckets(ctx context.Context, opts BucketOptions) (buck
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bucketsMap := make(map[string]struct{})
|
||||||
for idx, buckets := range nodeBuckets {
|
for idx, buckets := range nodeBuckets {
|
||||||
if errs[idx] == nil {
|
if errs[idx] != nil {
|
||||||
return buckets, nil
|
continue
|
||||||
|
}
|
||||||
|
for _, bi := range buckets {
|
||||||
|
_, ok := bucketsMap[bi.Name]
|
||||||
|
if !ok {
|
||||||
|
bucketsMap[bi.Name] = struct{}{}
|
||||||
|
result = append(result, bi)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return []BucketInfo{}, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBucketInfo returns bucket stat info about bucket on disk across all peers
|
// GetBucketInfo returns bucket stat info about bucket on disk across all peers
|
||||||
|
Loading…
x
Reference in New Issue
Block a user