tr: remove unused DriverHandle interface

was causing typed nil interface panics and served no purpose
This commit is contained in:
Michael Schurter
2018-10-15 20:06:35 -07:00
parent 9c4a1d4c28
commit e026d6e80a
3 changed files with 2 additions and 40 deletions

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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