Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: crash in prometherus metrics collector #12244

Merged
merged 1 commit into from May 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 8 additions & 16 deletions cmd/metrics-v2.go
Expand Up @@ -1041,6 +1041,10 @@ func getNodeHealthMetrics() MetricsGroup {
id: "NodeHealthMetrics",
cachedRead: cachedRead,
read: func(_ context.Context) (metrics []Metric) {
if globalIsGateway {
return
}
metrics = make([]Metric, 0, 16)
nodesUp, nodesDown := GetPeerOnlineCount()
metrics = append(metrics, Metric{
Description: getNodeOnlineTotalMD(),
Expand Down Expand Up @@ -1276,17 +1280,13 @@ func getBucketUsageMetrics() MetricsGroup {
id: "BucketUsageMetrics",
cachedRead: cachedRead,
read: func(ctx context.Context) (metrics []Metric) {
metrics = make([]Metric, 0, 50)
objLayer := newObjectLayerFn()
// Service not initialized yet
if objLayer == nil {
return
}

if globalIsGateway {
if objLayer == nil || globalIsGateway {
return
}

metrics = make([]Metric, 0, 50)
dataUsageInfo, err := loadDataUsageFromBackend(ctx, objLayer)
if err != nil {
return
Expand Down Expand Up @@ -1369,11 +1369,7 @@ func getLocalStorageMetrics() MetricsGroup {
read: func(ctx context.Context) (metrics []Metric) {
objLayer := newObjectLayerFn()
// Service not initialized yet
if objLayer == nil {
return
}

if globalIsGateway {
if objLayer == nil || globalIsGateway {
return
}

Expand Down Expand Up @@ -1415,11 +1411,7 @@ func getClusterStorageMetrics() MetricsGroup {
read: func(ctx context.Context) (metrics []Metric) {
objLayer := newObjectLayerFn()
// Service not initialized yet
if objLayer == nil {
return
}

if globalIsGateway {
if objLayer == nil || globalIsGateway {
return
}

Expand Down