Address review feedback

This commit is contained in:
Armon Dadgar 2016-02-21 13:32:45 -08:00
parent 6ddc4fd17b
commit e4524b173c
2 changed files with 10 additions and 4 deletions

View File

@ -128,8 +128,16 @@ func (s *Server) planApply() {
// applyPlan is used to apply the plan result and to return the alloc index
func (s *Server) applyPlan(job *structs.Job, result *structs.PlanResult, snap *state.StateSnapshot) (raft.ApplyFuture, error) {
// Determine the miniumum number of updates, could be more if there
// are multiple updates per node
minUpdates := len(result.NodeUpdate)
minUpdates += len(result.NodeAllocation)
minUpdates += len(result.FailedAllocs)
// Setup the update request
req := structs.AllocUpdateRequest{
Job: job,
Job: job,
Alloc: make([]*structs.Allocation, 0, minUpdates),
}
for _, updateList := range result.NodeUpdate {
req.Alloc = append(req.Alloc, updateList...)

View File

@ -2421,9 +2421,7 @@ type Plan struct {
func (p *Plan) AppendUpdate(alloc *Allocation, status, desc string) {
newAlloc := new(Allocation)
*newAlloc = *alloc
if p.Job != nil {
newAlloc.Job = nil // Normalize the job
}
newAlloc.Job = nil // Normalize the job
newAlloc.DesiredStatus = status
newAlloc.DesiredDescription = desc
node := alloc.NodeID