Skip to content

Commit 20589ac

Browse files
committed
Set metric even when there are no job.Status.Conditions present
1 parent c864c93 commit 20589ac

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

internal/store/job.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,10 @@ func jobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat
219219
}
220220
}
221221

222+
reasonKnown := false
222223
for _, c := range j.Status.Conditions {
223224
condition := c
224225
if condition.Type == v1batch.JobFailed {
225-
reasonKnown := false
226226
for _, reason := range jobFailureReasons {
227227
reasonKnown = reasonKnown || failureReason(&condition, reason)
228228

@@ -233,16 +233,16 @@ func jobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat
233233
Value: boolFloat64(failureReason(&condition, reason)),
234234
})
235235
}
236-
// for unknown reasons
237-
if !reasonKnown {
238-
ms = append(ms, &metric.Metric{
239-
LabelKeys: []string{"reason"},
240-
LabelValues: []string{""},
241-
Value: float64(j.Status.Failed),
242-
})
243-
}
244236
}
245237
}
238+
// for unknown reasons
239+
if !reasonKnown {
240+
ms = append(ms, &metric.Metric{
241+
LabelKeys: []string{"reason"},
242+
LabelValues: []string{""},
243+
Value: float64(j.Status.Failed),
244+
})
245+
}
246246

247247
return &metric.Family{
248248
Metrics: ms,

0 commit comments

Comments
 (0)