Do a full loop of the sys-job iterator before the fast-path check

This commit is contained in:
Alex Dadgar 2015-10-20 17:11:57 -07:00
parent fcee850c2b
commit 40fa9cbb89
1 changed files with 6 additions and 10 deletions

View File

@ -452,10 +452,14 @@ func (n *Node) createNodeEvals(nodeID string, nodeIndex uint64) ([]string, uint6
if err != nil {
return nil, 0, fmt.Errorf("failed to find system jobs for '%s': %v", nodeID, err)
}
nextJob := sysJobsIter.Next()
var sysJobs []*structs.Job
for job := sysJobsIter.Next(); job != nil; job = sysJobsIter.Next() {
sysJobs = append(sysJobs, job.(*structs.Job))
}
// Fast-path if nothing to do
if len(allocs) == 0 && nextJob == nil {
if len(allocs) == 0 && len(sysJobs) == 0 {
return nil, 0, nil
}
@ -486,14 +490,6 @@ func (n *Node) createNodeEvals(nodeID string, nodeIndex uint64) ([]string, uint6
evalIDs = append(evalIDs, eval.ID)
}
var sysJobs []*structs.Job
if nextJob != nil {
sysJobs = append(sysJobs, nextJob.(*structs.Job))
for job := sysJobsIter.Next(); job != nil; job = sysJobsIter.Next() {
sysJobs = append(sysJobs, job.(*structs.Job))
}
}
// Create an evaluation for each system job.
for _, job := range sysJobs {
// Still dedup on JobID as the node may already have the system job.