Process lifecycle hook in post-running action hook

This commit is contained in:
Mikhail f. Shiryaev 2023-05-03 19:45:38 +02:00
parent d45092d63b
commit 197d0d1314
No known key found for this signature in database
GPG Key ID: 4B02ED204C7D93F4

View File

@ -85,6 +85,13 @@ if curl --fail http://169.254.169.254/latest/meta-data/events/recommendations/re
terminate-and-exit
fi
# Here we check if the autoscaling group marked the instance for termination, and it's wait for the job to finish
ASG_STATUS=$(curl -s http://169.254.169.254/latest/meta-data/autoscaling/target-lifecycle-state)
if [ "$ASG_STATUS" == "Terminated" ]; then
echo 'The runner is marked as "Terminated" by the autoscaling group, we are terminating'
terminate-and-exit
fi
# shellcheck disable=SC2046
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
# shellcheck disable=SC2046