From e934c3e2a27024514b6d5f97b5c45c5edc652fe9 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Tue, 4 Feb 2020 02:27:47 +0100 Subject: [PATCH] usage: Fix buckets count calculation when no object is present (#8929) XL crawling wrongly returns a zero buckets count when there are no objects uploaded in the server yet. The reason is data of the crawler of posix returns invalid result when all disks has zero objects. A simple fix is to always pick the crawling result of the first disk but choose over the result of the disk which has the most objects in it. --- cmd/xl-v1.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/xl-v1.go b/cmd/xl-v1.go index 972b08997..b5aaf9926 100644 --- a/cmd/xl-v1.go +++ b/cmd/xl-v1.go @@ -227,8 +227,10 @@ func (xl xlObjects) CrawlAndGetDataUsage(ctx context.Context, endCh <-chan struc } wg.Wait() - var dataUsageInfo DataUsageInfo - for i := 0; i < len(dataUsageResults); i++ { + var dataUsageInfo = dataUsageResults[0] + // Pick the crawling result of the disk which has the most + // number of objects in it. + for i := 1; i < len(dataUsageResults); i++ { if dataUsageResults[i].ObjectsCount > dataUsageInfo.ObjectsCount { dataUsageInfo = dataUsageResults[i] }