Skip to content

Commit ce2fd86

Browse files
authored
Fix terminate workflow by using JQ Args. (#15160)
This is failing today since we aren't injecting the bash variables correctly into JQ. This PR makes it so. We also increase the time limit to 4 hours to accommodate long running test jobs.
1 parent 3d49955 commit ce2fd86

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

.github/workflows/terminate-zombie-build-instances.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
terminate:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- name: List and Terminate Instances Older Than 3 Hours
16+
- name: List and Terminate Instances Older Than 4 Hours
1717
env:
1818
AWS_ACCESS_KEY_ID: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
1919
AWS_SECRET_ACCESS_KEY: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
@@ -22,7 +22,7 @@ jobs:
2222
run: |
2323
set -euxo pipefail
2424
25-
TIME_LIMIT=10800 # 3 hours
25+
export TIME_LIMIT=14400 # 4 hours
2626
2727
aws configure set default.region us-east-2
2828
@@ -31,7 +31,7 @@ jobs:
3131
export to_terminate=$(aws ec2 describe-instances --no-paginate --filters Name=instance-type,Values=c5.2xlarge Name=instance-state-name,Values=running \
3232
--query 'Reservations[*].Instances[*].{Instance:InstanceId,LaunchTime:LaunchTime}' --output json \
3333
| jq 'def toZ(str): str | (split("+")[0] + "Z") | fromdate ;
34-
flatten | map( { InstanceId: .Instance, LaunchTime: toZ(.LaunchTime) } ) | map( select ( .LaunchTime < (now - $TIME_LIMIT) ) )')
34+
flatten | map( { InstanceId: .Instance, LaunchTime: toZ(.LaunchTime) } ) | map( select ( .LaunchTime < (now - (env.TIME_LIMIT|tonumber)) ) )')
3535
3636
echo "MARKED FOR TERMINATION: ${to_terminate}"
3737

0 commit comments

Comments
 (0)