Use client state

This commit is contained in:
Alex Dadgar 2015-12-16 14:34:17 -08:00
parent 7bec30c2b3
commit 561ccdb441
1 changed files with 7 additions and 6 deletions

View File

@ -1489,18 +1489,19 @@ type Allocation struct {
// TerminalStatus returns if the desired or actual status is terminal and
// will no longer transition.
func (a *Allocation) TerminalStatus() bool {
// First check the desired state and if that isn't terminal, check client
// state.
switch a.DesiredStatus {
case AllocDesiredStatusStop, AllocDesiredStatusEvict, AllocDesiredStatusFailed:
return true
default:
// If all tasks are dead, the alloc is terminal.
for _, state := range a.TaskStates {
if state.State != TaskStateDead {
return false
}
}
switch a.ClientStatus {
case AllocClientStatusDead, AllocClientStatusFailed:
return true
default:
return false
}
}