Allow guarded refresh-free scheduling preflight
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-30 23:49:15 -06:00
parent 0ab53e6bc7
commit adc141f609
1 changed files with 15 additions and 4 deletions

View File

@ -838,7 +838,7 @@ delete_prometheus_stack_storage() {
kubernetes_scheduling_preflight() {
local stack="$1"
shift
local directory status arg
local directory status arg plan_output retry_pattern
local -a plan_args=()
[[ "${stack}" == "bootstrap/platform" || "${stack}" == "bootstrap/apps" ]] || return 0
if [[ -z "${LAB_CLUSTER_CONTROL_PLANE_NODE_NAME:-}" ]]; then
@ -850,11 +850,22 @@ kubernetes_scheduling_preflight() {
done
directory="$(mktemp -d "${TMPDIR:-/tmp}/jeannie-scheduling.XXXXXX")" || return 1
echo "Checking scheduling feasibility for ${stack} before deployment..."
retry_pattern='bad record MAC|received record with version|first record does not look like a TLS handshake|TLS handshake timeout|unexpected EOF|unexpected error when reading response body|connection reset by peer|context deadline exceeded|failed to query with labels|connection refused|server is currently unable'
if ! tofu -chdir="${REPO_ROOT}/${stack}" plan -input=false -out="${directory}/plan" \
"${plan_args[@]}" >"${directory}/plan.log" 2>&1; then
cat "${directory}/plan.log" >&2
rm -rf -- "${directory}"
return 1
if ! grep -Eiq "${retry_pattern}" "${directory}/plan.log"; then
cat "${directory}/plan.log" >&2
rm -rf -- "${directory}"
return 1
fi
echo "Scheduling preflight hit a Kubernetes transport error; retrying with guarded -refresh=false plan..." >&2
plan_args+=("-refresh=false")
if ! tofu -chdir="${REPO_ROOT}/${stack}" plan -input=false -out="${directory}/plan" \
"${plan_args[@]}" >"${directory}/plan.log" 2>&1; then
cat "${directory}/plan.log" >&2
rm -rf -- "${directory}"
return 1
fi
fi
if ! tofu -chdir="${REPO_ROOT}/${stack}" show -json "${directory}/plan" >"${directory}/plan.json"; then
rm -rf -- "${directory}"