From 2285942384971cdc062af463b7b9e12708640f98 Mon Sep 17 00:00:00 2001 From: Martynas Pumputis Date: Fri, 12 May 2017 13:13:35 +0300 Subject: [PATCH 1/2] Add better detection for plugin-v2 (net-plugin) The problem is that the plugin name is prefixed with a registry name. So, if the plugin is fetched from Docker Store, its name will be "store/weaveworks/net-plugin". The detection function does an exact match on "weaveworks/net-plugin", so in the Docker Store case, the presence of the plugin cannot be detected. --- prog/weaveutil/plugin_network.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/prog/weaveutil/plugin_network.go b/prog/weaveutil/plugin_network.go index 064ed0fe..451e2bf9 100644 --- a/prog/weaveutil/plugin_network.go +++ b/prog/weaveutil/plugin_network.go @@ -4,6 +4,7 @@ package main import ( "context" "fmt" + "strings" "github.com/docker/docker/client" docker "github.com/fsouza/go-dockerclient" @@ -56,16 +57,19 @@ func isDockerPluginEnabled(args []string) error { } ctx := context.Background() - p, _, err := c.PluginInspectWithRaw(ctx, pluginName) + + plugins, err := c.PluginList(ctx) if err != nil { return err } - if !p.Enabled { - return fmt.Errorf("plugin %q is disabled", pluginName) + for _, p := range plugins { + if p.Enabled && strings.Contains(p.Name, pluginName) { + return nil + } } - return nil + return fmt.Errorf("plugin %q not found", pluginName) } func newDockerClient() (*docker.Client, error) { From 0e3ac00ff58a0caa08972d4c94fde695da89299c Mon Sep 17 00:00:00 2001 From: Martynas Pumputis Date: Fri, 12 May 2017 14:22:39 +0300 Subject: [PATCH 2/2] Fix DriverName for plugin-v2 Print the full plugin-v2 name which might include a registry name. Also, do not print error from "proxy_addrs". --- prog/weaveutil/plugin_network.go | 1 + weave | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/prog/weaveutil/plugin_network.go b/prog/weaveutil/plugin_network.go index 451e2bf9..f3a4a272 100644 --- a/prog/weaveutil/plugin_network.go +++ b/prog/weaveutil/plugin_network.go @@ -65,6 +65,7 @@ func isDockerPluginEnabled(args []string) error { for _, p := range plugins { if p.Enabled && strings.Contains(p.Name, pluginName) { + fmt.Println(p.Name) return nil } } diff --git a/weave b/weave index f807492e..caa105c3 100755 --- a/weave +++ b/weave @@ -1526,7 +1526,7 @@ case "$COMMAND" in echo "Invalid 'weave status' sub-command: $SUB_COMMAND" >&2 usage fi - if [ -z "$SUB_STATUS" ] && PROXY_ADDRS=$(proxy_addrs) ; then + if [ -z "$SUB_STATUS" ] && PROXY_ADDRS=$(proxy_addrs 2>/dev/null) ; then echo echo " Service: proxy" echo " Address: $PROXY_ADDRS" @@ -1535,10 +1535,10 @@ case "$COMMAND" in echo echo " Service: plugin (v1)" echo " DriverName: weave" - elif [ -z "$SUB_STATUS" ] && is_plugin_v2_enabled ; then + elif [ -z "$SUB_STATUS" ] && PLUGIN_FULL_NAME=$(is_plugin_v2_enabled) ; then echo echo " Service: plugin (v2)" - echo " DriverName: $PLUGIN_NAME" + echo " DriverName: $PLUGIN_FULL_NAME" fi [ -n "$SUB_STATUS" ] || echo [ $res -eq 0 ]