mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-29 17:52:32 +00:00
Fix a panic I observed in a sealed node running CollectMetrics (#21249)
This commit is contained in:
3
changelog/21249.txt
Normal file
3
changelog/21249.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
```release-note:bug
|
||||||
|
core: Fix panic in sealed nodes using raft storage trying to emit raft metrics
|
||||||
|
```
|
||||||
@@ -624,10 +624,13 @@ func (b *RaftBackend) DisableUpgradeMigration() (bool, bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *RaftBackend) CollectMetrics(sink *metricsutil.ClusterMetricSink) {
|
func (b *RaftBackend) CollectMetrics(sink *metricsutil.ClusterMetricSink) {
|
||||||
|
var stats map[string]string
|
||||||
b.l.RLock()
|
b.l.RLock()
|
||||||
logstoreStats := b.stableStore.(*raftboltdb.BoltStore).Stats()
|
logstoreStats := b.stableStore.(*raftboltdb.BoltStore).Stats()
|
||||||
fsmStats := b.fsm.Stats()
|
fsmStats := b.fsm.Stats()
|
||||||
stats := b.raft.Stats()
|
if b.raft != nil {
|
||||||
|
stats = b.raft.Stats()
|
||||||
|
}
|
||||||
b.l.RUnlock()
|
b.l.RUnlock()
|
||||||
b.collectMetricsWithStats(logstoreStats, sink, "logstore")
|
b.collectMetricsWithStats(logstoreStats, sink, "logstore")
|
||||||
b.collectMetricsWithStats(fsmStats, sink, "fsm")
|
b.collectMetricsWithStats(fsmStats, sink, "fsm")
|
||||||
@@ -637,10 +640,12 @@ func (b *RaftBackend) CollectMetrics(sink *metricsutil.ClusterMetricSink) {
|
|||||||
Value: b.localID,
|
Value: b.localID,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, key := range []string{"term", "commit_index", "applied_index", "fsm_pending"} {
|
if stats != nil {
|
||||||
n, err := strconv.ParseUint(stats[key], 10, 64)
|
for _, key := range []string{"term", "commit_index", "applied_index", "fsm_pending"} {
|
||||||
if err == nil {
|
n, err := strconv.ParseUint(stats[key], 10, 64)
|
||||||
sink.SetGaugeWithLabels([]string{"raft_storage", "stats", key}, float32(n), labels)
|
if err == nil {
|
||||||
|
sink.SetGaugeWithLabels([]string{"raft_storage", "stats", key}, float32(n), labels)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user