From 04fc1ab9971a744340261c6d902e20cc692bdaa0 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Wed, 28 Jan 2015 12:12:09 -0800 Subject: [PATCH] expr: Get rid of MatchEmpty. Signed-off-by: Andrea Luzzardi --- scheduler/filter/constraint.go | 9 +++++++-- scheduler/filter/expr.go | 4 ---- 2 files changed, 7 insertions(+), 6 deletions(-) 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