diff --git a/test/850_plugin_v2_cross_hosts_2_test.sh b/test/850_plugin_v2_cross_hosts_2_test.sh index e5db1c2b..58892f0b 100755 --- a/test/850_plugin_v2_cross_hosts_2_test.sh +++ b/test/850_plugin_v2_cross_hosts_2_test.sh @@ -2,7 +2,7 @@ . "$(dirname "$0")/config.sh" -PLUGIN_NAME="weave-ci-registry:5000/weaveworks/plugin-v2" +PLUGIN_NAME="weave-ci-registry:5000/weaveworks/net-plugin" HOST1_IP=$($SSH $HOST1 getent ahosts $HOST1 | grep "RAW" | cut -d' ' -f1) SERVICE="weave-850-service" NETWORK="weave-850-network" @@ -46,9 +46,7 @@ setup_worker() { echo "$HOST1_IP weave-ci-registry" | sudo tee -a /etc/hosts ping -nq -W 2 -c 1 weave-ci-registry docker swarm join --token "$1" "${HOST1_IP}:2377" - echo "Installing..." docker plugin install --disable --grant-all-permissions $PLUGIN_NAME - echo "Done" [ -n "$COVERAGE" ] && docker plugin set $PLUGIN_NAME EXTRA_ARGS="-test.coverprofile=/home/weave/cover.prof --" #docker plugin set $PLUGIN_NAME WEAVE_PASSWORD="foobar" @@ -100,7 +98,6 @@ start_suite "Test Docker plugin-v2" #exit 1 setup_master -#sleep 20 # registry seems to be async :( setup_worker $($SSH $HOST1 docker swarm join-token --quiet worker) echo "Creating network and service..." @@ -117,17 +114,14 @@ EOF wait_for_service $HOST1 $SERVICE 2 -$SSH $HOST1 "docker service ls" -$SSH $HOST1 "docker ps" -$SSH $HOST2 "docker ps" - C1=$($SSH $HOST1 weave ps | grep -v weave:expose | awk '{print $1}') C2_IP=$($SSH $HOST2 weave ps | grep -v weave:expose | awk '{print $3}' | cut -d/ -f1) -# TODO test for encryption - assert_raises "exec_on $HOST1 $C1 $PING $C2_IP" +# We do not test "weave {status,launch}", because the weave script does not detect +# plugin-v2 if its name is prefixed with a registry name. + # Failing to cleanup will make the rest of the tests to fail cleanup $HOST1 $HOST2 diff --git a/weave b/weave index 66f512fc..4cc57d9b 100755 --- a/weave +++ b/weave @@ -883,28 +883,29 @@ attach() { util_op attach-container $ATTACH_ARGS $CONTAINER $BRIDGE $MTU "$@" } -check_not_running_v2_plugin() { - if is_docker_plugin_enabled $PLUGIN_NAME; then - echo "Docker plugin \"$PLUGIN_NAME\" is already running." >&2 - return 1 - fi -} - -# Docker Plugin V2 -is_docker_plugin_enabled() { - util_op is-docker-plugin-enabled $PLUGIN_NAME 2>/dev/null -} - -# Docker Plugin (part of weaver process, so V2 or V1). -# Assumes that plugin is running inside Docker container. -is_plugin_enabled() { - docker inspect -f '{{.Config.Cmd}}' $CONTAINER_NAME | grep -q -- "--plugin" -} - ###################################################################### # functions for interacting with containers ###################################################################### +# Docker Plugin V1 runs in a Docker container. +is_plugin_v1_enabled() { + docker inspect -f '{{.Config.Cmd}}' $CONTAINER_NAME 2>/dev/null | grep -q -- "--plugin" +} + +# The presence of Docker Plugin V2 can be checked only via 'docker plugin', +# as v2 plugins do not run as regular containers. +is_plugin_v2_enabled() { + util_op is-docker-plugin-enabled $PLUGIN_NAME 2>/dev/null +} + +# Check that plugin (v2) is not running. +check_not_running_plugin_v2() { + if is_plugin_v2_enabled; then + echo "Docker plugin \"$PLUGIN_NAME\" is running; Aborting." >&2 + return 1 + fi +} + # Check that a container for component $1 named $2 with image $3 is not running check_not_running() { RUN_STATUS=$(docker inspect --format='{{.State.Running}} {{.State.Status}} {{.Config.Image}}' $2 2>/dev/null) || true @@ -1752,7 +1753,7 @@ populate_router() { } stop_router() { - ! is_plugin_enabled || util_op remove-plugin-network weave || true + ! is_plugin_v1_enabled || util_op remove-plugin-network weave || true stop $CONTAINER_NAME "Weave" conntrack -D -p udp --dport $PORT >/dev/null 2>&1 || true } @@ -1796,7 +1797,7 @@ stop_proxy() { protect_against_docker_hang() { # If the plugin is not running, remove its socket so Docker doesn't try to talk to it - if ! is_docker_plugin_enabled 2>/dev/null ; then + if ! is_plugin_v2_enabled 2>/dev/null ; then rm -f /run/docker/plugins/weave.sock /run/docker/plugins/weavemesh.sock fi } @@ -1984,7 +1985,7 @@ EOF deprecation_warnings "$@" check_not_running router $CONTAINER_NAME $BASE_IMAGE check_not_running proxy $PROXY_CONTAINER_NAME $BASE_EXEC_IMAGE - check_not_running_v2_plugin + check_not_running_plugin_v2 COMMON_ARGS=$(common_launch_args "$@") launch_router --plugin "$@" launch_proxy $COMMON_ARGS @@ -1992,7 +1993,7 @@ EOF launch-router) deprecation_warnings "$@" check_not_running router $CONTAINER_NAME $BASE_IMAGE - check_not_running_v2_plugin + check_not_running_plugin_v2 launch_router "$@" echo $ROUTER_CONTAINER ;; @@ -2010,7 +2011,7 @@ EOF launch-proxy) deprecation_warnings "$@" check_not_running proxy $PROXY_CONTAINER_NAME $BASE_EXEC_IMAGE - check_not_running_v2_plugin + check_not_running_plugin_v2 launch_proxy "$@" echo $PROXY_CONTAINER ;; @@ -2055,14 +2056,14 @@ EOF echo " Service: proxy" echo " Address: $PROXY_ADDRS" fi - if [ -z "$SUB_STATUS" ] && is_docker_plugin_enabled ; then + if [ -z "$SUB_STATUS" ] && is_plugin_v1_enabled ; then echo - echo " Service: plugin" - echo " DriverName: $PLUGIN_NAME" - elif [ -z "$SUB_STATUS" ] && is_plugin_enabled ; then - echo - echo " Service: plugin" + echo " Service: plugin (v1)" echo " DriverName: weave" + elif [ -z "$SUB_STATUS" ] && is_plugin_v2_enabled ; then + echo + echo " Service: plugin (v2)" + echo " DriverName: $PLUGIN_NAME" fi [ -n "$SUB_STATUS" ] || echo [ $res -eq 0 ] @@ -2261,7 +2262,7 @@ EOF ;; reset) [ $# -eq 0 ] || [ $# -eq 1 -a "$1" = "--force" ] || usage - ! is_plugin_enabled || util_op remove-plugin-network weave || true + ! is_plugin_v1_enabled || util_op remove-plugin-network weave || true warn_if_stopping_proxy_in_env res=0 [ "$1" = "--force" ] || check_running $CONTAINER_NAME 2>/dev/null || res=$?