mirror of
https://github.com/kemko/nomad.git
synced 2026-01-07 19:05:42 +03:00
Have Plan.AppendAlloc accept the job
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user