Skip to content

Commit

Permalink
enhancement: UpdateTask when Task is waiting for ShutdownDelay (#14775)
Browse files Browse the repository at this point in the history
Signed-off-by: Hemanth Krishna <[email protected]>
  • Loading branch information
DarthBenro008 authored Oct 6, 2022
1 parent 8bdeb58 commit a138821
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
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 @@ -8159,6 +8159,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

0 comments on commit a138821

Please sign in to comment.