Skip to content

container: fix concurrent map acccess #1963

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

Merged
merged 1 commit into from
Jun 13, 2018

Conversation

runcom
Copy link
Contributor

@runcom runcom commented Jun 13, 2018

GetSpec() can be called concurrently in manager/container.go.updateSpec()
results into a concurrent map access on the labels map because we're
directly updating the map inside GetSpec(). The labels map from the
container handler is not a copy of the map itself, just a reference,
that's why we're getting the concurrent map access.
Fix this by moving the label update with restartcount to the handler's
initialization method which is not called concurrently.

Signed-off-by: Antonio Murdaca [email protected]

@runcom
Copy link
Contributor Author

runcom commented Jun 13, 2018

@derekwaynecarr @sjenning @mrunalp PTAL

GetSpec() can be called concurrently in
manager/container.go.updateSpec()
results into a concurrent map access on the labels map because we're
directly updating the map inside GetSpec(). The labels map from the
container handler is not a copy of the map itself, just a reference,
that's why we're getting the concurrent map access.
Fix this by moving the label update with restartcount to the handler's
initialization method which is not called concurrently.

Signed-off-by: Antonio Murdaca <[email protected]>
@runcom runcom force-pushed the fix-race-cntr-handlers branch from c9d0286 to 42eeba5 Compare June 13, 2018 17:07
Copy link
Collaborator

@dashpole dashpole left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@dashpole
Copy link
Collaborator

Just curious, what behavior did you see that lead you to this fix?

@runcom
Copy link
Contributor Author

runcom commented Jun 13, 2018

Just curious, what behavior did you see that lead you to this fix?

we got a panic about a concurrent map access :)

@dashpole dashpole merged commit 9373cb2 into google:master Jun 13, 2018
@runcom runcom deleted the fix-race-cntr-handlers branch June 13, 2018 17:39
dashpole added a commit that referenced this pull request Jun 21, 2018
dashpole added a commit that referenced this pull request Jun 21, 2018
dashpole added a commit that referenced this pull request Jun 21, 2018
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.

2 participants