From faf5b14d8b1e8a8c0e22e6d5984f7889e021b837 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Wed, 13 Jul 2016 09:48:03 +0100 Subject: [PATCH 1/3] make CNI setup work on recent Docker-for-Macs Docker for Mac 1.12.0-rc3 (as of beta18) looks for mounted paths on VM first, and when it doesn't find them there, it assumes they refer to paths on the Mac OS host. At which point it will complain that the paths don't exit. So instead we mount / since that will always exist on the VM. It's also what we used to do already when launching the router. Fixes #2434. --- weave | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/weave b/weave index a5ee0746..7bb3a69c 100755 --- a/weave +++ b/weave @@ -135,20 +135,19 @@ docker_run_options() { echo --privileged --net=host $(docker_sock_options) } -cni_volume_options() { - [ "$1" = "setup" -o "$1" = "setup-cni" ] && echo -v /etc/cni:/etc/cni -v /opt/cni:/opt/cni -} - -launch_router_options() { - [ "$1" = "launch" -o "$1" = "launch-router" ] && echo -v /:/host -e HOST_ROOT=/host +exec_options() { + case "$1" in + setup|setup-cni|launch|launch-router) + echo -v /:/host -e HOST_ROOT=/host + ;; + esac } exec_remote() { docker $DOCKER_CLIENT_ARGS run --rm \ $(docker_run_options) \ --pid=host \ - $(cni_volume_options "$@") \ - $(launch_router_options "$@") \ + $(exec_options "$@") \ -e DOCKERHUB_USER="$DOCKERHUB_USER" \ -e WEAVE_VERSION \ -e WEAVE_DEBUG \ @@ -1034,7 +1033,7 @@ create_cni_script() { #!/bin/sh docker run --rm $(docker_run_options) --pid=host -i \\ -e CNI_VERSION -e CNI_COMMAND -e CNI_CONTAINERID -e CNI_NETNS \\ - -e CNI_IFNAME -e CNI_ARGS -e CNI_PATH $(cni_volume_options setup) \\ + -e CNI_IFNAME -e CNI_ARGS -e CNI_PATH -v /etc/cni:/etc/cni -v /opt/cni:/opt/cni \\ $PLUGIN_IMAGE $COVERAGE_ARGS $2 EOF chmod a+x "$1" @@ -1050,12 +1049,12 @@ EOF } setup_cni() { - if [ -d /opt/cni/bin ] ; then - create_cni_script /opt/cni/bin/weave-net --cni-net - create_cni_script /opt/cni/bin/weave-ipam --cni-ipam + if [ -d $HOST_ROOT/opt/cni/bin ] ; then + create_cni_script $HOST_ROOT/opt/cni/bin/weave-net --cni-net + create_cni_script $HOST_ROOT/opt/cni/bin/weave-ipam --cni-ipam fi - if [ -d /etc/cni/net.d -a ! -f /etc/cni/net.d/10-weave.conf ] ; then - create_cni_config /etc/cni/net.d/10-weave.conf + if [ -d $HOST_ROOT/etc/cni/net.d -a ! -f $HOST_ROOT/etc/cni/net.d/10-weave.conf ] ; then + create_cni_config $HOST_ROOT/etc/cni/net.d/10-weave.conf fi } From afc6f49e800f6a067233bb0d4121f76eea29fef8 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Wed, 13 Jul 2016 10:20:54 +0100 Subject: [PATCH 2/3] mount CNI_NETNS dir, in case it is some exotic location Fixes #2394 --- weave | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/weave b/weave index 7bb3a69c..2726f98f 100755 --- a/weave +++ b/weave @@ -1031,9 +1031,12 @@ peer_args() { create_cni_script() { cat >"$1" < Date: Wed, 13 Jul 2016 10:24:40 +0100 Subject: [PATCH 3/3] setup CNI on `weave launch[-router]` not just `setup[-cni]` Fixes #2435 --- weave | 1 + 1 file changed, 1 insertion(+) diff --git a/weave b/weave index 2726f98f..dabd1baa 100755 --- a/weave +++ b/weave @@ -1616,6 +1616,7 @@ launch_router() { done eval "set -- $ARGS" + setup_cni create_bridge # We set the router name to the bridge MAC, which in turn is # derived from the system UUID (if available), and thus stable