From d89f6af6c4ab280140627974252077fba47bbb79 Mon Sep 17 00:00:00 2001 From: Minio Trusted Date: Fri, 16 Sep 2022 17:09:45 -0700 Subject: [PATCH] avoid replication stats crash in Prometheus --- cmd/bucket-replication-stats.go | 7 +++++++ cmd/bucket-stats.go | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd/bucket-replication-stats.go b/cmd/bucket-replication-stats.go index 5441166e6..51ceaf5b4 100644 --- a/cmd/bucket-replication-stats.go +++ b/cmd/bucket-replication-stats.go @@ -270,6 +270,13 @@ func (r *ReplicationStats) getAllLatest(bucketsUsage map[string]BucketUsageInfo) } func (r *ReplicationStats) calculateBucketReplicationStats(bucket string, u BucketUsageInfo, bucketStats []BucketStats) (s BucketReplicationStats) { + if r == nil { + s = BucketReplicationStats{ + Stats: make(map[string]*BucketReplicationStat), + } + return s + } + // accumulate cluster bucket stats stats := make(map[string]*BucketReplicationStat) var totReplicaSize int64 diff --git a/cmd/bucket-stats.go b/cmd/bucket-stats.go index 918861e7f..32cb74ceb 100644 --- a/cmd/bucket-stats.go +++ b/cmd/bucket-stats.go @@ -66,7 +66,7 @@ type BucketStats struct { // BucketReplicationStats represents inline replication statistics // such as pending, failed and completed bytes in total for a bucket type BucketReplicationStats struct { - Stats map[string]*BucketReplicationStat + Stats map[string]*BucketReplicationStat `json:",omitempty"` // Pending size in bytes PendingSize int64 `json:"pendingReplicationSize"` // Completed size in bytes