Avoid killing terminate-instances task

This commit is contained in:
Mikhail f. Shiryaev 2022-06-28 17:51:47 +02:00
parent 6a67ba91cf
commit e1ac7477c9
No known key found for this signature in database
GPG Key ID: 4B02ED204C7D93F4

View File

@ -50,7 +50,9 @@ ROOT_STAT=($(df / | awk '/\// {print $4 " " int($4/$2 * 100)}'))
if [[ ${ROOT_STAT[0]} -lt 3000000 ]] || [[ ${ROOT_STAT[1]} -lt 5 ]]; then
echo "Going to terminate the runner, it has ${ROOT_STAT[0]}KiB and ${ROOT_STAT[1]}% of free space on /"
INSTANCE_ID=$(ec2metadata --instance-id)
( sleep 10 && aws ec2 terminate-instances --instance-ids "$INSTANCE_ID" ) &
# We execute it with at to not have it as an orphan process
# GH Runners kill all remain processes
echo "sleep 10; aws ec2 terminate-instances --instance-ids $INSTANCE_ID" | at now
exit 0
fi