Skip to content

Commit

Permalink
simplify logic
Browse files Browse the repository at this point in the history
bump log level
  • Loading branch information
chelseakomlo committed Mar 15, 2018
1 parent 8f3b9fb commit 6dd47cb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
12 changes: 7 additions & 5 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion client/fingerprint_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 1 addition & 3 deletions scheduler/feasible.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ func (c *DriverChecker) hasDrivers(option *structs.Node) bool {
return false
}

if !enabled {
return false
}
return enabled
}
}
return true
Expand Down
8 changes: 5 additions & 3 deletions scheduler/feasible_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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)
}
}

Expand Down

0 comments on commit 6dd47cb

Please sign in to comment.