🐛 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 DetailsIn 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 DetailsIn 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
left a comment
There was a problem hiding this comment.
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.
2 is enough to regularly hit the issue with the race detector?
There was a problem hiding this comment.
(only if -race is used of course)
|
/assign @alvaroaleman |
…hes using the same options
f5684ee to
a1adc6b
Compare
|
LGTM label has been added. DetailsGit 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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@sbueringer: new pull request created: #3079 DetailsIn 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 DetailsIn 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
defaultOptsfunction.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/cacheFile
pkg/cache/cache_race_test.go: