code review fixups
This commit is contained in:
parent
ed8c8afbcd
commit
1f31b39fe8
|
@ -963,33 +963,33 @@ func (c *Client) updateNodeFromFingerprint(response *cstructs.FingerprintRespons
|
|||
|
||||
var nodeHasChanged bool
|
||||
|
||||
for name, new_val := range response.Attributes {
|
||||
for name, newVal := range response.Attributes {
|
||||
old_val := c.config.Node.Attributes[name]
|
||||
if old_val == new_val {
|
||||
if old_val == newVal {
|
||||
continue
|
||||
}
|
||||
|
||||
nodeHasChanged = true
|
||||
if new_val == "" {
|
||||
if newVal == "" {
|
||||
delete(c.config.Node.Attributes, name)
|
||||
} else {
|
||||
c.config.Node.Attributes[name] = new_val
|
||||
c.config.Node.Attributes[name] = newVal
|
||||
}
|
||||
}
|
||||
|
||||
// update node links and resources from the diff created from
|
||||
// fingerprinting
|
||||
for name, new_val := range response.Links {
|
||||
for name, newVal := range response.Links {
|
||||
old_val := c.config.Node.Links[name]
|
||||
if old_val == new_val {
|
||||
if old_val == newVal {
|
||||
continue
|
||||
}
|
||||
|
||||
nodeHasChanged = true
|
||||
if new_val == "" {
|
||||
if newVal == "" {
|
||||
delete(c.config.Node.Links, name)
|
||||
} else {
|
||||
c.config.Node.Links[name] = new_val
|
||||
c.config.Node.Links[name] = newVal
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1528,8 +1528,6 @@ func (c *Client) updateNode() {
|
|||
// watchNodeUpdates blocks until it is edge triggered. Once triggered,
|
||||
// it will update the client node copy and re-register the node.
|
||||
func (c *Client) watchNodeUpdates() {
|
||||
c.logger.Printf("[DEBUG] client: starting process to watch for node updates.")
|
||||
|
||||
var hasChanged bool
|
||||
for {
|
||||
select {
|
||||
|
|
|
@ -129,7 +129,7 @@ func TestClient_TriggerNodeUpdate(t *testing.T) {
|
|||
driver.CheckForMockDriver(t)
|
||||
t.Parallel()
|
||||
|
||||
// these constants are only defined when nomad_test is enabled, so these fail
|
||||
// These constants are only defined when nomad_test is enabled, so these fail
|
||||
// our linter without explicit disabling.
|
||||
c1 := testClient(t, func(c *config.Config) {
|
||||
c.Options = map[string]string{
|
||||
|
@ -144,10 +144,10 @@ func TestClient_TriggerNodeUpdate(t *testing.T) {
|
|||
go c1.watchNodeUpdates()
|
||||
c1.updateNode()
|
||||
// This needs to be directly called as otherwise the client hangs on
|
||||
// attempt to register with a server. S[ecifically, retryRegisterNode is
|
||||
// attempt to register with a server. Specifically, retryRegisterNode is
|
||||
// blocking
|
||||
|
||||
// test that the client's copy of the node is also updated
|
||||
// Test that the client's copy of the node is also updated
|
||||
testutil.WaitForResult(func() (bool, error) {
|
||||
mockDriverStatusCopy := c1.configCopy.Node.Attributes[mockDriverName]
|
||||
if mockDriverStatusCopy == "" {
|
||||
|
@ -158,7 +158,7 @@ func TestClient_TriggerNodeUpdate(t *testing.T) {
|
|||
t.Fatalf("err: %v", err)
|
||||
})
|
||||
|
||||
// test that the client's copy of the node is also updated
|
||||
// Test that the client's copy of the node is also updated
|
||||
testutil.WaitForResult(func() (bool, error) {
|
||||
mockDriverStatusCopy := c1.configCopy.Node.Attributes[mockDriverName]
|
||||
if mockDriverStatusCopy != "" {
|
||||
|
@ -178,8 +178,8 @@ func TestClient_Fingerprint_Periodic(t *testing.T) {
|
|||
// our linter without explicit disabling.
|
||||
c1 := TestClient(t, func(c *config.Config) {
|
||||
c.Options = map[string]string{
|
||||
driver.ShutdownPeriodicAfter: "true", // nolint: varcheck
|
||||
driver.ShutdownPeriodicDuration: "3", // nolint: varcheck
|
||||
driver.ShutdownPeriodicAfter: "true",
|
||||
driver.ShutdownPeriodicDuration: "3",
|
||||
}
|
||||
})
|
||||
defer c1.Shutdown()
|
||||
|
|
|
@ -75,7 +75,7 @@ func TestFingerprintManager_Run_ResourcesFingerprint(t *testing.T) {
|
|||
require.Nil(err)
|
||||
require.NotEqual(0, node.Resources.CPU)
|
||||
require.NotEqual(0, node.Resources.MemoryMB)
|
||||
require.NotEqual(0, node.Resources.DiskMB)
|
||||
require.NotZero(node.Resources.DiskMB)
|
||||
}
|
||||
|
||||
func TestFingerprintManager_Fingerprint_Run(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue