Skip to content

Commit

Permalink
fixup: Support missing values in affinities
Browse files Browse the repository at this point in the history
  • Loading branch information
endocrimes committed Nov 14, 2018
1 parent 2faab61 commit d7f7b13
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
4 changes: 2 additions & 2 deletions scheduler/feasible.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,9 @@ func checkConstraint(ctx Context, operand string, lVal, rVal interface{}, lFound
}

// checkAffinity checks if a specific affinity is satisfied
func checkAffinity(ctx Context, operand string, lVal, rVal interface{}) bool {
func checkAffinity(ctx Context, operand string, lVal, rVal interface{}, lFound, rFound bool) bool {
// We pass ok here for both values, because matchesAffinity prevalidates these
return checkConstraint(ctx, operand, lVal, rVal, true, true)
return checkConstraint(ctx, operand, lVal, rVal, lFound, rFound)
}

// checkAttributeAffinity checks if an affinity is satisfied
Expand Down
12 changes: 3 additions & 9 deletions scheduler/rank.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,17 +564,11 @@ func (iter *NodeAffinityIterator) Next() *RankedNode {
func matchesAffinity(ctx Context, affinity *structs.Affinity, option *structs.Node) bool {
//TODO(preetha): Add a step here that filters based on computed node class for potential speedup
// Resolve the targets
lVal, ok := resolveTarget(affinity.LTarget, option)
if !ok {
return false
}
rVal, ok := resolveTarget(affinity.RTarget, option)
if !ok {
return false
}
lVal, lOk := resolveTarget(affinity.LTarget, option)
rVal, rOk := resolveTarget(affinity.RTarget, option)

// Check if satisfied
return checkAffinity(ctx, affinity.Operand, lVal, rVal)
return checkAffinity(ctx, affinity.Operand, lVal, rVal, lOk, rOk)
}

// ScoreNormalizationIterator is used to combine scores from various prior
Expand Down

0 comments on commit d7f7b13

Please sign in to comment.