remove ListBucketsMetadata instead add them to AccountInfo() (#13241)

This commit is contained in:
Harshavardhana
2021-09-17 15:02:21 -07:00
committed by GitHub
parent 5ed781a330
commit 6d42569ade
8 changed files with 32 additions and 108 deletions

View File

@@ -306,8 +306,6 @@ func (api objectAPIHandlers) ListBucketsHandler(w http.ResponseWriter, r *http.R
return
}
metadata := r.Form.Get("metadata") == "true"
// If etcd, dns federation configured list buckets from etcd.
var bucketsInfo []BucketInfo
if globalDNSConfig != nil && globalBucketFederation {
@@ -372,49 +370,6 @@ func (api objectAPIHandlers) ListBucketsHandler(w http.ResponseWriter, r *http.R
}
}
if metadata && !globalIsGateway {
usageInfo, err := loadDataUsageFromBackend(ctx, objectAPI)
if err != nil {
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL)
return
}
for i, bucket := range bucketsInfo {
if bu, ok := usageInfo.BucketsUsage[bucket.Name]; ok {
bucketsInfo[i].Usage = &BucketUsageInfo{
Size: bu.Size,
ObjectsCount: bu.ObjectsCount,
ObjectSizesHistogram: StringMap{},
}
for k, v := range bu.ObjectSizesHistogram {
bucketsInfo[i].Usage.ObjectSizesHistogram[k] = fmt.Sprint(v)
}
} else {
bucketsInfo[i].Usage = &BucketUsageInfo{
ObjectSizesHistogram: StringMap{},
}
}
lcfg, _ := globalBucketObjectLockSys.Get(bucket.Name)
quota, _ := globalBucketQuotaSys.Get(bucket.Name)
var bquota *BucketQuotaConfig
if quota != nil {
bquota = &BucketQuotaConfig{
Quota: quota.Quota,
Type: quota.Type,
}
}
rcfg, _ := globalBucketMetadataSys.GetReplicationConfig(ctx, bucket.Name)
tcfg, _ := globalBucketMetadataSys.GetTaggingConfig(bucket.Name)
bucketsInfo[i].Details = &BucketDetailsInfo{
Versioning: globalBucketVersioningSys.Enabled(bucket.Name),
VersioningSuspended: globalBucketVersioningSys.Suspended(bucket.Name),
Replication: rcfg != nil,
Locking: lcfg.LockEnabled,
Quota: bquota,
Tagging: tcfg,
}
}
}
// Generate response.
response := generateListBucketsResponse(bucketsInfo)
encodedSuccessResponse := encodeResponse(response)