Merged
Conversation
Signed-off-by: Luke Shumaker <lukeshu@datawire.io>
If the watchable.Map has content in it already when .Subscribe() is called on it, then those initial entries won't have a snapshot.Updates entry in that first snapshot. For the first snapshot we just need to iterate over snapshot.State. Signed-off-by: Luke Shumaker <lukeshu@datawire.io>
controller-runtime.SetupSignalHandler() panics if called more than once in a process. So running the test multiple times (`go test -count=2`) reliably causes the test to panic. So don't use ctrl.SetupSignalHandler() in unit tests. Signed-off-by: Luke Shumaker <lukeshu@datawire.io>
Xunzhuo
reviewed
Oct 13, 2022
Member
Xunzhuo
left a comment
There was a problem hiding this comment.
Looks good, we can fix it with this way, but I wonder if we can make the first time creation, to be a update? The create/update/delete, I think they should be notified.
As the added godoc comment says, "This is better than iterating over snapshot.Updates because it handles the case where the the watchable.Map already contains entries before .Subscribe is called." The generalizes the fix that I made in the XDS translator. Signed-off-by: Luke Shumaker <lukeshu@datawire.io>
Signed-off-by: Luke Shumaker <lukeshu@datawire.io>
Contributor
Author
|
I've added 2 new commits based on discussion from today's call. |
arkodg
reviewed
Oct 13, 2022
arkodg
reviewed
Oct 13, 2022
I was going to do a type alias for `watchable.Update`, but:
internal/message/watchutil.go:7:6: generic type cannot be alias
So I just defined a new child type, which is fine because there aren't any
methods on Update.
Signed-off-by: Luke Shumaker <lukeshu@datawire.io>
arkodg
approved these changes
Oct 14, 2022
Contributor
arkodg
left a comment
There was a problem hiding this comment.
LGTM, thanks for catching the race and refactoring how snapshot updates are consumed !
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.
Fixes #504
The XDS translator's startup is racy; it needs to be changed to handle anything that's already in the
watchable.Mapwhen it calls.Subscribe. Since this turned out to be a common pattern I created a utility function, and moved everything over to use it.Also, a different test is broken with any
-count> 1, becausecontroller-runtime.SetupSignalHandler()is designed to panic if it is called more than once.I used
go test -v -count=300 ./...to validate that these changes make the intermittent test failures to go away.Also, I added
vendor/to.gitignoreso that I could rungo mod vendorand then add log statements to 3rd-party code while debugging.