Merge pull request #263 from balena-io/ab77/patch-1

break from wait loops if EC2 instance is terminated
This commit is contained in:
Anton Belodedenko 2024-06-25 12:09:18 -07:00 committed by GitHub
commit 10e2908b4e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -470,8 +470,8 @@ jobs:
echo "::warning::Still working..." echo "::warning::Still working..."
sleep "$(( (RANDOM % 5) + 5 ))s" sleep "$(( (RANDOM % 5) + 5 ))s"
aws ec2 wait instance-running --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 }} aws ec2 wait instance-status-ok --instance-ids ${{ steps.balena-sut.outputs.instance_id }} || break
done done
echo "key_id=${GITHUB_SHA}" >> "${GITHUB_OUTPUT}" echo "key_id=${GITHUB_SHA}" >> "${GITHUB_OUTPUT}"
@ -509,8 +509,8 @@ jobs:
echo "::warning::Still working..." echo "::warning::Still working..."
sleep "$(( (RANDOM % 30) + 30 ))s" sleep "$(( (RANDOM % 30) + 30 ))s"
aws ec2 wait instance-running --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 }} aws ec2 wait instance-status-ok --instance-ids ${{ steps.balena-sut.outputs.instance_id }} || break
done done
# wait for Docker healthchecks # wait for Docker healthchecks
@ -523,8 +523,8 @@ jobs:
echo "::warning::Still working..." echo "::warning::Still working..."
sleep "$(( (RANDOM % 30) + 30 ))s" sleep "$(( (RANDOM % 30) + 30 ))s"
aws ec2 wait instance-running --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 }} aws ec2 wait instance-status-ok --instance-ids ${{ steps.balena-sut.outputs.instance_id }} || break
done done
# (TBC) https://www.balena.io/docs/reference/supervisor/docker-compose/ # (TBC) https://www.balena.io/docs/reference/supervisor/docker-compose/
@ -563,8 +563,8 @@ jobs:
echo "::warning::Still working..." echo "::warning::Still working..."
sleep "$(( (RANDOM % 30) + 30 ))s" sleep "$(( (RANDOM % 30) + 30 ))s"
aws ec2 wait instance-running --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 }} aws ec2 wait instance-status-ok --instance-ids ${{ steps.balena-sut.outputs.instance_id }} || break
done done
- name: SUT&DUT (balena) - name: SUT&DUT (balena)
@ -609,8 +609,8 @@ jobs:
echo "::warning::Still working..." echo "::warning::Still working..."
sleep "$(( ( RANDOM % ${{ env.RETRY }} ) + ${{ env.RETRY }} ))s" sleep "$(( ( RANDOM % ${{ env.RETRY }} ) + ${{ env.RETRY }} ))s"
aws ec2 wait instance-running --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 }} aws ec2 wait instance-status-ok --instance-ids ${{ steps.balena-sut.outputs.instance_id }} || break
done done
# .. once the service exits with status == exited, it is assumed to be finished # .. 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" sleep "$(( ( RANDOM % ${{ env.RETRY }} ) + ${{ env.RETRY }} ))s"
aws ec2 wait instance-running --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 }} aws ec2 wait instance-status-ok --instance-ids ${{ steps.balena-sut.outputs.instance_id }} || break
done done
# .. check its exit code # .. check its exit code
@ -908,8 +908,8 @@ jobs:
with_backoff docker compose ls with_backoff docker compose ls
sleep $(((RANDOM%5) + 5))s sleep $(((RANDOM%5) + 5))s
aws ec2 wait instance-running --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 }} aws ec2 wait instance-status-ok --instance-ids ${{ steps.ubuntu-sut.outputs.instance_id }} || break
done done
echo '::info::composition started' echo '::info::composition started'
@ -920,8 +920,8 @@ jobs:
with_backoff docker compose ps with_backoff docker compose ps
sleep $(((RANDOM%5) + 5))s sleep $(((RANDOM%5) + 5))s
aws ec2 wait instance-running --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 }} aws ec2 wait instance-status-ok --instance-ids ${{ steps.ubuntu-sut.outputs.instance_id }} || break
done done
echo "::info::${service} started" echo "::info::${service} started"
done done
@ -936,8 +936,8 @@ jobs:
echo '::info::still running...' echo '::info::still running...'
sleep $(((RANDOM%1) + 1))s sleep $(((RANDOM%1) + 1))s
aws ec2 wait instance-running --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 }} aws ec2 wait instance-status-ok --instance-ids ${{ steps.ubuntu-sut.outputs.instance_id }} || break
done done
aws ssm wait command-executed --command-id "${cid}" --instance-id "${iid}" aws ssm wait command-executed --command-id "${cid}" --instance-id "${iid}"