Merge pull request #1651 from hashicorp/b-fix-client-tests

Don't duplicate TaskKilled event and check for TaskSiblingFailed.
This commit is contained in:
Ivo Verberk 2016-08-25 20:47:04 +02:00 committed by GitHub
commit a33c5a6a52
2 changed files with 6 additions and 4 deletions

View file

@ -521,8 +521,8 @@ 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 lastE := state1.Events[len(state1.Events)-1]; lastE.Type != structs.TaskKilled {
return false, fmt.Errorf("got last event %v; want %v", lastE.Type, structs.TaskKilled)
if lastE := state1.Events[len(state1.Events)-1]; lastE.Type != structs.TaskSiblingFailed {
return false, fmt.Errorf("got last event %v; want %v", lastE.Type, structs.TaskSiblingFailed)
}
// Task Two should be failed

View file

@ -404,8 +404,10 @@ func (r *TaskRunner) run() {
// Store that the task has been destroyed and any associated error.
r.setState(structs.TaskStateDead, structs.NewTaskEvent(structs.TaskKilled).SetKillError(err))
// Store that task event that provides context on the task destroy.
r.setState(structs.TaskStateDead, r.destroyEvent)
// Store the task event that provides context on the task destroy.
if r.destroyEvent.Type != structs.TaskKilled {
r.setState(structs.TaskStateDead, r.destroyEvent)
}
r.runningLock.Lock()
r.running = false