908bfab4c2
0.9.0beta2 contains a regression where artifact download errors would not cause a task restart and instead immediately fail the task. This restores the pre-0.9 behavior of retrying all artifact errors and adds missing tests.
38 lines
689 B
Go
38 lines
689 B
Go
package taskrunner
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/hashicorp/nomad/nomad/structs"
|
|
)
|
|
|
|
const (
|
|
errTaskNotRunning = "Task not running"
|
|
)
|
|
|
|
var (
|
|
ErrTaskNotRunning = errors.New(errTaskNotRunning)
|
|
)
|
|
|
|
// NewHookError contains an underlying err and a pre-formatted task event.
|
|
func NewHookError(err error, taskEvent *structs.TaskEvent) error {
|
|
return &hookError{
|
|
err: err,
|
|
taskEvent: taskEvent,
|
|
}
|
|
}
|
|
|
|
type hookError struct {
|
|
taskEvent *structs.TaskEvent
|
|
err error
|
|
}
|
|
|
|
func (h *hookError) Error() string {
|
|
return h.err.Error()
|
|
}
|
|
|
|
// Recoverable is true if the underlying error is recoverable.
|
|
func (h *hookError) IsRecoverable() bool {
|
|
return structs.IsRecoverable(h.err)
|
|
}
|