diff --git a/client/allocrunner/taskrunner/stats_hook.go b/client/allocrunner/taskrunner/stats_hook.go index 741fb2075..01733e495 100644 --- a/client/allocrunner/taskrunner/stats_hook.go +++ b/client/allocrunner/taskrunner/stats_hook.go @@ -9,7 +9,6 @@ import ( hclog "github.com/hashicorp/go-hclog" "github.com/hashicorp/nomad/client/allocrunner/interfaces" 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 +94,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() == dstructs.DriverStatsNotImplemented.Error() { + if err.Error() == cstructs.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 316643a67..67fc21cba 100644 --- a/client/allocrunner/taskrunner/stats_hook_test.go +++ b/client/allocrunner/taskrunner/stats_hook_test.go @@ -7,7 +7,6 @@ import ( "github.com/hashicorp/nomad/client/allocrunner/interfaces" 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 +159,7 @@ func TestTaskRunner_StatsHook_NotImplemented(t *testing.T) { logger := testlog.HCLogger(t) su := newMockStatsUpdater() ds := &mockDriverStats{ - err: dstructs.DriverStatsNotImplemented, + err: cstructs.DriverStatsNotImplemented, } poststartReq := &interfaces.TaskPoststartRequest{DriverStats: ds} diff --git a/client/allocrunnerdeprecated/taskrunner/task_runner.go b/client/allocrunnerdeprecated/taskrunner/task_runner.go index efb162b0a..6d6e7852a 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() == dstructs.DriverStatsNotImplemented.Error() { + if err.Error() == cstructs.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/structs/structs.go b/client/structs/structs.go index 81c700e9e..043437041 100644 --- a/client/structs/structs.go +++ b/client/structs/structs.go @@ -4,6 +4,7 @@ package structs import ( "crypto/md5" + "errors" "io" "strconv" "time" @@ -437,3 +438,10 @@ func (h *HealthCheckResponse) AddDriverInfo(name string, driverInfo *structs.Dri h.Drivers[name] = driverInfo } + +// 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") diff --git a/drivers/docker/handle.go b/drivers/docker/handle.go index e15b542db..694bdfdf2 100644 --- a/drivers/docker/handle.go +++ b/drivers/docker/handle.go @@ -15,7 +15,6 @@ import ( plugin "github.com/hashicorp/go-plugin" cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/drivers/docker/docklog" - dstructs "github.com/hashicorp/nomad/drivers/shared/structs" "github.com/hashicorp/nomad/helper/stats" "github.com/hashicorp/nomad/plugins/drivers" "github.com/hashicorp/nomad/plugins/shared" @@ -83,8 +82,8 @@ func (h *taskHandle) Exec(ctx context.Context, cmd string, args []string) (*driv } execResult := &drivers.ExecTaskResult{ExitResult: &drivers.ExitResult{}} - stdout, _ := circbuf.NewBuffer(int64(dstructs.CheckBufSize)) - stderr, _ := circbuf.NewBuffer(int64(dstructs.CheckBufSize)) + stdout, _ := circbuf.NewBuffer(int64(cstructs.CheckBufSize)) + stderr, _ := circbuf.NewBuffer(int64(cstructs.CheckBufSize)) startOpts := docker.StartExecOptions{ Detach: false, Tty: false, diff --git a/drivers/shared/executor/executor.go b/drivers/shared/executor/executor.go index 511776368..7239fd577 100644 --- a/drivers/shared/executor/executor.go +++ b/drivers/shared/executor/executor.go @@ -24,7 +24,6 @@ import ( "github.com/hashicorp/consul-template/signals" cstructs "github.com/hashicorp/nomad/client/structs" - dstructs "github.com/hashicorp/nomad/drivers/shared/structs" ) const ( @@ -321,7 +320,7 @@ func ExecScript(ctx context.Context, dir string, env []string, attrs *syscall.Sy cmd.Env = env // Capture output - buf, _ := circbuf.NewBuffer(int64(dstructs.CheckBufSize)) + buf, _ := circbuf.NewBuffer(int64(cstructs.CheckBufSize)) cmd.Stdout = buf cmd.Stderr = buf diff --git a/drivers/shared/executor/executor_linux.go b/drivers/shared/executor/executor_linux.go index 07b5ee953..1a6a5864d 100644 --- a/drivers/shared/executor/executor_linux.go +++ b/drivers/shared/executor/executor_linux.go @@ -19,7 +19,6 @@ import ( multierror "github.com/hashicorp/go-multierror" "github.com/hashicorp/nomad/client/stats" cstructs "github.com/hashicorp/nomad/client/structs" - dstructs "github.com/hashicorp/nomad/drivers/shared/structs" "github.com/hashicorp/nomad/helper/discover" shelpers "github.com/hashicorp/nomad/helper/stats" "github.com/hashicorp/nomad/helper/uuid" @@ -403,7 +402,7 @@ func (l *LibcontainerExecutor) Signal(s os.Signal) error { func (l *LibcontainerExecutor) Exec(deadline time.Time, cmd string, args []string) ([]byte, int, error) { combined := append([]string{cmd}, args...) // Capture output - buf, _ := circbuf.NewBuffer(int64(dstructs.CheckBufSize)) + buf, _ := circbuf.NewBuffer(int64(cstructs.CheckBufSize)) process := &libcontainer.Process{ Args: combined, diff --git a/drivers/shared/structs/structs.go b/drivers/shared/structs/structs.go deleted file mode 100644 index 669980795..000000000 --- a/drivers/shared/structs/structs.go +++ /dev/null @@ -1,10 +0,0 @@ -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")