Skip to content

Commit

Permalink
Merge pull request #3461 from hashicorp/b-node-race
Browse files Browse the repository at this point in the history
Node access is done using locked Node copy
  • Loading branch information
dadgar committed Oct 30, 2017
2 parents 2464b02 + af7e141 commit 2d77197
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
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
}

// StatsReporter exposes the various APIs related resource usage of a Nomad
Expand Down
2 changes: 1 addition & 1 deletion client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func TestClient_HasNodeChanged(t *testing.T) {
c := testClient(t, nil)
defer c.Shutdown()

node := c.Node()
node := c.config.Node
attrHash, err := hashstructure.Hash(node.Attributes, nil)
if err != nil {
c.logger.Printf("[DEBUG] client: unable to calculate node attributes hash: %v", err)
Expand Down

0 comments on commit 2d77197

Please sign in to comment.