use retry to wait for swarm join

Signed-off-by: Chanwit Kaewkasi <chanwit@gmail.com>
This commit is contained in:
Chanwit Kaewkasi 2015-05-04 22:23:33 +07:00
parent 92f8c8ec60
commit 89fe217e12
1 changed files with 1 additions and 18 deletions

View File

@ -88,24 +88,7 @@ function swarm_join() {
SWARM_JOIN_PID[$i]=$!
((++i))
done
wait_until_swarm_joined $i
}
# Wait until a swarm instance joins the cluster.
# Parameter $1 is number of nodes to check.
function wait_until_swarm_joined {
local attempts=0
local max_attempts=10
until [ $attempts -ge $max_attempts ]; do
run docker -H $SWARM_HOST info
if [[ "${lines[3]}" == *"Nodes: $1"* ]]; then
break
fi
echo "Checking if joined successfully for the $((++attempts)) time" >&2
sleep 1
done
[[ $attempts -lt $max_attempts ]]
retry 30 1 [ `docker_swarm info | grep -q "Nodes: $i"` -eq 0 ]
}
# Stops the manager.