From 739c2c6e3aa0518308cb39be989879f3eaa4b227 Mon Sep 17 00:00:00 2001 From: Steven Dake Date: Thu, 27 Aug 2015 18:04:30 -0700 Subject: [PATCH] Move scripts for haproxy to docker_templates Change-Id: I942ba0e0ced0532fb0b575843fa170a031a8eb59 Partially-Implements: blueprint remove-docker-dir --- docker/common/haproxy/config-external.sh | 10 --------- docker/common/haproxy/ensure_latest_config.sh | 12 ----------- docker/common/haproxy/start.sh | 20 ------------------ docker_templates/haproxy/config-external.sh | 11 +++++++++- .../haproxy/ensure_latest_config.sh | 13 +++++++++++- docker_templates/haproxy/start.sh | 21 ++++++++++++++++++- 6 files changed, 42 insertions(+), 45 deletions(-) delete mode 100644 docker/common/haproxy/config-external.sh delete mode 100755 docker/common/haproxy/ensure_latest_config.sh delete mode 100755 docker/common/haproxy/start.sh mode change 120000 => 100644 docker_templates/haproxy/config-external.sh mode change 120000 => 100755 docker_templates/haproxy/ensure_latest_config.sh mode change 120000 => 100755 docker_templates/haproxy/start.sh diff --git a/docker/common/haproxy/config-external.sh b/docker/common/haproxy/config-external.sh deleted file mode 100644 index 0c41a5bdbb..0000000000 --- a/docker/common/haproxy/config-external.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -SOURCE="/opt/kolla/haproxy/haproxy.cfg" -TARGET="/etc/haproxy/haproxy.cfg" -OWNER="root" - -if [[ -f "$SOURCE" ]]; then - cp -f $SOURCE $TARGET - chown ${OWNER}: $TARGET - chmod 0644 $TARGET -fi diff --git a/docker/common/haproxy/ensure_latest_config.sh b/docker/common/haproxy/ensure_latest_config.sh deleted file mode 100755 index b91189ca57..0000000000 --- a/docker/common/haproxy/ensure_latest_config.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -CURRENT_CONFIG_HASH=$(sha1sum /etc/haproxy/haproxy.cfg | cut -f1 -d' ') -NEW_CONFIG_HASH=$(sha1sum /opt/kolla/haproxy/haproxy.cfg | cut -f1 -d' ') - -if [[ $CURRENT_CONFIG_HASH != $NEW_CONFIG_HASH ]]; then - changed=changed - source /opt/kolla/config-external.sh - /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -sf $(cat /run/haproxy.pid) -fi - -echo $changed diff --git a/docker/common/haproxy/start.sh b/docker/common/haproxy/start.sh deleted file mode 100755 index d1da4a607f..0000000000 --- a/docker/common/haproxy/start.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -set -o errexit - -CMD='/usr/sbin/haproxy' -ARGS="-f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid" - -# Loading common functions. -source /opt/kolla/kolla-common.sh - -# Execute config strategy -set_configs - -# We are intentionally not using exec so we can reload the haproxy config later -$CMD $ARGS - -# TODO(SamYaple): This has the potential for a race condition triggered by a -# config reload that could cause the container to exit -while [[ -e "/proc/$(cat /run/haproxy.pid)" ]]; do - sleep 5 -done diff --git a/docker_templates/haproxy/config-external.sh b/docker_templates/haproxy/config-external.sh deleted file mode 120000 index d0351492c5..0000000000 --- a/docker_templates/haproxy/config-external.sh +++ /dev/null @@ -1 +0,0 @@ -../../docker/common/haproxy/config-external.sh \ No newline at end of file diff --git a/docker_templates/haproxy/config-external.sh b/docker_templates/haproxy/config-external.sh new file mode 100644 index 0000000000..0c41a5bdbb --- /dev/null +++ b/docker_templates/haproxy/config-external.sh @@ -0,0 +1,10 @@ +#!/bin/bash +SOURCE="/opt/kolla/haproxy/haproxy.cfg" +TARGET="/etc/haproxy/haproxy.cfg" +OWNER="root" + +if [[ -f "$SOURCE" ]]; then + cp -f $SOURCE $TARGET + chown ${OWNER}: $TARGET + chmod 0644 $TARGET +fi diff --git a/docker_templates/haproxy/ensure_latest_config.sh b/docker_templates/haproxy/ensure_latest_config.sh deleted file mode 120000 index a78adec669..0000000000 --- a/docker_templates/haproxy/ensure_latest_config.sh +++ /dev/null @@ -1 +0,0 @@ -../../docker/common/haproxy/ensure_latest_config.sh \ No newline at end of file diff --git a/docker_templates/haproxy/ensure_latest_config.sh b/docker_templates/haproxy/ensure_latest_config.sh new file mode 100755 index 0000000000..b91189ca57 --- /dev/null +++ b/docker_templates/haproxy/ensure_latest_config.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +CURRENT_CONFIG_HASH=$(sha1sum /etc/haproxy/haproxy.cfg | cut -f1 -d' ') +NEW_CONFIG_HASH=$(sha1sum /opt/kolla/haproxy/haproxy.cfg | cut -f1 -d' ') + +if [[ $CURRENT_CONFIG_HASH != $NEW_CONFIG_HASH ]]; then + changed=changed + source /opt/kolla/config-external.sh + /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -sf $(cat /run/haproxy.pid) +fi + +echo $changed diff --git a/docker_templates/haproxy/start.sh b/docker_templates/haproxy/start.sh deleted file mode 120000 index 269fd27860..0000000000 --- a/docker_templates/haproxy/start.sh +++ /dev/null @@ -1 +0,0 @@ -../../docker/common/haproxy/start.sh \ No newline at end of file diff --git a/docker_templates/haproxy/start.sh b/docker_templates/haproxy/start.sh new file mode 100755 index 0000000000..d1da4a607f --- /dev/null +++ b/docker_templates/haproxy/start.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -o errexit + +CMD='/usr/sbin/haproxy' +ARGS="-f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid" + +# Loading common functions. +source /opt/kolla/kolla-common.sh + +# Execute config strategy +set_configs + +# We are intentionally not using exec so we can reload the haproxy config later +$CMD $ARGS + +# TODO(SamYaple): This has the potential for a race condition triggered by a +# config reload that could cause the container to exit +while [[ -e "/proc/$(cat /run/haproxy.pid)" ]]; do + sleep 5 +done