diff --git a/scheduler/filter/constraint.go b/scheduler/filter/constraint.go index bf9f133141..ecc26a5524 100644 --- a/scheduler/filter/constraint.go +++ b/scheduler/filter/constraint.go @@ -34,8 +34,13 @@ func (f *ConstraintFilter) Filter(config *dockerclient.ContainerConfig, nodes [] if constraint.Match(label) { candidates = append(candidates, node) } - } else if constraint.MatchEmpty() { - candidates = append(candidates, node) + } else { + // The node doesn't have this particular label. + if constraint.operator == NOTEQ { + // Special case: If the operator is != and the node doesn't + // have the label at all, consider it as a candidate. + candidates = append(candidates, node) + } } } } diff --git a/scheduler/filter/expr.go b/scheduler/filter/expr.go index 9f5468048a..cbb526e121 100644 --- a/scheduler/filter/expr.go +++ b/scheduler/filter/expr.go @@ -72,10 +72,6 @@ func parseExprs(key string, env []string) ([]expr, error) { return exprs, nil } -func (e *expr) MatchEmpty() bool { - return e.operator == NOTEQ -} - func (e *expr) Match(whats ...string) bool { var ( pattern string