diff --git a/client/allocrunner/taskrunner/service_hook.go b/client/allocrunner/taskrunner/service_hook.go index f9e4ebb24..c5def6b29 100644 --- a/client/allocrunner/taskrunner/service_hook.go +++ b/client/allocrunner/taskrunner/service_hook.go @@ -140,7 +140,7 @@ func (h *serviceHook) Update(ctx context.Context, req *interfaces.TaskUpdateRequ return h.consul.UpdateTask(oldTaskServices, newTaskServices) } -func (h *serviceHook) Killing(ctx context.Context, req *interfaces.TaskPreKillRequest, resp *interfaces.TaskPreKillResponse) error { +func (h *serviceHook) PreKilling(ctx context.Context, req *interfaces.TaskPreKillRequest, resp *interfaces.TaskPreKillResponse) error { h.mu.Lock() defer h.mu.Unlock() diff --git a/client/allocrunner/taskrunner/service_hook_test.go b/client/allocrunner/taskrunner/service_hook_test.go index f8825be49..86772f0f5 100644 --- a/client/allocrunner/taskrunner/service_hook_test.go +++ b/client/allocrunner/taskrunner/service_hook_test.go @@ -3,11 +3,18 @@ package taskrunner import ( "testing" + "github.com/hashicorp/nomad/client/allocrunner/interfaces" "github.com/hashicorp/nomad/client/taskenv" "github.com/hashicorp/nomad/nomad/structs" "github.com/stretchr/testify/require" ) +// Statically assert the stats hook implements the expected interfaces +var _ interfaces.TaskPoststartHook = (*serviceHook)(nil) +var _ interfaces.TaskExitedHook = (*serviceHook)(nil) +var _ interfaces.TaskPreKillHook = (*serviceHook)(nil) +var _ interfaces.TaskUpdateHook = (*serviceHook)(nil) + // TestTaskRunner_ServiceHook_InterpolateServices asserts that all service // and check fields are properly interpolated. func TestTaskRunner_ServiceHook_InterpolateServices(t *testing.T) { diff --git a/client/allocrunner/taskrunner/task_runner_hooks.go b/client/allocrunner/taskrunner/task_runner_hooks.go index f26390faf..a41e76b7e 100644 --- a/client/allocrunner/taskrunner/task_runner_hooks.go +++ b/client/allocrunner/taskrunner/task_runner_hooks.go @@ -462,7 +462,7 @@ func (tr *TaskRunner) preKill() { var start time.Time if tr.logger.IsTrace() { start = time.Now() - tr.logger.Trace("running kill hook", "name", name, "start", start) + tr.logger.Trace("running prekill hook", "name", name, "start", start) } // Run the pre kill hook @@ -470,14 +470,14 @@ func (tr *TaskRunner) preKill() { var resp interfaces.TaskPreKillResponse if err := killHook.PreKilling(context.Background(), &req, &resp); err != nil { tr.emitHookError(err, name) - tr.logger.Error("kill hook failed", "name", name, "error", err) + tr.logger.Error("prekill hook failed", "name", name, "error", err) } // No need to persist as TaskKillResponse is currently empty if tr.logger.IsTrace() { end := time.Now() - tr.logger.Trace("finished kill hook", "name", name, "end", end, "duration", end.Sub(start)) + tr.logger.Trace("finished prekill hook", "name", name, "end", end, "duration", end.Sub(start)) } } } diff --git a/client/allocrunner/taskrunner/task_runner_test.go b/client/allocrunner/taskrunner/task_runner_test.go index aea2bd12b..def3ffea8 100644 --- a/client/allocrunner/taskrunner/task_runner_test.go +++ b/client/allocrunner/taskrunner/task_runner_test.go @@ -468,7 +468,7 @@ func TestTaskRunner_ShutdownDelay(t *testing.T) { } // No shutdown escape hatch for this delay, so don't set it too high - task.ShutdownDelay = 500 * time.Duration(testutil.TestMultiplier()) * time.Millisecond + task.ShutdownDelay = 1000 * time.Duration(testutil.TestMultiplier()) * time.Millisecond conf, cleanup := testTaskRunnerConfig(t, alloc, task.Name) defer cleanup()