From e026d6e80a158244c8a5cfcb65f047633d7bc9ce Mon Sep 17 00:00:00 2001 From: Michael Schurter Date: Mon, 15 Oct 2018 20:06:35 -0700 Subject: [PATCH] tr: remove unused DriverHandle interface was causing typed nil interface panics and served no purpose --- .../taskrunner/interfaces/handle.go | 36 ------------------- client/allocrunner/taskrunner/task_runner.go | 3 +- .../taskrunner/task_runner_getters.go | 3 +- 3 files changed, 2 insertions(+), 40 deletions(-) diff --git a/client/allocrunner/taskrunner/interfaces/handle.go b/client/allocrunner/taskrunner/interfaces/handle.go index a0737c74f..3fafaba15 100644 --- a/client/allocrunner/taskrunner/interfaces/handle.go +++ b/client/allocrunner/taskrunner/interfaces/handle.go @@ -1,45 +1,9 @@ package interfaces import ( - "context" "time" - - cstructs "github.com/hashicorp/nomad/client/structs" - "github.com/hashicorp/nomad/nomad/structs" - "github.com/hashicorp/nomad/plugins/drivers" ) -// DriverHandle wraps operations to a driver such that they are operated on a specific -// task -type DriverHandle interface { - // ID returns the task ID - ID() string - - // WaitCh is used to return a channel used to wait for task completion - WaitCh(context.Context) (<-chan *drivers.ExitResult, error) - - // Update is used to update the task if possible and update task related - // configurations. - Update(task *structs.Task) error - - // Kill is used to stop the task - Kill() error - - // Stats returns aggregated stats of the driver - Stats() (*cstructs.TaskResourceUsage, error) - - // Signal is used to send a signal to the task - Signal(s string) error - - // ScriptExecutor is an interface used to execute commands such as - // health check scripts in the a DriverHandle's context. - ScriptExecutor - - // Network returns the driver's network or nil if the driver did not - // create a network. - Network() *cstructs.DriverNetwork -} - // ScriptExecutor is an interface that supports Exec()ing commands in the // driver's context. Split out of DriverHandle to ease testing. type ScriptExecutor interface { diff --git a/client/allocrunner/taskrunner/task_runner.go b/client/allocrunner/taskrunner/task_runner.go index c3a49c94a..49c560b50 100644 --- a/client/allocrunner/taskrunner/task_runner.go +++ b/client/allocrunner/taskrunner/task_runner.go @@ -15,7 +15,6 @@ import ( "github.com/hashicorp/hcl2/hcldec" "github.com/hashicorp/nomad/client/allocdir" "github.com/hashicorp/nomad/client/allocrunner/interfaces" - tinterfaces "github.com/hashicorp/nomad/client/allocrunner/taskrunner/interfaces" "github.com/hashicorp/nomad/client/allocrunner/taskrunner/restarts" "github.com/hashicorp/nomad/client/allocrunner/taskrunner/state" "github.com/hashicorp/nomad/client/config" @@ -548,7 +547,7 @@ func (tr *TaskRunner) initDriver() error { // handleDestroy will retry with an exponential backoff and will give up at a // given limit. It returns whether the task was destroyed and the error // associated with the last kill attempt. -func (tr *TaskRunner) handleDestroy(handle tinterfaces.DriverHandle) (destroyed bool, err error) { +func (tr *TaskRunner) handleDestroy(handle *DriverHandle) (destroyed bool, err error) { // Cap the number of times we attempt to kill the task. for i := 0; i < killFailureLimit; i++ { if err = handle.Kill(); err != nil { diff --git a/client/allocrunner/taskrunner/task_runner_getters.go b/client/allocrunner/taskrunner/task_runner_getters.go index 8a5661be0..61eaf9711 100644 --- a/client/allocrunner/taskrunner/task_runner_getters.go +++ b/client/allocrunner/taskrunner/task_runner_getters.go @@ -1,7 +1,6 @@ package taskrunner import ( - "github.com/hashicorp/nomad/client/allocrunner/taskrunner/interfaces" "github.com/hashicorp/nomad/nomad/structs" ) @@ -51,7 +50,7 @@ func (tr *TaskRunner) setVaultToken(token string) { // getDriverHandle returns a driver handle and its result proxy. Use the // result proxy instead of the handle's WaitCh. -func (tr *TaskRunner) getDriverHandle() interfaces.DriverHandle { +func (tr *TaskRunner) getDriverHandle() *DriverHandle { tr.handleLock.Lock() defer tr.handleLock.Unlock() return tr.handle