Fix TestHeadlessAuthenticationWatcher flakiness#24562
Merged
Conversation
…ing waiters as stale by accident.
mdwn
reviewed
Apr 14, 2023
Contributor
mdwn
left a comment
There was a problem hiding this comment.
Overall this looks good to me. I've got two questions, but feel free to push back on these.
codingllama
reviewed
Apr 14, 2023
Contributor
codingllama
left a comment
There was a problem hiding this comment.
Thanks for the fix, Brian!
| select { | ||
| case t := <-h.retry.After(): | ||
| h.Log.Debugf("Attempting to restart watch after waiting %v.", t.Sub(startedWaiting)) | ||
| h.Log.Warningf("Restarting watch on error after waiting %v. Error: %v.", t.Sub(startedWaiting), err) |
Contributor
There was a problem hiding this comment.
Does h.watch always return a non-nil error? I'm a bit confused by the error handling here.
Contributor
Author
There was a problem hiding this comment.
Yes, h.watch should always return non-nil error, and we want to restart the watcher on any error received, unless it's a context canceled/deadline error or the watcher is closed, which is covered by the select case.
zmb3
approved these changes
Apr 15, 2023
Collaborator
zmb3
left a comment
There was a problem hiding this comment.
I like the new approach. See comments for some minor suggestions.
codingllama
approved these changes
Apr 17, 2023
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.
After repeatedly getting
TestHeadlessAuthenticationWatcherflakiness and mistakenly just shifting the problem around, I decided this time to restructure the headless watcher and subscriber logic to make testing without race conditions possible.For context, the headless authentication watcher uses a stale channel to skip slow subscribers. Subscribers are expected to watch the stale channel and check the backend on receive. This PR breaks out this logic from the single
headlessAuthenticationWatcher.Waitmethod into a newHeadlessAuthenticationSubscriberinterface. This interface gives tests more insight into the stale mechanism, etc, without creating// Only used in testsbackdoors into the watcher.This change also makes the TestHeadlessAuthenticationWatcher much faster 🚀 since it avoids unstable waiting/ticking logic.
Closes #24409