Merge pull request #1351 from hashicorp/b-unblockfailed-delete-job

UnblockFailed needs to untrack the job
This commit is contained in:
Alex Dadgar 2016-06-23 15:34:11 -07:00 committed by GitHub
commit 14f6b369ec
2 changed files with 13 additions and 1 deletions

View File

@ -336,6 +336,7 @@ func (b *BlockedEvals) UnblockFailed() {
if eval.TriggeredBy == structs.EvalTriggerMaxPlans {
unblock = append(unblock, eval)
delete(b.captured, id)
delete(b.jobs, eval.JobID)
}
}
@ -343,10 +344,15 @@ func (b *BlockedEvals) UnblockFailed() {
if eval.TriggeredBy == structs.EvalTriggerMaxPlans {
unblock = append(unblock, eval)
delete(b.escaped, id)
delete(b.jobs, eval.JobID)
b.stats.TotalEscaped -= 1
}
}
b.evalBroker.EnqueueAll(unblock)
if l := len(unblock); l > 0 {
b.stats.TotalBlocked -= l
b.evalBroker.EnqueueAll(unblock)
}
}
// GetDuplicates returns all the duplicate evaluations and blocks until the

View File

@ -404,6 +404,12 @@ func TestBlockedEvals_UnblockFailed(t *testing.T) {
// Trigger an unblock fail
blocked.UnblockFailed()
// Verify UnblockFailed caused the eval to be immediately unblocked
blockedStats := blocked.Stats()
if blockedStats.TotalBlocked != 0 && blockedStats.TotalEscaped != 0 {
t.Fatalf("bad: %#v", blockedStats)
}
testutil.WaitForResult(func() (bool, error) {
// Verify Unblock caused an enqueue
brokerStats := broker.Stats()