Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

etcd: start the status checker only after establishing the initial session #26363

Merged
merged 1 commit into from Jun 22, 2023

Conversation

giorio94
Copy link
Member

Currently, the etcd status checker is started in a separate goroutine as soon as the client is created, without waiting for the establishment of the initial session. Yet, the status checker will never succeed until then, based on how it is implemented. This is problematic especially in the clustermesh case, because the errors propagated by the status checker cause a watchdog logic to restart the connection.

Let's consider the following situation: a new etcd client is created, starting the corresponding status checker, while the remote clustermesh-apiserver is not yet running. The status checker will likely fail a few times, propagating the corresponding error through the StatusCheckErrors channel. Eventually, the clustermesh-apiserver pod boots up, the initial session is established and the different watchers are started. At this point, the watchdog logic starts to read from the channel, and restarts an otherwise working connection. It is worth mentioning that this issue affects clustermesh only because the other components ignore the errors returned through the StatusCheckErrors channel.

This PR modifies the etcd client to start the status checker only after that the initial connection has been established (the same also for the heartbeat watcher), so that the above issue is prevented. Another alternative might be to ignore all errors reported through the StatusCheckErrors when the watchdog is initially started, but this would be subject to race conditions, and possibly show incorrect statuses through cilium status.

Currently, the etcd status checker is started in a separate goroutine
as soon as the client is created, without waiting for the establishment
of the initial session. Yet, the status checker will never succeed until
then, based on how it is implemented. This is problematic especially in
the clustermesh case, because the errors propagated by the status
checker cause a watchdog logic to restart the connection.

Let's consider the following situation: a new etcd client is created,
starting the corresponding status checker, while the remote
clustermesh-apiserver is not yet running. The status checker will likely
fail a few times, propagating the corresponding error through the
StatusCheckErrors channel. Eventually, the clustermesh-apiserver pod
boots up, the initial session is established and the different watchers
are started. At this point, the watchdog logic starts to read from the
channel, and restarts an otherwise working connection. It is worth
mentioning that this issue affects clustermesh only because the other
components ignore the errors returned through the StatusCheckErrors
channel.

This commit modifies the etcd client to start the status checker only
after that the initial connection has been established (the same also
for the heartbeat watcher), so that the above issue is prevented.
Another alternative might be to ignore all errors reported through the
StatusCheckErrors when the watchdog is initially started, but this would
be subject to race conditions, and possibly show incorrect statuses
through `cilium status`.

Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
@giorio94 giorio94 added kind/enhancement This would improve or streamline existing functionality. release-note/misc This PR makes changes that have no direct user impact. sig/kvstore Impacts the KVStore package interactions. labels Jun 19, 2023
@giorio94 giorio94 requested a review from a team as a code owner June 19, 2023 16:35
@giorio94 giorio94 requested a review from tklauser June 19, 2023 16:35
@giorio94
Copy link
Member Author

/test

@giorio94
Copy link
Member Author

giorio94 commented Jun 20, 2023

/ci-aks

Hit #26075

@marseel marseel self-requested a review June 20, 2023 12:28
Copy link
Contributor

@marseel marseel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Jun 22, 2023
@borkmann borkmann merged commit 33853e1 into cilium:main Jun 22, 2023
63 checks passed
@giorio94 giorio94 deleted the mio/etcd-status-checker branch June 22, 2023 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement This would improve or streamline existing functionality. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact. sig/kvstore Impacts the KVStore package interactions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants