aboutsummaryrefslogtreecommitdiff
path: root/docker/haproxy
diff options
context:
space:
mode:
authorMD NADEEM <mail2nadeem92@gmail.com>2016-03-15 15:00:30 +0530
committerMD NADEEM <md.nadeem@nectechnologies.in>2016-03-16 15:56:19 +0000
commitf11112371d50a604829e8a6c5c333e87ea94185f (patch)
tree6f72755256dd37b8b0ca23417102cf8998167f8f /docker/haproxy
parentf4d6aaf0979754b6198f702e309e4a4688b4645b (diff)
downloadkolla-f11112371d50a604829e8a6c5c333e87ea94185f.tar.gz
kolla-f11112371d50a604829e8a6c5c333e87ea94185f.zip
Fix race condition in haproxy
The time period between getting pid of haproxy service and checking existance of pid file is very short, if with in this period haproxy service get reload then the race condition occured and container get exit as extend_start.sh script exit. To minimize the risk of race condition, this patch let the extend_start.sh script to try upto 3 times before exit. Closes-Bug: #1479888 Change-Id: I2f9b7ec832dec8d94a2cdd27ca8a212d0c65a60d
Diffstat (limited to 'docker/haproxy')
-rw-r--r--docker/haproxy/extend_start.sh13
1 files changed, 9 insertions, 4 deletions
diff --git a/docker/haproxy/extend_start.sh b/docker/haproxy/extend_start.sh
index 16a65c0af..c33780d20 100644
--- a/docker/haproxy/extend_start.sh
+++ b/docker/haproxy/extend_start.sh
@@ -7,11 +7,16 @@ sysctl net.unix.max_dgram_qlen=128
echo "Running command: '${CMD}'"
$CMD
-# 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
+retry=0
+# The loop breaks only when haproxy.pid get missing even after 3 re-try.
+while [[ $retry -lt 3 ]]; do
+ if [[ ! -e /run/haproxy.pid || ! -d /proc/$(cat /run/haproxy.pid) ]]; then
+ retry=$((retry+1))
+ sleep 2
+ continue
+ fi
+ retry=0
sleep 5
done
-# Based on the above loop this point should never be reached
exit 1