Browse Source

Set replication metric to 0 when losing leadership (#20665)

* Set replication metric to 0 when losing leadership

* Fix replication metrics on replication.go also

---------

Co-authored-by: sarahalsmiller <100602640+sarahalsmiller@users.noreply.github.com>
pull/21616/head
Jorge Marey 3 months ago committed by GitHub
parent
commit
d12f9cf4d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      agent/consul/leader.go
  2. 6
      agent/consul/replication.go

6
agent/consul/leader.go

@ -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
}

6
agent/consul/replication.go

@ -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