From 89ffc9602d543afe2a9be00824f92492fb23b747 Mon Sep 17 00:00:00 2001 From: Chelsea Holland Komlo Date: Wed, 21 Mar 2018 15:32:40 -0400 Subject: [PATCH] fix up scheduling test --- scheduler/feasible.go | 31 ++++++++++++++++--------------- scheduler/feasible_test.go | 2 +- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/scheduler/feasible.go b/scheduler/feasible.go index b8bfc758b1a..4b1a995710b 100644 --- a/scheduler/feasible.go +++ b/scheduler/feasible.go @@ -134,8 +134,7 @@ func (c *DriverChecker) hasDrivers(option *structs.Node) bool { // corresponds with every driver. As a Nomad server might be on a later // version than a Nomad client, we need to check for compatibility here // to verify the client supports this. - if option.Drivers != nil { - driverInfo := option.Drivers[driver] + if driverInfo, ok := option.Drivers[driver]; ok { if driverInfo == nil { c.ctx.Logger(). Printf("[WARN] scheduler.DriverChecker: node %v has no driver info set for %v", @@ -144,21 +143,23 @@ func (c *DriverChecker) hasDrivers(option *structs.Node) bool { } return driverInfo.Detected && driverInfo.Healthy - } else { - value, ok := option.Attributes[driverStr] - if !ok { - return false - } + } - enabled, err := strconv.ParseBool(value) - if err != nil { - c.ctx.Logger(). - Printf("[WARN] scheduler.DriverChecker: node %v has invalid driver setting %v: %v", - option.ID, driverStr, value) - return false - } + value, ok := option.Attributes[driverStr] + if !ok { + return false + } - return enabled + enabled, err := strconv.ParseBool(value) + if err != nil { + c.ctx.Logger(). + Printf("[WARN] scheduler.DriverChecker: node %v has invalid driver setting %v: %v", + option.ID, driverStr, value) + return false + } + + if !enabled { + return false } } return true diff --git a/scheduler/feasible_test.go b/scheduler/feasible_test.go index 087945c6415..7b2129e1c78 100644 --- a/scheduler/feasible_test.go +++ b/scheduler/feasible_test.go @@ -127,7 +127,7 @@ func TestDriverChecker(t *testing.T) { } } -func TestDriverChecker_HealthChecks(t *testing.T) { +func Test_HealthChecks(t *testing.T) { require := require.New(t) _, ctx := testContext(t)