Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: UpdateTask when Task is waiting for ShutdownDelay #14775

Merged
merged 1 commit into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/14775.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
client: Added a TaskEvent when task shutdown is waiting on shutdown_delay
```
4 changes: 4 additions & 0 deletions client/allocrunner/taskrunner/task_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,10 @@ func (tr *TaskRunner) handleKill(resultCh <-chan *drivers.ExitResult) *drivers.E
if delay := tr.Task().ShutdownDelay; delay != 0 {
tr.logger.Debug("waiting before killing task", "shutdown_delay", delay)

ev := structs.NewTaskEvent(structs.TaskWaitingShuttingDownDelay).
SetDisplayMessage(fmt.Sprintf("Waiting for shutdown_delay of %s before killing the task.", delay))
tr.UpdateState(structs.TaskStatePending, ev)

select {
case result := <-resultCh:
return result
Expand Down
4 changes: 4 additions & 0 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8153,6 +8153,10 @@ const (

// TaskClientReconnected indicates that the client running the task disconnected.
TaskClientReconnected = "Reconnected"

// TaskWaitingShuttingDownDelay indicates that the task is waiting for
// shutdown delay before being TaskKilled
TaskWaitingShuttingDownDelay = "Waiting for shutdown delay"
)

// TaskEvent is an event that effects the state of a task and contains meta-data
Expand Down