fix: add timeout and retry for terraform refresh-heavy plans
All checks were successful
Terraform Plan / Terraform Plan (push) Successful in 5m22s

This commit is contained in:
2026-02-28 22:23:01 +00:00
parent f5d9eba9d0
commit 24c3f56399
3 changed files with 46 additions and 5 deletions

View File

@@ -53,7 +53,20 @@ jobs:
- name: Terraform Plan
working-directory: terraform
run: terraform plan -out=tfplan
run: |
set -euo pipefail
for attempt in 1 2; do
echo "Terraform plan attempt $attempt/2"
if timeout 20m terraform plan -parallelism=1 -out=tfplan; then
exit 0
fi
if [ "$attempt" -eq 1 ]; then
echo "Plan attempt failed or timed out; retrying in 20s"
sleep 20
fi
done
echo "Terraform plan failed after retries"
exit 1
- name: Block accidental destroy
env:

View File

@@ -74,15 +74,16 @@ jobs:
- name: Terraform Destroy Plan
working-directory: terraform
run: |
set -euo pipefail
case "${{ inputs.target }}" in
all)
terraform plan -destroy -out=tfdestroy
TF_PLAN_CMD="terraform plan -parallelism=1 -destroy -out=tfdestroy"
;;
control-planes)
terraform plan -destroy -target=proxmox_vm_qemu.control_planes -out=tfdestroy
TF_PLAN_CMD="terraform plan -parallelism=1 -destroy -target=proxmox_vm_qemu.control_planes -out=tfdestroy"
;;
workers)
terraform plan -destroy -target=proxmox_vm_qemu.workers -out=tfdestroy
TF_PLAN_CMD="terraform plan -parallelism=1 -destroy -target=proxmox_vm_qemu.workers -out=tfdestroy"
;;
*)
echo "Invalid destroy target: ${{ inputs.target }}"
@@ -90,6 +91,20 @@ jobs:
;;
esac
for attempt in 1 2; do
echo "Terraform destroy plan attempt $attempt/2"
if timeout 20m bash -lc "$TF_PLAN_CMD"; then
exit 0
fi
if [ "$attempt" -eq 1 ]; then
echo "Destroy plan attempt failed or timed out; retrying in 20s"
sleep 20
fi
done
echo "Terraform destroy plan failed after retries"
exit 1
- name: Terraform Destroy Apply
working-directory: terraform
run: |

View File

@@ -67,7 +67,20 @@ jobs:
- name: Terraform Plan
working-directory: terraform
run: terraform plan -out=tfplan
run: |
set -euo pipefail
for attempt in 1 2; do
echo "Terraform plan attempt $attempt/2"
if timeout 20m terraform plan -parallelism=1 -out=tfplan; then
exit 0
fi
if [ "$attempt" -eq 1 ]; then
echo "Plan attempt failed or timed out; retrying in 20s"
sleep 20
fi
done
echo "Terraform plan failed after retries"
exit 1
- name: Block accidental destroy
env: