Have Plan.AppendAlloc accept the job

This commit is contained in:
Mahmood Ali
2020-08-25 17:09:21 -04:00
parent 5720266c91
commit cb038b1a8c
4 changed files with 9 additions and 17 deletions

View File

@@ -9831,17 +9831,13 @@ func (p *Plan) PopUpdate(alloc *Allocation) {
}
// AppendAlloc appends the alloc to the plan allocations.
// To save space, it clears the Job field so it can be derived from the plan Job.
// If keepJob is true, the normalizatin skipped to accommodate cases where a plan
// needs to support multiple versions of the same job.
func (p *Plan) AppendAlloc(alloc *Allocation, keepJob bool) {
// Uses the passed job if explicitly passed, otherwise
// it is assumed the alloc will use the plan Job version.
func (p *Plan) AppendAlloc(alloc *Allocation, job *Job) {
node := alloc.NodeID
existing := p.NodeAllocation[node]
// Normalize the job
if !keepJob {
alloc.Job = nil
}
alloc.Job = job
p.NodeAllocation[node] = append(existing, alloc)
}

View File

@@ -388,12 +388,12 @@ func (s *GenericScheduler) computeJobAllocs() error {
update.DeploymentID = s.deployment.GetID()
update.DeploymentStatus = nil
}
s.ctx.Plan().AppendAlloc(update, false)
s.ctx.Plan().AppendAlloc(update, nil)
}
// Handle the annotation updates
for _, update := range results.attributeUpdates {
s.ctx.Plan().AppendAlloc(update, false)
s.ctx.Plan().AppendAlloc(update, nil)
}
// Nothing remaining to do if placement is not required
@@ -601,14 +601,10 @@ func (s *GenericScheduler) computePlacements(destructive, place []placementResul
}
}
if downgradedJob != nil {
alloc.Job = downgradedJob
}
s.handlePreemptions(option, alloc, missing)
// Track the placement
s.plan.AppendAlloc(alloc, downgradedJob != nil)
s.plan.AppendAlloc(alloc, downgradedJob)
} else {
// Lazy initialize the failed map

View File

@@ -398,7 +398,7 @@ func (s *SystemScheduler) computePlacements(place []allocTuple) error {
alloc.PreemptedAllocations = preemptedAllocIDs
}
s.plan.AppendAlloc(alloc, false)
s.plan.AppendAlloc(alloc, nil)
}
return nil

View File

@@ -655,7 +655,7 @@ func inplaceUpdate(ctx Context, eval *structs.Evaluation, job *structs.Job,
},
}
newAlloc.Metrics = ctx.Metrics()
ctx.Plan().AppendAlloc(newAlloc, false)
ctx.Plan().AppendAlloc(newAlloc, nil)
// Remove this allocation from the slice
doInplace(&i, &n, &inplaceCount)