Skip to content

Commit 3d467b6

Browse files
authored
Merge pull request #432 from NHSDigital/apm-3869-fix-ecs-clean-up-pipeline
APM-3869 Fix ECS clean up pipeline again
2 parents 0c3064b + 1b0c45d commit 3d467b6

2 files changed

Lines changed: 17 additions & 13 deletions

File tree

azure/cleanup-ecs-pr-proxies.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ trigger: none
44
pr: none
55

66
schedules:
7-
- cron: "0 2 * * *"
7+
- cron: "0 */4 * * *" # Every 4 hours
88
displayName: Daily PR cleanup
99
branches:
1010
include:
@@ -47,6 +47,13 @@ jobs:
4747
- bash: |
4848
tfenv use 0.14.6
4949
displayName: setup terraform
50+
51+
- task: s3-cache-action@1
52+
inputs:
53+
key: poetry | utils | poetry.lock
54+
location: ".venv"
55+
debug: true
56+
displayName: cache utils pre-requisites
5057

5158
- bash: |
5259
make install
@@ -61,5 +68,5 @@ jobs:
6168
echo "AWS role session has timed out after multiple retries"
6269
exit -1
6370
displayName: Trigger failure if role has timed out
64-
condition: eq(variables['has_aws_role_timedout'], 'true')
71+
condition: eq(variables['should_retry'], 'true')
6572

azure/components/cleanup-ecs-pr-proxies-job.yml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,17 @@ steps:
1111
- bash: |
1212
make remove-stale-locks
1313
export retain_hours=72
14-
ANSIBLE_FORCE_COLOR=yes make -C ansible remove-old-ecs-pr-deploys | tee /tmp/output.txt
14+
ANSIBLE_FORCE_COLOR=yes make -C ansible remove-old-ecs-pr-deploys
1515
ERROR_CODE=$?
16-
ROLE_TIMEOUT_MSG="The AWS assume role session token is due to expire"
17-
if grep -q "$ROLE_TIMEOUT_MSG" /tmp/output.txt ; then
18-
echo "stderr for ansible has the error \"$ROLE_TIMEOUT_MSG\""
19-
echo "Re-assuming role and re-running step"
20-
echo "##vso[task.setvariable variable=has_aws_role_timedout;]true"
16+
echo ERROR_CODE - $ERROR_CODE
17+
18+
if [ $ERROR_CODE -ne 0 ] ; then
19+
echo "\n\nansible has unhandled error, re-trying"
20+
echo "##vso[task.setvariable variable=should_retry;]true"
2121
22-
elif [ $ERROR_CODE -ne 0 ] ; then
23-
echo "\n\nansible has unhandled error, re-raising"
24-
exit -1
2522
else
26-
echo "##vso[task.setvariable variable=has_aws_role_timedout;]false"
23+
echo "##vso[task.setvariable variable=should_retry;]false"
2724
fi
2825
2926
displayName: "cleanup older pr deploys"
30-
condition: or(eq( ${{ parameters.retry }}, '0'), eq(variables['has_aws_role_timedout'], 'true'))
27+
condition: or(eq( ${{ parameters.retry }}, '0'), eq(variables['should_retry'], 'true'))

0 commit comments

Comments
 (0)