[!] poll the etcd leader key instead of watching it - #436
Merged
Merged
Conversation
The watch kept producing bugs: cancelled watches (#228), events lost while the watch was down (#394), a failed re-sync leaving a healthy watch silent (#431), and the startup read racing the watch. While etcd is unreachable the client retries the watch without closing its channel, so the checker sent nothing and a node kept its VIP for the whole outage (#435). The etcd checker now reads the key once per interval, like the Consul and Patroni checkers. A failed read sends false, and the next successful read sends the current value. The value is logged only when it changes, and read failures stay throttled. interval applies to etcd again, so the README note saying otherwise is gone and the e2e test uses the default interval.
This was referenced Sep 25, 2026
denys-holub
approved these changes
Sep 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The etcd checker now reads the leader key once per
intervalinstead of watching it, the same way the Consul and Patroni checkers work. Closes #431, closes #435, and replaces #432.While etcd is completely unreachable,
clientv3keeps retrying the watch and never closes the watch channel. With a real etcd container stopped under an openWithRequireLeaderwatch, nothing arrived on the channel for 40 seconds. So the checker sent nothing, and the node kept its VIP for the whole outage (#435). Every earlier watch fix (#228, #394, #431, #432) handled one more way the watch can go quiet or send stale state.Changes:
GetChangeNotificationStreamcallsgetin a loop and waitsintervalms between reads. A failed read sendsfalse, and the next successful read sends the current value.intervalaffects etcd again, so the README note "Doesn't affect etcd checker since v2.3.0" is removed.behaviour_test.shdrops--interval 3000, because with polling itssleep 2needs the default 1000.FollowsLeaderKeychecks that changes to the key are picked up.Outagechecks that reads failing sendsfalseand that recovery sendstrueagain; it fails against the old watch code.EmitsOnConnectionErrorno longer hangs for 10 minutes when it fails.Trade-off: a leader change is noticed up to
intervalms later (1s by default) instead of immediately.