From 70f9f46bffb582f5353cd04eac529d8237d5bce4 Mon Sep 17 00:00:00 2001 From: Antoni Segura Puimedon Date: Thu, 15 Sep 2016 10:05:36 +0200 Subject: [PATCH] devstack: Make docker also listen to its socket In order to have Docker easily usable for the fullstack testing, we made it listen to the port 2375. This had an unintended and very bothering side effect in forcing cli usage to have to pass '-H :2375' to every signle docker command. It was driving me crazy, so this should make both the normal cli usage and the fullstack usage work without hassle. Change-Id: I0d6162937e018664516de406197ca0a464b4ee71 Signed-off-by: Antoni Segura Puimedon --- devstack/plugin.sh | 15 ++++++++++++++- devstack/settings | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/devstack/plugin.sh b/devstack/plugin.sh index a7db9d17..27231f0d 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -133,7 +133,17 @@ if is_service_enabled kuryr-libnetwork; then # After an ./unstack it will be stopped. So it is ok if it returns exit-code == 1 sudo service docker stop || true - run_process docker-engine "sudo /usr/bin/docker daemon -H tcp://0.0.0.0:$KURYR_DOCKER_ENGINE_PORT --cluster-store etcd://localhost:$KURYR_ETCD_PORT" + run_process docker-engine "sudo /usr/bin/docker daemon -H unix://$KURYR_DOCKER_ENGINE_SOCKET_FILE -H tcp://0.0.0.0:$KURYR_DOCKER_ENGINE_PORT --cluster-store etcd://localhost:$KURYR_ETCD_PORT" + + # We put the stack user as owner of the socket so we do not need to + # run the Docker commands with sudo when developing. + echo -n "Waiting for Docker to create its socket file" + while [ ! -e "$KURYR_DOCKER_ENGINE_SOCKET_FILE" ]; do + echo -n "." + sleep 1 + done + echo "" + sudo chown "$STACK_USER":docker "$KURYR_DOCKER_ENGINE_SOCKET_FILE" fi if [[ "$1" == "stack" && "$2" == "extra" ]]; then @@ -162,6 +172,9 @@ if is_service_enabled kuryr-libnetwork; then stop_process etcd-server rm -rf $DEST/etcd/ stop_process docker-engine + # Stop process does not handle well Docker 1.12+ new multi process + # split and doesn't kill them all. Let's leverage Docker's own pidfile + sudo kill -s SIGTERM "$(cat /var/run/docker.pid)" fi fi diff --git a/devstack/settings b/devstack/settings index d52c0948..50011260 100644 --- a/devstack/settings +++ b/devstack/settings @@ -18,6 +18,7 @@ KURYR_POOL_PREFIX=${KURYR_POOL_PREFIX:-10.10.0.0/16} KURYR_POOL_PREFIX_LEN=${KURYR_POOL_PREFIX_LEN:-24} KURYR_DOCKER_ENGINE_PORT=${KURYR_DOCKER_ENGINE_PORT:-2375} +KURYR_DOCKER_ENGINE_SOCKET_FILE=${KURYR_DOCKER_ENGINE_SOCKET_FILE:-/var/run/docker.sock} KURYR_ETCD_PORT=${KURYR_ETCD_PORT:-4001} enable_service kuryr-libnetwork etcd-server docker-engine