Skip to content
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

Merged
merged 1 commit into from May 1, 2017

Conversation

dcbw
Copy link
Member

@dcbw dcbw commented Apr 20, 2017

@dcbw
Copy link
Member Author

dcbw commented Apr 20, 2017

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!

@danwinship
Copy link
Contributor

LGTM

Copy link
Contributor

@pecameron pecameron left a 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.

p.lock.Lock()
defer p.lock.Unlock()

p.usingUserspace = make(map[types.NamespacedName]bool)
Copy link
Contributor

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?

Copy link
Contributor

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)

@@ -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
Copy link
Contributor

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?

Copy link
Contributor

@DirectXMan12 DirectXMan12 left a 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

@@ -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
Copy link
Contributor

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).

Name: endpoint.Name,
}
if _, ok := p.usingUserspace[svcName]; !ok {
if !p.isUsingUserspace(endpoint.Namespace, endpoint.Name) {
Copy link
Contributor

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.

p.lock.Lock()
defer p.lock.Unlock()

p.usingUserspace = make(map[types.NamespacedName]bool)
Copy link
Contributor

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)

Copy link

@pravisankar pravisankar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dcbw
Copy link
Member Author

dcbw commented Apr 22, 2017

@DirectXMan12 updated; now with just the locking and went back to struct{} maps. PTAL thanks!

@eparis
Copy link
Member

eparis commented Apr 24, 2017

[test]

Copy link
Contributor

@knobunc knobunc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@knobunc
Copy link
Contributor

knobunc commented Apr 24, 2017

[merge]

Copy link
Contributor

@DirectXMan12 DirectXMan12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@dcbw
Copy link
Member Author

dcbw commented Apr 26, 2017

re-[test] this issue #13067

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 27, 2017
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
@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 826b674

@eparis
Copy link
Member

eparis commented Apr 27, 2017

[merge]

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/1004/) (Base Commit: b6b92db)

@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 27, 2017
@knobunc
Copy link
Contributor

knobunc commented Apr 28, 2017

@eparis
Copy link
Member

eparis commented May 1, 2017

[merge] #13977

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 826b674

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/merge FAILURE (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_origin/526/) (Base Commit: 09ea247)

@eparis eparis merged commit 7b4e657 into openshift:master May 1, 2017
@dcbw
Copy link
Member Author

dcbw commented May 1, 2017

[merge] flake is #13942

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants