-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
proxy/hybrid: add locking around userspace map #13847
Conversation
I'm not actually sure how to easily test this; can somebody either test it out for me, or describe how I would do so? Thanks! |
LGTM |
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.
Not sure what is being locked or the sequences that are causing the problems. So not sure why the lock does anything useful.
pkg/proxy/hybrid/proxy.go
Outdated
p.lock.Lock() | ||
defer p.lock.Unlock() | ||
|
||
p.usingUserspace = make(map[types.NamespacedName]bool) |
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.
Is this already set up in line 43?
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.
we swap out a new map every time (in response to @pecameron)
pkg/proxy/hybrid/proxy.go
Outdated
@@ -24,7 +25,8 @@ type HybridProxier struct { | |||
|
|||
// TODO(directxman12): figure out a good way to avoid duplicating this information | |||
// (it's saved in the individual proxies as well) | |||
usingUserspace map[types.NamespacedName]struct{} | |||
usingUserspace map[types.NamespacedName]bool | |||
lock sync.Mutex |
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.
What data are you locking with this lock?
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.
a couple of minor changes
pkg/proxy/hybrid/proxy.go
Outdated
@@ -24,7 +25,8 @@ type HybridProxier struct { | |||
|
|||
// TODO(directxman12): figure out a good way to avoid duplicating this information | |||
// (it's saved in the individual proxies as well) | |||
usingUserspace map[types.NamespacedName]struct{} | |||
usingUserspace map[types.NamespacedName]bool |
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.
please leave this as struct{}
-- it's the recommended method doing sets (it takes up no space for the value).
pkg/proxy/hybrid/proxy.go
Outdated
Name: endpoint.Name, | ||
} | ||
if _, ok := p.usingUserspace[svcName]; !ok { | ||
if !p.isUsingUserspace(endpoint.Namespace, endpoint.Name) { |
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.
I would just lock around this entire block, instead of locking on each operation like this.
pkg/proxy/hybrid/proxy.go
Outdated
p.lock.Lock() | ||
defer p.lock.Unlock() | ||
|
||
p.usingUserspace = make(map[types.NamespacedName]bool) |
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.
we swap out a new map every time (in response to @pecameron)
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.
LGTM
bfea7fa
to
6563222
Compare
@DirectXMan12 updated; now with just the locking and went back to struct{} maps. PTAL thanks! |
[test] |
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.
LGTM
[merge] |
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.
LGTM 👍
6563222
to
c0ee5dd
Compare
re-[test] this issue #13067 |
The map may be accessed concurrently from different goroutines so we need to lock it. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1444125
c0ee5dd
to
826b674
Compare
Evaluated for origin test up to 826b674 |
[merge] |
continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/1004/) (Base Commit: b6b92db) |
[merge] flaked on #13942 (logs: https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/1004/) |
[merge] #13977 |
Evaluated for origin merge up to 826b674 |
continuous-integration/openshift-jenkins/merge FAILURE (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_origin/526/) (Base Commit: 09ea247) |
[merge] flake is #13942 |
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1444125
@openshift/networking @knobunc @DirectXMan12 @eparis