From 731b78fb47fd8e049acb495ac54259c50eb53083 Mon Sep 17 00:00:00 2001 From: GWphua Date: Fri, 20 Dec 2024 16:56:52 +0800 Subject: [PATCH 1/5] Allow Dockerfile to exit after 3 failures --- integration-tests/docker/Dockerfile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/integration-tests/docker/Dockerfile b/integration-tests/docker/Dockerfile index 89fd45c97784..2320630a93a0 100644 --- a/integration-tests/docker/Dockerfile +++ b/integration-tests/docker/Dockerfile @@ -27,15 +27,17 @@ ARG ZK_VERSION ARG APACHE_ARCHIVE_MIRROR_HOST=https://archive.apache.org ARG SETUP_RETRIES=3 # Retry mechanism for running the setup script up to limit of 3 times. -RUN set -e; \ - for i in $(seq 1 $SETUP_RETRIES); do \ +RUN for i in $(seq 1 $SETUP_RETRIES); do \ echo "Attempt $i to run the setup script..."; \ APACHE_ARCHIVE_MIRROR_HOST=${APACHE_ARCHIVE_MIRROR_HOST} /root/base-setup.sh && break || { \ echo "Set up script attempt $i/$SETUP_RETRIES failed."; \ sleep 2; \ }; \ done; \ - rm -f /root/base-setup.sh + rm -f /root/base-setup.sh; \ + if [ "$i" -eq "$SETUP_RETRIES" ]; then \ + exit 1; \ + fi; \ FROM druidbase ARG MYSQL_VERSION From 22eb5722dfb6aa297ca36594c3ba07f06d34e3e1 Mon Sep 17 00:00:00 2001 From: GWphua Date: Fri, 20 Dec 2024 17:01:43 +0800 Subject: [PATCH 2/5] Allow Dockerfile to exit with same error code as last failed .sh run --- integration-tests/docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/docker/Dockerfile b/integration-tests/docker/Dockerfile index 2320630a93a0..59441ff15cc9 100644 --- a/integration-tests/docker/Dockerfile +++ b/integration-tests/docker/Dockerfile @@ -36,7 +36,7 @@ RUN for i in $(seq 1 $SETUP_RETRIES); do \ done; \ rm -f /root/base-setup.sh; \ if [ "$i" -eq "$SETUP_RETRIES" ]; then \ - exit 1; \ + exit $?; \ fi; \ FROM druidbase From 6577760a810cf25a9d0e62e05857226ab66313e1 Mon Sep 17 00:00:00 2001 From: GWphua Date: Fri, 20 Dec 2024 17:39:36 +0800 Subject: [PATCH 3/5] Remember last exit code before deleting base-setup.sh --- integration-tests/docker/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/integration-tests/docker/Dockerfile b/integration-tests/docker/Dockerfile index 59441ff15cc9..b33c27f9bf46 100644 --- a/integration-tests/docker/Dockerfile +++ b/integration-tests/docker/Dockerfile @@ -34,9 +34,10 @@ RUN for i in $(seq 1 $SETUP_RETRIES); do \ sleep 2; \ }; \ done; \ + LAST_EXIT_CODE=$?; \ rm -f /root/base-setup.sh; \ if [ "$i" -eq "$SETUP_RETRIES" ]; then \ - exit $?; \ + exit LAST_EXIT_CODE; \ fi; \ FROM druidbase From 1f604421b1a9fc372fa6ad557dc7d351552f0a23 Mon Sep 17 00:00:00 2001 From: GWphua Date: Fri, 20 Dec 2024 17:56:34 +0800 Subject: [PATCH 4/5] Prevent exit on 3rd success --- integration-tests/docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/docker/Dockerfile b/integration-tests/docker/Dockerfile index b33c27f9bf46..388edff5bec3 100644 --- a/integration-tests/docker/Dockerfile +++ b/integration-tests/docker/Dockerfile @@ -36,7 +36,7 @@ RUN for i in $(seq 1 $SETUP_RETRIES); do \ done; \ LAST_EXIT_CODE=$?; \ rm -f /root/base-setup.sh; \ - if [ "$i" -eq "$SETUP_RETRIES" ]; then \ + if [ "$i" -eq "$SETUP_RETRIES" ] && [ "$LAST_EXIT_CODE" -ne 0 ]; then \ exit LAST_EXIT_CODE; \ fi; \ From f5f9ef1f66ef3e13ba32f2e1b4dbc51543665626 Mon Sep 17 00:00:00 2001 From: GWphua Date: Fri, 20 Dec 2024 18:41:13 +0800 Subject: [PATCH 5/5] Fix bug where exit on 3rd success --- integration-tests/docker/Dockerfile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/integration-tests/docker/Dockerfile b/integration-tests/docker/Dockerfile index 388edff5bec3..c31d4a71861c 100644 --- a/integration-tests/docker/Dockerfile +++ b/integration-tests/docker/Dockerfile @@ -27,18 +27,19 @@ ARG ZK_VERSION ARG APACHE_ARCHIVE_MIRROR_HOST=https://archive.apache.org ARG SETUP_RETRIES=3 # Retry mechanism for running the setup script up to limit of 3 times. -RUN for i in $(seq 1 $SETUP_RETRIES); do \ - echo "Attempt $i to run the setup script..."; \ +RUN i=0; \ + while [ $i -lt $SETUP_RETRIES ]; do \ APACHE_ARCHIVE_MIRROR_HOST=${APACHE_ARCHIVE_MIRROR_HOST} /root/base-setup.sh && break || { \ + i=$(($i + 1)); \ echo "Set up script attempt $i/$SETUP_RETRIES failed."; \ sleep 2; \ }; \ done; \ - LAST_EXIT_CODE=$?; \ rm -f /root/base-setup.sh; \ - if [ "$i" -eq "$SETUP_RETRIES" ] && [ "$LAST_EXIT_CODE" -ne 0 ]; then \ - exit LAST_EXIT_CODE; \ - fi; \ + if [ "$i" -eq "$SETUP_RETRIES" ]; then \ + exit 1; \ + fi + FROM druidbase ARG MYSQL_VERSION