scheduler: ignore allocations in terminal state

This commit is contained in:
Armon Dadgar
2015-09-17 21:25:55 -07:00
parent b7cd4a4ad7
commit 14009c5ce3
2 changed files with 16 additions and 0 deletions

View File

@@ -211,6 +211,9 @@ func (s *GenericScheduler) computeJobAllocs() error {
s.eval.JobID, err)
}
// Filter out the allocations in a terminal state
allocs = structs.FilterTerminalAllocs(allocs)
// Determine the tainted nodes containing job allocs
tainted, err := taintedNodes(s.state, allocs)
if err != nil {

View File

@@ -139,6 +139,19 @@ func TestServiceSched_JobModify(t *testing.T) {
}
noErr(t, h.State.UpsertAllocs(h.NextIndex(), allocs))
// Add a few terminal status allocations, these should be ignored
var terminal []*structs.Allocation
for i := 0; i < 5; i++ {
alloc := mock.Alloc()
alloc.Job = job
alloc.JobID = job.ID
alloc.NodeID = nodes[i].ID
alloc.Name = fmt.Sprintf("my-job.web[%d]", i)
alloc.DesiredStatus = structs.AllocDesiredStatusFailed
terminal = append(terminal, alloc)
}
noErr(t, h.State.UpsertAllocs(h.NextIndex(), terminal))
// Update the job
job2 := mock.Job()
job2.ID = job.ID