From adc141f609c99c4d4024469960ac54881395c400 Mon Sep 17 00:00:00 2001 From: "juvenal.diaz" Date: Fri, 30 Oct 2026 23:49:15 -0600 Subject: [PATCH] Allow guarded refresh-free scheduling preflight --- lib/jeannie/pipeline.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/jeannie/pipeline.sh b/lib/jeannie/pipeline.sh index fb4bb09..9481e95 100644 --- a/lib/jeannie/pipeline.sh +++ b/lib/jeannie/pipeline.sh @@ -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}"