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
Conversation
This file contains 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
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
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
/test |
/ci-aks Hit #26075 |
tklauser
approved these changes
Jun 21, 2023
marseel
approved these changes
Jun 22, 2023
There was a problem hiding this 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
bot
added
the
ready-to-merge
This PR has passed all tests and received consensus from code owners to merge.
label
Jun 22, 2023
2 tasks
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.
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.
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
.