-
Notifications
You must be signed in to change notification settings - Fork 113
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
Fix a data race in watcher.go #2952
Conversation
o, err := ow.pollFunc() | ||
results <- result{Obj: o, Err: err} |
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.
The race was due to this write to obj
happening across goroutines. We can instead communicate that state via the results
channel.
Does the PR have any schema changes?Looking good! No breaking changes found. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2952 +/- ##
==========================================
+ Coverage 29.16% 29.18% +0.01%
==========================================
Files 61 61
Lines 8194 8196 +2
==========================================
+ Hits 2390 2392 +2
Misses 5600 5600
Partials 204 204 ☔ View full report in Codecov by Sentry. |
provider/pkg/watcher/watcher_test.go
Outdated
@@ -20,6 +20,7 @@ import ( | |||
"testing" | |||
"time" | |||
|
|||
"go.uber.org/atomic" |
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.
Could we use sync/atomic
instead?
Ran into a small data race while testing await logic.
This PR fixes the underlying race condition as well as a race-y test.