simplify logic

bump log level
This commit is contained in:
Chelsea Holland Komlo 2018-03-15 17:45:00 -04:00
parent 86b7b3d2d9
commit d92703617c
4 changed files with 14 additions and 12 deletions

View File

@ -1024,9 +1024,11 @@ func (c *Client) updateNodeFromDriver(name string, fingerprint, health *structs.
if fingerprint != nil {
if c.config.Node.Drivers[name] == nil {
// if the driver info has not yet been set, do that here
hasChanged = true
c.config.Node.Drivers[name] = fingerprint
} else {
// the driver info has already been set, fix it up
if c.config.Node.Drivers[name].Detected != fingerprint.Detected {
hasChanged = true
c.config.Node.Drivers[name].Detected = fingerprint.Detected
@ -1054,7 +1056,11 @@ func (c *Client) updateNodeFromDriver(name string, fingerprint, health *structs.
c.config.Node.Drivers[name] = health
} else {
oldVal := c.config.Node.Drivers[name]
if !health.HealthCheckEquals(oldVal) {
if health.HealthCheckEquals(oldVal) {
// make sure we accurately reflect the last time a health check has been
// performed for the driver.
oldVal.UpdateTime = health.UpdateTime
} else {
hasChanged = true
c.config.Node.Drivers[name].MergeHealthCheck(health)
@ -1068,10 +1074,6 @@ func (c *Client) updateNodeFromDriver(name string, fingerprint, health *structs.
if err := c.submitNodeEvents(events); err != nil {
c.logger.Printf("[ERR] nomad.client Error when submitting node event: %v", err)
}
} else {
// make sure we accurately reflect the last time a health check has been
// performed for the driver.
oldVal.UpdateTime = health.UpdateTime
}
}
}

View File

@ -264,7 +264,7 @@ func (fm *FingerprintManager) setupFingerprinters(fingerprints []string) error {
f, err := fingerprint.NewFingerprint(name, fm.logger)
if err != nil {
fm.logger.Printf("[DEBUG] client.fingerprint_manager: fingerprinting for %v failed: %+v", name, err)
fm.logger.Printf("[ERR] client.fingerprint_manager: fingerprinting for %v failed: %+v", name, err)
return err
}

View File

@ -158,9 +158,7 @@ func (c *DriverChecker) hasDrivers(option *structs.Node) bool {
return false
}
if !enabled {
return false
}
return enabled
}
}
return true

View File

@ -9,6 +9,7 @@ import (
"github.com/hashicorp/nomad/helper/uuid"
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/stretchr/testify/require"
)
func TestStaticIterator_Reset(t *testing.T) {
@ -127,7 +128,9 @@ func TestDriverChecker(t *testing.T) {
}
func TestDriverChecker_HealthChecks(t *testing.T) {
require := require.New(t)
_, ctx := testContext(t)
nodes := []*structs.Node{
mock.Node(),
mock.Node(),
@ -182,9 +185,8 @@ func TestDriverChecker_HealthChecks(t *testing.T) {
testDrivers[i]: {},
}
checker := NewDriverChecker(ctx, drivers)
if act := checker.Feasible(c.Node); act != c.Result {
t.Fatalf("case(%d) failed: got %v; want %v", i, act, c.Result)
}
act := checker.Feasible(c.Node)
require.Equal(act, c.Result)
}
}