Fixed an issue occasionally causing an empty config for etcd slave nodes

The script which adds new nodes to etcd cluster now does up to 30 attempts
and fails (returns a non-zero exit code) if none are successful.

A minor performance optimization has been done as well, so no unneeded
waits happen when the command is successful and no temporary files are used.

Closes-Bug: #1494997
Change-Id: Ic0552f388518c119925da902b64797bbf96f979f
This commit is contained in:
Alexander Tivelkov 2015-09-12 05:22:21 +03:00
parent a4f4876340
commit 2da4435439

View File

@ -2,13 +2,15 @@
# $1 - NAME # $1 - NAME
# $2 - IP # $2 - IP
count=5 count=30
done=false
while [ $count -gt 0 ] && [ "$done" != "true" ] while [ $count -gt 0 ]; do
do out=$(/opt/bin/etcdctl member add "$1" "http://$2:7001")
/opt/bin/etcdctl member add $1 http://$2:7001 > /tmp/out && done="true" if [ $? -eq 0 ]; then
((count-- )) echo "$out" | grep ETCD_INITIAL_CLUSTER= | cut -f 2 -d '"'
sleep 2 exit 0
fi
((count-- ))
sleep 2
done done
cat /tmp/out | grep ETCD_INITIAL_CLUSTER | grep -n 1 | cut -f 2 -d'"' exit 1