Backport of Set replication metric to 0 when losing leadership into release/1.19.x (#21687)

* backport of commit d6e0bffbce

* backport of commit 74a6463761

---------

Co-authored-by: Jorge Marey <jorgenw3@gmail.com>
pull/21699/head
hc-github-team-consul-core 3 months ago committed by GitHub
parent 2c17252b48
commit e9573e3b6f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -771,6 +771,12 @@ func (s *Server) runACLReplicator(
index, exit, err := replicateFunc(ctx, logger, lastRemoteIndex)
if exit {
metrics.SetGauge([]string{"leader", "replication", metricName, "status"},
0,
)
metrics.SetGauge([]string{"leader", "replication", metricName, "index"},
0,
)
return nil
}

@ -153,6 +153,12 @@ func (r *Replicator) Run(ctx context.Context) error {
// Perform a single round of replication
index, exit, err := r.delegate.Replicate(ctx, atomic.LoadUint64(&r.lastRemoteIndex), r.logger)
if exit {
metrics.SetGauge([]string{"leader", "replication", r.delegate.MetricName(), "status"},
0,
)
metrics.SetGauge([]string{"leader", "replication", r.delegate.MetricName(), "index"},
0,
)
return nil
}
if err != nil {

Loading…
Cancel
Save