From 56bcb2fcb5a698201efb0491dbb6ad1671d5f6bf Mon Sep 17 00:00:00 2001 From: Aaron Lehmann Date: Tue, 13 Dec 2016 16:51:04 -0800 Subject: [PATCH] Handle tags in plugin names Signed-off-by: Aaron Lehmann --- agent/exec/container/executor.go | 6 +++++- manager/scheduler/filter.go | 14 +++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/agent/exec/container/executor.go b/agent/exec/container/executor.go index 433e3001a0..a043b1dd33 100644 --- a/agent/exec/container/executor.go +++ b/agent/exec/container/executor.go @@ -64,9 +64,13 @@ func (e *executor) Describe(ctx context.Context) (*api.NodeDescription, error) { } else if typ.Capability == "networkdriver" { plgnTyp = "Network" } + plgnName := plgn.Name + if plgn.Tag != "" { + plgnName += ":" + plgn.Tag + } plugins[api.PluginDescription{ Type: plgnTyp, - Name: plgn.Name, + Name: plgnName, }] = struct{}{} } } diff --git a/manager/scheduler/filter.go b/manager/scheduler/filter.go index 79e0d079b4..b2b64578b4 100644 --- a/manager/scheduler/filter.go +++ b/manager/scheduler/filter.go @@ -2,6 +2,7 @@ package scheduler import ( "fmt" + "strings" "github.com/docker/swarmkit/api" "github.com/docker/swarmkit/manager/constraint" @@ -156,7 +157,18 @@ func (f *PluginFilter) Check(n *NodeInfo) bool { // pluginExistsOnNode returns true if the (pluginName, pluginType) pair is present in nodePlugins func (f *PluginFilter) pluginExistsOnNode(pluginType string, pluginName string, nodePlugins []api.PluginDescription) bool { for _, np := range nodePlugins { - if pluginType == np.Type && pluginName == np.Name { + if pluginType != np.Type { + continue + } + if pluginName == np.Name { + return true + } + // This does not use the reference package to avoid the + // overhead of parsing references as part of the scheduling + // loop. This is okay only because plugin names are a very + // strict subset of the reference grammar that is always + // name:tag. + if strings.HasPrefix(np.Name, pluginName) && np.Name[len(pluginName):] == ":latest" { return true } }