Skip to content

Commit

Permalink
Fix terminate workflow by using JQ Args. (airbytehq#15160)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
davinchia authored and UsmanAli99 committed Aug 3, 2022
1 parent f848f08 commit 2efdb88
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/terminate-zombie-build-instances.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
terminate:
runs-on: ubuntu-latest
steps:
- name: List and Terminate Instances Older Than 3 Hours
- name: List and Terminate Instances Older Than 4 Hours
env:
AWS_ACCESS_KEY_ID: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
Expand All @@ -22,7 +22,7 @@ jobs:
run: |
set -euxo pipefail
TIME_LIMIT=10800 # 3 hours
export TIME_LIMIT=14400 # 4 hours
aws configure set default.region us-east-2
Expand All @@ -31,7 +31,7 @@ jobs:
export to_terminate=$(aws ec2 describe-instances --no-paginate --filters Name=instance-type,Values=c5.2xlarge Name=instance-state-name,Values=running \
--query 'Reservations[*].Instances[*].{Instance:InstanceId,LaunchTime:LaunchTime}' --output json \
| jq 'def toZ(str): str | (split("+")[0] + "Z") | fromdate ;
flatten | map( { InstanceId: .Instance, LaunchTime: toZ(.LaunchTime) } ) | map( select ( .LaunchTime < (now - $TIME_LIMIT) ) )')
flatten | map( { InstanceId: .Instance, LaunchTime: toZ(.LaunchTime) } ) | map( select ( .LaunchTime < (now - (env.TIME_LIMIT|tonumber)) ) )')
echo "MARKED FOR TERMINATION: ${to_terminate}"
Expand Down

0 comments on commit 2efdb88

Please sign in to comment.