Skip to content

Commit

Permalink
improve the keep alive worker
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <rleungx@gmail.com>
  • Loading branch information
rleungx committed Aug 9, 2023
1 parent ebd2cfe commit 0183048
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/election/lease.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,11 @@ func (l *lease) keepAliveWorker(ctx context.Context, interval time.Duration) <-c
expire := start.Add(time.Duration(res.TTL) * time.Second)
select {
case ch <- expire:
case <-ctx1.Done():
// Here we don't use `ctx1.Done()` because we want to make sure if the keep alive success, we can update the expire time.
case <-ctx.Done():
}
} else {
log.Error("keep alive response ttl is zero", zap.String("purpose", l.Purpose))

Check warning on line 181 in pkg/election/lease.go

View check run for this annotation

Codecov / codecov/patch

pkg/election/lease.go#L180-L181

Added lines #L180 - L181 were not covered by tests
}
}()

Expand Down

0 comments on commit 0183048

Please sign in to comment.