metrics: Avoid crash when fetching tier metrics (#14493)

Data usage does not always contain tiering info even if the data usage
information is valid. Avoid a crash in that case.

(e.g. the scanner scanned the namespace, the user enables tiering,
prometheus scrapes the server before the scanner gets a chance to
update the data usage with new tiering information)
This commit is contained in:
Anis Elleuch 2022-03-07 19:59:32 +01:00 committed by GitHub
parent 1d1b213f1f
commit bacf6156c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -1663,8 +1663,8 @@ func getClusterTierMetrics() *MetricsGroup {
if err != nil {
return
}
// data usage has not captured any data yet.
if dui.LastUpdate.IsZero() {
// data usage has not captured any tier stats yet.
if dui.TierStats == nil {
return
}