diff options
Diffstat (limited to 'docker')
| -rwxr-xr-x | docker/centos/binary/haproxy/Dockerfile | 2 | ||||
| l--------- | docker/centos/binary/haproxy/ensure_latest_config.sh | 1 | ||||
| -rwxr-xr-x | docker/common/haproxy/config-external.sh | 3 | ||||
| -rwxr-xr-x | docker/common/haproxy/ensure_latest_config.sh | 12 | ||||
| -rwxr-xr-x | docker/common/haproxy/start.sh | 15 |
5 files changed, 24 insertions, 9 deletions
diff --git a/docker/centos/binary/haproxy/Dockerfile b/docker/centos/binary/haproxy/Dockerfile index 40f2af610..8e1a05f18 100755 --- a/docker/centos/binary/haproxy/Dockerfile +++ b/docker/centos/binary/haproxy/Dockerfile @@ -6,6 +6,6 @@ RUN yum -y install \ && yum clean all COPY start.sh / -COPY config-external.sh /opt/kolla/ +COPY config-external.sh ensure_latest_config.sh /opt/kolla/ CMD ["/start.sh"] diff --git a/docker/centos/binary/haproxy/ensure_latest_config.sh b/docker/centos/binary/haproxy/ensure_latest_config.sh new file mode 120000 index 000000000..80c50f32a --- /dev/null +++ b/docker/centos/binary/haproxy/ensure_latest_config.sh @@ -0,0 +1 @@ +../../../common/haproxy/ensure_latest_config.sh
\ No newline at end of file diff --git a/docker/common/haproxy/config-external.sh b/docker/common/haproxy/config-external.sh index d267eb195..0c41a5bdb 100755 --- a/docker/common/haproxy/config-external.sh +++ b/docker/common/haproxy/config-external.sh @@ -4,8 +4,7 @@ TARGET="/etc/haproxy/haproxy.cfg" OWNER="root" if [[ -f "$SOURCE" ]]; then - rm $TARGET - cp $SOURCE $TARGET + 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 new file mode 100755 index 000000000..b91189ca5 --- /dev/null +++ b/docker/common/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/common/haproxy/start.sh b/docker/common/haproxy/start.sh index 68600f44e..c39184767 100755 --- a/docker/common/haproxy/start.sh +++ b/docker/common/haproxy/start.sh @@ -2,11 +2,7 @@ set -o errexit CMD='/usr/sbin/haproxy' -# Parameters: -# -db for non-daemon execution and logging to stdout -# -p pidfile to specify pidfile and allow hot reconfiguration -# loop which generates -f file.conf for each file in /etc/haproxy and /etc/haproxy/conf.d -ARGS="-db -f /etc/haproxy/haproxy.cfg" +ARGS="-f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid" # Loading common functions. source /opt/kolla/kolla-common.sh @@ -14,4 +10,11 @@ source /opt/kolla/kolla-common.sh # Config-internal script exec out of this function, it does not return here. set_configs -exec $CMD $ARGS +# 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 |
