Commit c9340637 authored by Alex Dadgar's avatar Alex Dadgar
Browse files

FinishedAt only records when the task has actually started

parent e5476981
Showing with 5 additions and 5 deletions
+5 -5
......@@ -388,8 +388,11 @@ func (r *AllocRunner) setTaskState(taskName, state string, event *structs.TaskEv
taskState.StartedAt = time.Now().UTC()
}
case structs.TaskStateDead:
// Capture the finished time
taskState.FinishedAt = time.Now().UTC()
// Capture the finished time. If it has never started there is no finish
// time
if !taskState.StartedAt.IsZero() {
taskState.FinishedAt = time.Now().UTC()
}
// Find all tasks that are not the one that is dead and check if the one
// that is dead is a leader
......
......@@ -633,9 +633,6 @@ func TestAllocRunner_TaskFailed_KillTG(t *testing.T) {
if state1.State != structs.TaskStateDead {
return false, fmt.Errorf("got state %v; want %v", state1.State, structs.TaskStateDead)
}
if state1.FinishedAt.IsZero() || state1.StartedAt.IsZero() {
return false, fmt.Errorf("expected to have a start and finish time")
}
if len(state1.Events) < 2 {
// At least have a received and destroyed
return false, fmt.Errorf("Unexpected number of events")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment