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

Node access is done using locked Node copy #3461

Merged
merged 3 commits into from
Oct 30, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ BUG FIXES:
[GH_-3452]
* client: Fix lock contention that could cause a node to miss a heartbeat and
be marked as down [GH-3195]
* client: Fix data race that could lead to concurrent map read/writes during
hearbeating and fingerprinting [GH-3461]
* driver/docker: Fix docker user specified syslogging [GH-3184]
* driver/docker: Fix issue where CPU usage statistics were artificially high
[GH-3229]
Expand Down
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ func (c *Client) CollectAllAllocs() error {
func (c *Client) Node() *structs.Node {
c.configLock.RLock()
defer c.configLock.RUnlock()
return c.config.Node
return c.configCopy.Node
}
Copy link
Contributor

Choose a reason for hiding this comment

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

There are other public methods in this file that access fields from config rather than configcopy. - datacenter/region/nodeid etc. None of them are maps, but are other lurking races there as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those fields are immutable once the Client is returned, the mutable fields are the attributes and links, which surfaced via the Node() and Fingerprint() using the same Node object rather than the readonly copy.


// StatsReporter exposes the various APIs related resource usage of a Nomad
Expand Down