-
Notifications
You must be signed in to change notification settings - Fork 1.4k
🐛 clustercache: Prevent concurrent map read/write when creating a cache #11707
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
🐛 clustercache: Prevent concurrent map read/write when creating a cache #11707
Conversation
/area clustercache |
@chrischdi: The label(s) 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. |
b204cbc
to
3aa7711
Compare
/assign @sbueringer @fabriziopandini |
/area clustercache |
@chrischdi: The label(s) 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. |
@@ -213,13 +214,19 @@ func createUncachedClient(scheme *runtime.Scheme, config *rest.Config, httpClien | |||
|
|||
// createCachedClient creates a cached client for the given cluster, based on the rest.Config. | |||
func createCachedClient(ctx context.Context, clusterAccessorConfig *clusterAccessorConfig, config *rest.Config, httpClient *http.Client, mapper meta.RESTMapper) (client.Client, *stoppableCache, error) { | |||
// Create the cache for the cluster. | |||
// The byObject map needs to be cloned to not hit concurrent read/writes on the Namespaces map. |
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.
Let's open a small issue to track removal of this code once it's fixed in CR
Thx! /lgtm |
LGTM label has been added. Git tree hash: c0111678afb5789b766c1bc7ed7ee54cf5e5dc89
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sbueringer 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 |
/cherry-pick release-1.9 |
@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. |
@sbueringer: new pull request created: #11709 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. |
What this PR does / why we need it:
The clustercache has an issue with concurrent read writes. Found data races:
Reproducible with the following unit test and by running it including the
-race
flag, e.g.go test -race -count=1 -timeout 300s -run '^Test_createCachedClient$'
:Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #