From 15b5052fa10d085cd1b708f6d634826a116f9c03 Mon Sep 17 00:00:00 2001 From: Michal Nasiadka Date: Fri, 2 Feb 2024 14:26:02 +0100 Subject: [PATCH] toolbox: Improve retry loop for ansible-galaxy Currently if it somehow fails for 5 times - we get exit code 0. Closes-Bug: #2052293 Change-Id: I2bdeb77e3133123053b05adcbde3a426c60f3304 (cherry picked from commit 94bd013ed55fd79bc4bfa33121c823927ec40b56) --- docker/kolla-toolbox/Dockerfile.j2 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docker/kolla-toolbox/Dockerfile.j2 b/docker/kolla-toolbox/Dockerfile.j2 index 141c8f7c6a..08316fc96e 100644 --- a/docker/kolla-toolbox/Dockerfile.j2 +++ b/docker/kolla-toolbox/Dockerfile.j2 @@ -85,8 +85,10 @@ RUN {{ macros.install_pip(['pip', 'wheel', 'setuptools']) }} \ {% block kolla_toolbox_collections_install %} COPY requirements.yml /var/lib/ansible/ -RUN for i in {1..5}; do ansible-galaxy collection install --timeout 120 -p /usr/share/ansible/collections -r /var/lib/ansible/requirements.yml \ - && break || sleep 15; done +RUN fail=1; for i in $(seq 1 5); do if \ +ansible-galaxy collection install --timeout 120 -p /usr/share/ansible/collections -r /var/lib/ansible/requirements.yml \ +; then fail=0; break; fi; echo "Collection download failed, retrying"; sleep 5; done; \ +if [ "$fail" -eq 1 ]; then exit 1; fi ENV ANSIBLE_LIBRARY /usr/share/ansible:$ANSIBLE_LIBRARY {% endblock %}