diff --git a/client/allocrunner/taskrunner/stats_hook.go b/client/allocrunner/taskrunner/stats_hook.go index ec0415e2f..741fb2075 100644 --- a/client/allocrunner/taskrunner/stats_hook.go +++ b/client/allocrunner/taskrunner/stats_hook.go @@ -8,8 +8,8 @@ import ( hclog "github.com/hashicorp/go-hclog" "github.com/hashicorp/nomad/client/allocrunner/interfaces" - "github.com/hashicorp/nomad/client/driver" cstructs "github.com/hashicorp/nomad/client/structs" + dstructs "github.com/hashicorp/nomad/drivers/shared/structs" ) // StatsUpdater is the interface required by the StatsHook to update stats. @@ -95,7 +95,7 @@ func (h *statsHook) collectResourceUsageStats(handle interfaces.DriverStats, sto ru, err := handle.Stats() if err != nil { // Check if the driver doesn't implement stats - if err.Error() == driver.DriverStatsNotImplemented.Error() { + if err.Error() == dstructs.DriverStatsNotImplemented.Error() { h.logger.Debug("driver does not support stats") return } diff --git a/client/allocrunner/taskrunner/stats_hook_test.go b/client/allocrunner/taskrunner/stats_hook_test.go index 87e2ce40b..316643a67 100644 --- a/client/allocrunner/taskrunner/stats_hook_test.go +++ b/client/allocrunner/taskrunner/stats_hook_test.go @@ -6,8 +6,8 @@ import ( "time" "github.com/hashicorp/nomad/client/allocrunner/interfaces" - "github.com/hashicorp/nomad/client/driver" cstructs "github.com/hashicorp/nomad/client/structs" + dstructs "github.com/hashicorp/nomad/drivers/shared/structs" "github.com/hashicorp/nomad/helper/testlog" "github.com/stretchr/testify/require" ) @@ -160,7 +160,7 @@ func TestTaskRunner_StatsHook_NotImplemented(t *testing.T) { logger := testlog.HCLogger(t) su := newMockStatsUpdater() ds := &mockDriverStats{ - err: driver.DriverStatsNotImplemented, + err: dstructs.DriverStatsNotImplemented, } poststartReq := &interfaces.TaskPoststartRequest{DriverStats: ds} diff --git a/client/allocrunnerdeprecated/taskrunner/task_runner.go b/client/allocrunnerdeprecated/taskrunner/task_runner.go index 4df5f94dc..efb162b0a 100644 --- a/client/allocrunnerdeprecated/taskrunner/task_runner.go +++ b/client/allocrunnerdeprecated/taskrunner/task_runner.go @@ -1601,7 +1601,7 @@ func (r *TaskRunner) collectResourceUsageStats(stopCollection <-chan struct{}) { if err != nil { // Check if the driver doesn't implement stats - if err.Error() == driver.DriverStatsNotImplemented.Error() { + if err.Error() == dstructs.DriverStatsNotImplemented.Error() { r.logger.Printf("[DEBUG] client: driver for task %q in allocation %q doesn't support stats", r.task.Name, r.alloc.ID) return } diff --git a/client/driver/driver.go b/client/driver/driver.go index 4cca5b917..fe5e366fb 100644 --- a/client/driver/driver.go +++ b/client/driver/driver.go @@ -3,7 +3,6 @@ package driver import ( "context" "crypto/md5" - "errors" "fmt" "io" "log" @@ -30,10 +29,6 @@ var ( "qemu": NewQemuDriver, "rkt": NewRktDriver, } - - // DriverStatsNotImplemented is the error to be returned if a driver doesn't - // implement stats. - DriverStatsNotImplemented = errors.New("stats not implemented for driver") ) // NewDriver is used to instantiate and return a new driver diff --git a/drivers/shared/structs/structs.go b/drivers/shared/structs/structs.go index 733640aa9..669980795 100644 --- a/drivers/shared/structs/structs.go +++ b/drivers/shared/structs/structs.go @@ -1,4 +1,10 @@ package structs +import "errors" + // CheckBufSize is the size of the buffer that is used for job output const CheckBufSize = 4 * 1024 + +// DriverStatsNotImplemented is the error to be returned if a driver doesn't +// implement stats. +var DriverStatsNotImplemented = errors.New("stats not implemented for driver")