-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
🐛 cache: clone maps to prevent data race when concurrently creating caches using the same options #3078
🐛 cache: clone maps to prevent data race when concurrently creating caches using the same options #3078
Conversation
a495593
to
f5684ee
Compare
/cherry-pick release-0.20 |
@sbueringer: once the present PR merges, I will cherry-pick it on top of In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/cherry-pick release-0.19 |
@sbueringer: once the present PR merges, I will cherry-pick it on top of In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
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.
Just a question + the linter finding
|
||
// Start go routines which re-use the above options struct. | ||
wg := sync.WaitGroup{} | ||
for range 2 { |
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.
2 is enough to regularly hit the issue with the race detector?
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.
yes
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.
(only if -race
is used of course)
/assign @alvaroaleman |
…hes using the same options
f5684ee
to
a1adc6b
Compare
LGTM label has been added. Git tree hash: 4209a5d785e31a029ebf7b0ecfb70dba12fdbf61
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman, chrischdi The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@sbueringer: new pull request created: #3079 In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
@sbueringer: new pull request created: #3080 In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
This PR adds clones to the cache packages
defaultOpts
function.This is necessary to prevent data races when creating caches in parallel using the same options.
Note: we found this in CAPI and workaround using: kubernetes-sigs/cluster-api#11707
Data races before:
Reproduction using the following command and unit test:
go test -race -count=1 -timeout 300s -run ^TestDefaultOptsRace$ sigs.k8s.io/controller-runtime/pkg/cache
File
pkg/cache/cache_race_test.go
: