Skip to content

Commit 8024fac

Browse files
committed
Improve lock awareness on TF destroy action
1 parent a1622d0 commit 8024fac

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

.github/workflows/multinode.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,19 @@ jobs:
371371
if: ${{ steps.config_ach.outcome == 'success' && contains(fromJSON('["success", "always"]'), inputs.break_on) }}
372372

373373
- name: Destroy
374-
run: terraform destroy -auto-approve -input=false
374+
run: |
375+
for attempt in $(seq 3); do
376+
if terraform destroy -auto-approve -input=false -lock-timeout=100s; then
377+
echo "Destroyed infrastructure on attempt $attempt"
378+
exit 0
379+
fi
380+
echo "Failed to destroy infrastructure on attempt $attempt"
381+
sleep 60
382+
done
383+
echo "Failed to destroy infrastructure after $attempt attempts"
384+
echo "Forcefully destroying infrastructure"
385+
terraform destroy -auto-approve -input=false -lock=false
386+
exit 1
375387
working-directory: ${{ github.workspace }}/terraform-kayobe-multinode
376388
env:
377389
OS_CLOUD: ${{ vars.OS_CLOUD }}

0 commit comments

Comments
 (0)