From bc79a9187f0eb97af68e2af955e31776eb321d58 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Thu, 12 May 2016 15:38:08 +0000 Subject: [PATCH] Protect against Docker hanging trying to talk to a non-existent plugin Remove the Unix socket from the filesystem before doing volume operations, if the plugin is not running. --- weave | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/weave b/weave index 6ebd4efc..0b75b380 100755 --- a/weave +++ b/weave @@ -1740,6 +1740,7 @@ launch_router() { # Create a data-only container for persistence data if ! docker inspect -f ' ' $DB_CONTAINER_NAME > /dev/null 2>&1 ; then + protect_against_docker_hang docker create -v /weavedb --name=$DB_CONTAINER_NAME \ --label=weavevolumes $WEAVEDB_IMAGE >/dev/null fi @@ -1803,6 +1804,7 @@ launch_proxy() { mkdir -p /var/run/weave # Create a data-only container to mount the weavewait files from if ! docker inspect -f ' ' $VOLUMES_CONTAINER_NAME > /dev/null 2>&1 ; then + protect_against_docker_hang docker create -v /w -v /w-noop -v /w-nomcast --name=$VOLUMES_CONTAINER_NAME \ --label=weavevolumes --entrypoint=/bin/false $EXEC_IMAGE >/dev/null fi @@ -1864,6 +1866,13 @@ stop_plugin() { stop $PLUGIN_CONTAINER_NAME "Plugin" } +protect_against_docker_hang() { + # If the plugin is not running, remove its socket so Docker doesn't try to talk to it + if !check_running $PLUGIN_CONTAINER_NAME 2>/dev/null ; then + rm -f /run/docker/plugins/weave.sock /run/docker/plugins/weavemesh.sock + fi +} + ########################################################################################## [ $(id -u) = 0 ] || {