From 65a5d54727f08a3cd4a74a5c3863b7572ff9ecb5 Mon Sep 17 00:00:00 2001 From: Sun Hongliang Date: Tue, 5 Apr 2016 11:06:16 +0800 Subject: [PATCH] send warn message if got an engine with label "node" Signed-off-by: Sun Hongliang --- cluster/engine.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cluster/engine.go b/cluster/engine.go index b47eda94a8..de1bf427b2 100644 --- a/cluster/engine.go +++ b/cluster/engine.go @@ -472,6 +472,16 @@ func (e *Engine) updateSpecs() error { message := fmt.Sprintf("Engine (ID: %s, Addr: %s) contains an invalid label (%s) not formatted as \"key=value\".", e.ID, e.Addr, label) return fmt.Errorf(message) } + + // If an engine managed by Swarm contains a label with key "node", + // such as node=node1 + // `docker run -e constraint:node==node1 -d nginx` will not work, + // since "node" in constraint will match node.Name instead of label. + // Log warn message in this case. + if kv[0] == "node" { + log.Warnf("Engine (ID: %s, Addr: %s) containers a label (%s) with key of \"node\" which cannot be used in Swarm.", e.ID, e.Addr, label) + } + e.Labels[kv[0]] = kv[1] } return nil