Skip to content

proxy/hybrid: add locking around userspace map - #13847

Merged
eparis merged 1 commit into
openshift:masterfrom
dcbw:hybrid-proxy-locking
May 1, 2017
Merged

eparis merged 1 commit into
openshift:masterfrom
dcbw:hybrid-proxy-locking

Conversation

@dcbw

@dcbw dcbw commented Apr 20, 2017 •

Copy link
Copy Markdown
Contributor

@dcbw

dcbw commented Apr 20, 2017

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Contributor

LGTM

@pecameron pecameron left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread pkg/proxy/hybrid/proxy.go Outdated
p.lock.Lock()
defer p.lock.Unlock()

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

Copy link
Copy Markdown
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?

@DirectXMan12 DirectXMan12 Apr 21, 2017 •

Copy link
Copy Markdown
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)

Comment thread pkg/proxy/hybrid/proxy.go Outdated
// (it's saved in the individual proxies as well)
usingUserspace map[types.NamespacedName]struct{}
usingUserspace map[types.NamespacedName]bool
lock sync.Mutex

Copy link
Copy Markdown
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?

@DirectXMan12 DirectXMan12 left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread pkg/proxy/hybrid/proxy.go Outdated
// 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
Copy Markdown
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).

Comment thread pkg/proxy/hybrid/proxy.go Outdated
Name: endpoint.Name,
}
if _, ok := p.usingUserspace[svcName]; !ok {
if !p.isUsingUserspace(endpoint.Namespace, endpoint.Name) {

Copy link
Copy Markdown
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.

Comment thread pkg/proxy/hybrid/proxy.go Outdated
p.lock.Lock()
defer p.lock.Unlock()

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

@DirectXMan12 DirectXMan12 Apr 21, 2017 •

Copy link
Copy Markdown
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)

@pravisankar pravisankar left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@dcbw
dcbw force-pushed the hybrid-proxy-locking branch from bfea7fa to 6563222 Compare April 22, 2017 19:16
@dcbw

dcbw commented Apr 22, 2017

Copy link
Copy Markdown
Contributor Author

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

@eparis

eparis commented Apr 24, 2017

Copy link
Copy Markdown
Member

[test]

@knobunc knobunc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@knobunc

knobunc commented Apr 24, 2017

Copy link
Copy Markdown
Contributor

[merge]

@DirectXMan12 DirectXMan12 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍

@dcbw
dcbw force-pushed the hybrid-proxy-locking branch from 6563222 to c0ee5dd Compare April 25, 2017 23:22
@dcbw

dcbw commented Apr 26, 2017

Copy link
Copy Markdown
Contributor Author

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
@dcbw
dcbw force-pushed the hybrid-proxy-locking branch from c0ee5dd to 826b674 Compare April 27, 2017 18:34
@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin test up to 826b674

@eparis

eparis commented Apr 27, 2017

Copy link
Copy Markdown
Member

[merge]

@openshift-bot

Copy link
Copy Markdown
Contributor

@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

knobunc commented Apr 28, 2017

Copy link
Copy Markdown
Contributor

@eparis

eparis commented May 1, 2017

Copy link
Copy Markdown
Member

[merge] #13977

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin merge up to 826b674

@openshift-bot

Copy link
Copy Markdown
Contributor

@eparis
eparis merged commit 7b4e657 into openshift:master May 1, 2017
@dcbw

dcbw commented May 1, 2017

Copy link
Copy Markdown
Contributor Author

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

8 participants