Add and fix wait for docker images
Closes-bug: #PROD-25515 (PROD:25515)
Related-bug: #PROD-25653 (PROD:25653)
Change-Id: I248e7ecdf298c349291fed88746a213e7130c0e7
diff --git a/config-drive/master_config.yaml b/config-drive/master_config.yaml
index 9352656..ad09fe5 100644
--- a/config-drive/master_config.yaml
+++ b/config-drive/master_config.yaml
@@ -149,19 +149,21 @@
# $1 is stack name
function wait_for_docker_images() {
local IMAGES=$(docker stack ps ${1} --format "{{.Image}}" | awk -F ':' '{print $1}' | uniq);
- local NOT_PULLED=""
+ local NOT_PULLED="NOT_PULLED"
local counter=0
- until [[ -z "${NOT_PULLED}" ]] || [ counter -eq 90 ]; do
+ until [[ -z "${NOT_PULLED}" ]] || [ $counter -eq 90 ]; do
+ NOT_PULLED=""
for image in ${IMAGES}; do
- NOT_PULLED=""
- local exist=$(docker images --format "{{if eq .Repository \"$image\"}}{{.Repository}}{{end}}");
+ local exist=$(docker images --format "{{if eq .Repository \"$image\"}}{{.Repository}}{{end}}" | tr -d '\n');
if [ -z "${exist}" ]; then
NOT_PULLED="${image} ${NOT_PULLED}"
fi;
done
- echo "Images ${NOT_PULLED} are not pulled yet"
- sleep 10;
- counter=$(( counter++ ))
+ if [ -n "${NOT_PULLED}" ]; then
+ echo "Images ${NOT_PULLED} are not pulled yet"
+ sleep 10;
+ $(( counter++ ))
+ fi
done
}