Skip to content

Commit

Permalink
Merge branch 'master' of github.com:hashicorp/nomad
Browse files Browse the repository at this point in the history
  • Loading branch information
dadgar committed Feb 23, 2016
2 parents fe0621f + de98c4e commit 8de39eb
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions nomad/plan_apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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--

Expand Down

0 comments on commit 8de39eb

Please sign in to comment.