From 85fd15d7b3528eb1f6dc0cb1955f5b9495cc4b02 Mon Sep 17 00:00:00 2001 From: Anton Belodedenko <2033996+ab77@users.noreply.github.com> Date: Tue, 25 Jun 2024 11:44:34 -0700 Subject: [PATCH] break from wait loops if EC2 instance is terminated change-type: patch --- .github/workflows/tests.yml | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a37720e..cf70337 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -470,8 +470,8 @@ jobs: echo "::warning::Still working..." sleep "$(( (RANDOM % 5) + 5 ))s" - aws ec2 wait instance-running --instance-ids ${{ steps.balena-sut.outputs.instance_id }} - aws ec2 wait instance-status-ok --instance-ids ${{ steps.balena-sut.outputs.instance_id }} + aws ec2 wait instance-running --instance-ids ${{ steps.balena-sut.outputs.instance_id }} || break + aws ec2 wait instance-status-ok --instance-ids ${{ steps.balena-sut.outputs.instance_id }} || break done echo "key_id=${GITHUB_SHA}" >> "${GITHUB_OUTPUT}" @@ -509,8 +509,8 @@ jobs: echo "::warning::Still working..." sleep "$(( (RANDOM % 30) + 30 ))s" - aws ec2 wait instance-running --instance-ids ${{ steps.balena-sut.outputs.instance_id }} - aws ec2 wait instance-status-ok --instance-ids ${{ steps.balena-sut.outputs.instance_id }} + aws ec2 wait instance-running --instance-ids ${{ steps.balena-sut.outputs.instance_id }} || break + aws ec2 wait instance-status-ok --instance-ids ${{ steps.balena-sut.outputs.instance_id }} || break done # wait for Docker healthchecks @@ -523,8 +523,8 @@ jobs: echo "::warning::Still working..." sleep "$(( (RANDOM % 30) + 30 ))s" - aws ec2 wait instance-running --instance-ids ${{ steps.balena-sut.outputs.instance_id }} - aws ec2 wait instance-status-ok --instance-ids ${{ steps.balena-sut.outputs.instance_id }} + aws ec2 wait instance-running --instance-ids ${{ steps.balena-sut.outputs.instance_id }} || break + aws ec2 wait instance-status-ok --instance-ids ${{ steps.balena-sut.outputs.instance_id }} || break done # (TBC) https://www.balena.io/docs/reference/supervisor/docker-compose/ @@ -563,8 +563,8 @@ jobs: echo "::warning::Still working..." sleep "$(( (RANDOM % 30) + 30 ))s" - aws ec2 wait instance-running --instance-ids ${{ steps.balena-sut.outputs.instance_id }} - aws ec2 wait instance-status-ok --instance-ids ${{ steps.balena-sut.outputs.instance_id }} + aws ec2 wait instance-running --instance-ids ${{ steps.balena-sut.outputs.instance_id }} || break + aws ec2 wait instance-status-ok --instance-ids ${{ steps.balena-sut.outputs.instance_id }} || break done - name: SUT&DUT (balena) @@ -609,8 +609,8 @@ jobs: echo "::warning::Still working..." sleep "$(( ( RANDOM % ${{ env.RETRY }} ) + ${{ env.RETRY }} ))s" - aws ec2 wait instance-running --instance-ids ${{ steps.balena-sut.outputs.instance_id }} - aws ec2 wait instance-status-ok --instance-ids ${{ steps.balena-sut.outputs.instance_id }} + aws ec2 wait instance-running --instance-ids ${{ steps.balena-sut.outputs.instance_id }} || break + aws ec2 wait instance-status-ok --instance-ids ${{ steps.balena-sut.outputs.instance_id }} || break done # .. once the service exits with status == exited, it is assumed to be finished @@ -626,8 +626,8 @@ jobs: sleep "$(( ( RANDOM % ${{ env.RETRY }} ) + ${{ env.RETRY }} ))s" - aws ec2 wait instance-running --instance-ids ${{ steps.balena-sut.outputs.instance_id }} - aws ec2 wait instance-status-ok --instance-ids ${{ steps.balena-sut.outputs.instance_id }} + aws ec2 wait instance-running --instance-ids ${{ steps.balena-sut.outputs.instance_id }} || break + aws ec2 wait instance-status-ok --instance-ids ${{ steps.balena-sut.outputs.instance_id }} || break done # .. check its exit code @@ -908,8 +908,8 @@ jobs: with_backoff docker compose ls sleep $(((RANDOM%5) + 5))s - aws ec2 wait instance-running --instance-ids ${{ steps.ubuntu-sut.outputs.instance_id }} - aws ec2 wait instance-status-ok --instance-ids ${{ steps.ubuntu-sut.outputs.instance_id }} + aws ec2 wait instance-running --instance-ids ${{ steps.ubuntu-sut.outputs.instance_id }} || break + aws ec2 wait instance-status-ok --instance-ids ${{ steps.ubuntu-sut.outputs.instance_id }} || break done echo '::info::composition started' @@ -920,8 +920,8 @@ jobs: with_backoff docker compose ps sleep $(((RANDOM%5) + 5))s - aws ec2 wait instance-running --instance-ids ${{ steps.ubuntu-sut.outputs.instance_id }} - aws ec2 wait instance-status-ok --instance-ids ${{ steps.ubuntu-sut.outputs.instance_id }} + aws ec2 wait instance-running --instance-ids ${{ steps.ubuntu-sut.outputs.instance_id }} || break + aws ec2 wait instance-status-ok --instance-ids ${{ steps.ubuntu-sut.outputs.instance_id }} || break done echo "::info::${service} started" done @@ -936,8 +936,8 @@ jobs: echo '::info::still running...' sleep $(((RANDOM%1) + 1))s - aws ec2 wait instance-running --instance-ids ${{ steps.ubuntu-sut.outputs.instance_id }} - aws ec2 wait instance-status-ok --instance-ids ${{ steps.ubuntu-sut.outputs.instance_id }} + aws ec2 wait instance-running --instance-ids ${{ steps.ubuntu-sut.outputs.instance_id }} || break + aws ec2 wait instance-status-ok --instance-ids ${{ steps.ubuntu-sut.outputs.instance_id }} || break done aws ssm wait command-executed --command-id "${cid}" --instance-id "${iid}"