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

@@ -1081,8 +1081,12 @@ func (a adminAPIHandlers) AccountInfoHandler(w http.ResponseWriter, r *http.Requ
if rd || wr {
// Fetch the data usage of the current bucket
var size uint64
var objectsCount uint64
var objectsHist map[string]uint64
if !dataUsageInfo.LastUpdate.IsZero() {
size = dataUsageInfo.BucketsUsage[bucket.Name].Size
objectsCount = dataUsageInfo.BucketsUsage[bucket.Name].ObjectsCount
objectsHist = dataUsageInfo.BucketsUsage[bucket.Name].ObjectSizesHistogram
}
// Fetch the prefix usage of the current bucket
var prefixUsage map[string]uint64
@@ -1093,11 +1097,27 @@ func (a adminAPIHandlers) AccountInfoHandler(w http.ResponseWriter, r *http.Requ
logger.LogIf(ctx, err)
}
}
lcfg, _ := globalBucketObjectLockSys.Get(bucket.Name)
quota, _ := globalBucketQuotaSys.Get(bucket.Name)
rcfg, _ := globalBucketMetadataSys.GetReplicationConfig(ctx, bucket.Name)
tcfg, _ := globalBucketMetadataSys.GetTaggingConfig(bucket.Name)
acctInfo.Buckets = append(acctInfo.Buckets, madmin.BucketAccessInfo{
Name: bucket.Name,
Created: bucket.Created,
Size: size,
PrefixUsage: prefixUsage,
Name: bucket.Name,
Created: bucket.Created,
Size: size,
Objects: objectsCount,
ObjectSizesHistogram: objectsHist,
PrefixUsage: prefixUsage,
Details: &madmin.BucketDetails{
Versioning: globalBucketVersioningSys.Enabled(bucket.Name),
VersioningSuspended: globalBucketVersioningSys.Suspended(bucket.Name),
Replication: rcfg != nil,
Locking: lcfg.LockEnabled,
Quota: quota,
Tagging: tcfg,
},
Access: madmin.AccountAccess{
Read: rd,
Write: wr,

View File

@@ -240,16 +240,6 @@ type CommonPrefix struct {
type Bucket struct {
Name string
CreationDate string // time string of format "2006-01-02T15:04:05.000Z"
// Usage size of the bucket not reflective of
// actual usage atomically, but an ever increasing
// value.
Usage *BucketUsageInfo `xml:"Usage,omitempty"`
// Provides information about various bucket features
// enabled such as versioning, object locking, tagging
// quota, replication config etc.
Details *BucketDetailsInfo `xml:"Details,omitempty"`
}
// ObjectVersion container for object version metadata
@@ -437,8 +427,6 @@ func generateListBucketsResponse(buckets []BucketInfo) ListBucketsResponse {
listbuckets = append(listbuckets, Bucket{
Name: bucket.Name,
CreationDate: bucket.Created.UTC().Format(iso8601TimeFormat),
Usage: bucket.Usage,
Details: bucket.Details,
})
}

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)

View File

@@ -104,10 +104,7 @@ func (er erasureObjects) getBucketInfo(ctx context.Context, bucketName string) (
if err != nil {
return err
}
bucketsInfo[index] = BucketInfo{
Name: volInfo.Name,
Created: volInfo.Created,
}
bucketsInfo[index] = BucketInfo(volInfo)
return nil
}, index)
}

View File

@@ -859,10 +859,7 @@ func (s *erasureSets) ListBuckets(ctx context.Context) (buckets []BucketInfo, er
}
for _, v := range healBuckets {
listBuckets = append(listBuckets, BucketInfo{
Name: v.Name,
Created: v.Created,
})
listBuckets = append(listBuckets, BucketInfo(v))
}
sort.Slice(listBuckets, func(i, j int) bool {

View File

@@ -24,7 +24,6 @@ import (
humanize "github.com/dustin/go-humanize"
"github.com/minio/madmin-go"
"github.com/minio/minio-go/v7/pkg/tags"
"github.com/minio/minio/internal/bucket/replication"
"github.com/minio/minio/internal/hash"
)
@@ -71,30 +70,6 @@ var ObjectsHistogramIntervals = []objectHistogramInterval{
{"GREATER_THAN_512_MB", humanize.MiByte * 512, math.MaxInt64},
}
// BucketUsageInfo represents per bucket usage statistics
type BucketUsageInfo struct {
Size uint64
ObjectsCount uint64
ObjectSizesHistogram StringMap
}
// BucketQuotaConfig holds bucket quota restrictions
type BucketQuotaConfig struct {
Quota uint64
Type madmin.QuotaType
}
// BucketDetailsInfo provides information about features currently
// turned-on per bucket.
type BucketDetailsInfo struct {
Versioning bool
VersioningSuspended bool
Locking bool
Replication bool
Tagging *tags.Tags `xml:",omitempty"`
Quota *BucketQuotaConfig `xml:",omitempty"`
}
// BucketInfo - represents bucket metadata.
type BucketInfo struct {
// Name of the bucket.
@@ -102,16 +77,6 @@ type BucketInfo struct {
// Date and time when the bucket was created.
Created time.Time
// Usage size of the bucket not reflective of
// actual usage atomically, but an ever increasing
// value.
Usage *BucketUsageInfo `xml:",omitempty"`
// Provides information about various bucket features
// enabled such as versioning, object locking, tagging
// quota, replication config etc.
Details *BucketDetailsInfo `xml:",omitempty"`
}
// ObjectInfo - represents object metadata.