Usage: Reset merged info when updating (#10126)

When merging multiple buckets reset between each update.

Avoids merging the same usage metrics multiple times resulting 
in duplicate data entries.
This commit is contained in:
Klaus Post 2020-07-24 11:02:10 -07:00 committed by GitHub
parent 10025bda45
commit 11593c6cc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -340,12 +340,13 @@ func (z *erasureZones) CrawlAndGetDataUsage(ctx context.Context, bf *bloomFilter
// We need to merge since we will get the same buckets from each zone. // We need to merge since we will get the same buckets from each zone.
// Therefore to get the exact bucket sizes we must merge before we can convert. // Therefore to get the exact bucket sizes we must merge before we can convert.
allMerged := dataUsageCache{Info: dataUsageCacheInfo{Name: dataUsageRoot}} var allMerged dataUsageCache
update := func() { update := func() {
mu.Lock() mu.Lock()
defer mu.Unlock() defer mu.Unlock()
allMerged = dataUsageCache{Info: dataUsageCacheInfo{Name: dataUsageRoot}}
for _, info := range results { for _, info := range results {
if info.Info.LastUpdate.IsZero() { if info.Info.LastUpdate.IsZero() {
// Not filled yet. // Not filled yet.