Skip to content

Commit

Permalink
Handle tags in plugin names
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
  • Loading branch information
aaronlehmann committed Dec 14, 2016
1 parent 015208a commit 56bcb2f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 5 additions & 1 deletion agent/exec/container/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}{}
}
}
Expand Down
14 changes: 13 additions & 1 deletion manager/scheduler/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package scheduler

import (
"fmt"
"strings"

"github.com/docker/swarmkit/api"
"github.com/docker/swarmkit/manager/constraint"
Expand Down Expand Up @@ -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
}
}
Expand Down

0 comments on commit 56bcb2f

Please sign in to comment.