From 9e254754759c8ec102e7a5d01e1e4701c5e0ab76 Mon Sep 17 00:00:00 2001 From: Poorna Date: Tue, 29 Mar 2022 10:10:06 -0700 Subject: [PATCH] Validate tier manager is initialized in tier Empty() check (#14646) Co-authored-by: Poorna Krishnamoorthy --- cmd/metrics-v2.go | 6 +++--- cmd/tier.go | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/metrics-v2.go b/cmd/metrics-v2.go index 15c789b3f..80ee2c271 100644 --- a/cmd/metrics-v2.go +++ b/cmd/metrics-v2.go @@ -1651,13 +1651,13 @@ func getClusterTierMetrics() *MetricsGroup { cacheInterval: 10 * time.Second, } mg.RegisterRead(func(ctx context.Context) (metrics []Metric) { - if globalTierConfigMgr.Empty() { - return - } objLayer := newObjectLayerFn() if objLayer == nil || globalIsGateway { return } + if globalTierConfigMgr.Empty() { + return + } dui, err := loadDataUsageFromBackend(GlobalContext, objLayer) if err != nil { diff --git a/cmd/tier.go b/cmd/tier.go index 824bb3025..486b1522b 100644 --- a/cmd/tier.go +++ b/cmd/tier.go @@ -148,6 +148,9 @@ func (config *TierConfigMgr) Verify(ctx context.Context, tier string) error { // Empty returns if tier targets are empty func (config *TierConfigMgr) Empty() bool { + if config == nil { + return true + } return len(config.ListTiers()) == 0 }