fix: fallback platform apply without refresh
Homelab Main / validate (push) Waiting to run Details
Homelab Main / running-update (push) Blocked by required conditions Details
Homelab Main / debian-ops (push) Blocked by required conditions Details

This commit is contained in:
juvenal.diaz 2026-10-07 12:40:17 -06:00
parent 32178fb840
commit 49304e2674
1 changed files with 8 additions and 0 deletions

View File

@ -580,6 +580,7 @@ tofu_apply_with_kubernetes_retry() {
shift
local max_attempts="${LAB_TOFU_K8S_APPLY_RETRIES:-3}"
local retry_sleep="${LAB_TOFU_K8S_APPLY_RETRY_SLEEP_SECONDS:-30}"
local refresh_fallback="${LAB_TOFU_K8S_REFRESH_FALSE_FALLBACK:-true}"
local attempt=1
local status=0
local output_file
@ -609,6 +610,13 @@ tofu_apply_with_kubernetes_retry() {
fi
if ((attempt >= max_attempts)); then
if truthy "${refresh_fallback}"; then
echo "OpenTofu ${stack} apply still hit Kubernetes API/OpenAPI read errors after ${attempt} attempt(s); trying one guarded -refresh=false apply." >&2
rm -f "${output_file}"
ensure_kubernetes_api_ready_for_tofu_stack "${stack}"
tofu -chdir="${REPO_ROOT}/${stack}" apply -refresh=false "$@"
return $?
fi
echo "OpenTofu ${stack} apply still hit Kubernetes API/OpenAPI errors after ${attempt} attempt(s)." >&2
rm -f "${output_file}"
return "${status}"