fix: fallback platform apply without refresh
This commit is contained in:
parent
32178fb840
commit
49304e2674
|
|
@ -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}"
|
||||
|
|
|
|||
Loading…
Reference in New Issue