Skip to content
Snippets Groups Projects
Commit f1111237 authored by MD NADEEM's avatar MD NADEEM Committed by MD NADEEM
Browse files

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
parent f4d6aaf0
No related branches found
No related tags found
No related merge requests found
...@@ -7,11 +7,16 @@ sysctl net.unix.max_dgram_qlen=128 ...@@ -7,11 +7,16 @@ sysctl net.unix.max_dgram_qlen=128
echo "Running command: '${CMD}'" echo "Running command: '${CMD}'"
$CMD $CMD
# TODO(SamYaple): This has the potential for a race condition triggered by a retry=0
# config reload that could cause the container to exit # The loop breaks only when haproxy.pid get missing even after 3 re-try.
while [[ -e "/proc/$(cat /run/haproxy.pid)" ]]; do 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 sleep 5
done done
# Based on the above loop this point should never be reached
exit 1 exit 1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment