From de98c4e3278064b08d2979b15157f3ca77af26e8 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Mon, 22 Feb 2016 22:31:25 -0800 Subject: [PATCH] nomad: do not skip node plan if we receive an evaluation result --- nomad/plan_apply.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/nomad/plan_apply.go b/nomad/plan_apply.go index a4056390d..52c575b14 100644 --- a/nomad/plan_apply.go +++ b/nomad/plan_apply.go @@ -213,11 +213,18 @@ func evaluatePlan(pool *EvaluatePool, snap *state.StateSnapshot, plan *structs.P // Collect all the nodeIDs nodeIDs := make(map[string]struct{}) + nodeIDList := make([]string, 0, len(plan.NodeUpdate)+len(plan.NodeAllocation)) for nodeID := range plan.NodeUpdate { - nodeIDs[nodeID] = struct{}{} + if _, ok := nodeIDs[nodeID]; !ok { + nodeIDs[nodeID] = struct{}{} + nodeIDList = append(nodeIDList, nodeID) + } } for nodeID := range plan.NodeAllocation { - nodeIDs[nodeID] = struct{}{} + if _, ok := nodeIDs[nodeID]; !ok { + nodeIDs[nodeID] = struct{}{} + nodeIDList = append(nodeIDList, nodeID) + } } // Setup a multierror to handle potentially getting many @@ -264,12 +271,14 @@ func evaluatePlan(pool *EvaluatePool, snap *state.StateSnapshot, plan *structs.P outstanding := 0 didCancel := false - // Evalute each node in the plan, handling results as - // they are ready to avoid blocking. - for nodeID := range nodeIDs { + // Evalute each node in the plan, handling results as they are ready to + // avoid blocking. + for len(nodeIDList) > 0 { + nodeID := nodeIDList[0] select { case req <- evaluateRequest{snap, plan, nodeID}: outstanding++ + nodeIDList = nodeIDList[1:] case r := <-resp: outstanding--