Skip to content

Commit

Permalink
Defer cancel on timeout for heartbeat
Browse files Browse the repository at this point in the history
Signed-off-by: Anna Tran <[email protected]>
  • Loading branch information
anna-tran committed Sep 17, 2024
1 parent 3041b3c commit d4d2612
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/ring/lifecycler.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,8 @@ func (i *Lifecycler) loop(ctx context.Context) error {

func (i *Lifecycler) heartbeat(ctx context.Context) {
i.lifecyclerMetrics.consulHeartbeats.Inc()
ctx, _ = context.WithTimeout(ctx, i.cfg.HeartbeatPeriod)
ctx, cancel := context.WithTimeout(ctx, i.cfg.HeartbeatPeriod)
defer cancel()
if err := i.updateConsul(context.Background()); err != nil {
level.Error(i.logger).Log("msg", "failed to write to the KV store, sleeping", "ring", i.RingName, "err", err)
}
Expand Down

0 comments on commit d4d2612

Please sign in to comment.