Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix: background the T1 port-forward as a direct kubectl child
Alfredo Lopez58a88d14c384
diff --git a/.cursor/rules/minikube-t2-harness.mdc b/.cursor/rules/minikube-t2-harness.mdcindex 1ecd6f67c..3119de28f 100644--- a/.cursor/rules/minikube-t2-harness.mdc+++ b/.cursor/rules/minikube-t2-harness.mdc@@ -64,6 +64,11 @@ Invariants that must never regress:PIDs recorded in the profile cache or legacy `/tmp/pf-<profile>-*.pid`.awk is a loose pre-filter: `kubectl` as argv0/path token and a laterstandalone `port-forward` token (flags may sit between them).+- T1 backgrounds its control-postgres port-forward as a direct `kubectl`+ child (never through the `t2_kc` function): a backgrounded function forks+ a subshell whose argv is the script, `$!` records that subshell, cleanup's+ `*port-forward*` guard never matches, and the orphaned real kubectl fails+ the final exact-head preflight with `PORT_FORWARD_CONFLICT`.- Stable failure codes (`BOOTSTRAP_REQUIRED`, `HEAD_MARKER_MISMATCH`,`PORT_FORWARD_CONFLICT`, `PROFILE_BUSY`, ...) keep their meanings.diff --git a/scripts/e2e/minikube-real-postgres.sh b/scripts/e2e/minikube-real-postgres.shindex b8993e846..dfa9e5a4f 100755--- a/scripts/e2e/minikube-real-postgres.sh+++ b/scripts/e2e/minikube-real-postgres.sh@@ -389,14 +389,13 @@ main() {T1_REDACT_PASSWORD="$PG_PASSWORD"LOCAL_PORT="$(choose_local_port)"- # Background kubectl DIRECTLY, not the t2_kc function. Backgrounding a shell- # function forks a subshell, so $! is the subshell's PID and its command line- # is this script's name — cleanup_t1's `svc/control-postgres` guard never- # matches it, so the kill is skipped and the port-forward (plus the subshell)- # orphan (PPID=1) past T1 into the T2 final preflight, tripping a spurious- # PORT_FORWARD_CONFLICT. Backgrounding kubectl directly makes PORT_FORWARD_PID- # the real forward whose command line the guard (and the wait) can act on.- kubectl --context="$T2_CONTEXT" -n "$PG_NAMESPACE" port-forward --address=127.0.0.1 svc/"$PG_SERVICE" "$LOCAL_PORT:5432" \+ # Launch kubectl directly, not through the t2_kc function: backgrounding a+ # function forks a subshell whose argv is this script, so $! would record+ # the subshell, the cleanup guard (*port-forward*svc/control-postgres*)+ # would never match, and the orphaned real kubectl port-forward would fail+ # the final exact-head preflight with PORT_FORWARD_CONFLICT.+ kubectl --context="$T2_CONTEXT" -n "$PG_NAMESPACE" port-forward \+ --address=127.0.0.1 svc/"$PG_SERVICE" "$LOCAL_PORT:5432" \>"$T1_TMP_DIR/port-forward.log" 2>&1 &PORT_FORWARD_PID=$!if ! wait_for_tcp "$LOCAL_PORT"; thendiff --git a/scripts/tests/test-minikube-t2-contract.sh b/scripts/tests/test-minikube-t2-contract.shindex c9f32a369..9ed74063f 100755--- a/scripts/tests/test-minikube-t2-contract.sh+++ b/scripts/tests/test-minikube-t2-contract.sh@@ -84,6 +84,14 @@ if grep -Fq "[ \"\$passed_files\" -ne \"\$expected\" ]" "$T1"; thenexit 1figrep -Fq 'port-forward' "$T1"+# The pf must be a direct kubectl child: backgrounding the t2_kc function+# records the subshell PID, cleanup never matches *port-forward*, and the+# orphaned kubectl fails the final preflight with PORT_FORWARD_CONFLICT.+if grep -Eq 't2_kc[^|]*port-forward' "$T1"; then+ echo 'FAIL: T1 backgrounds the control-postgres port-forward through the t2_kc function' >&2+ exit 1+fi+grep -Fq 'kubectl --context="$T2_CONTEXT" -n "$PG_NAMESPACE" port-forward' "$T1"grep -Fq 'set +x' "$T1" "$PREFLIGHT" "$T2"# T1 must restore the branch-profile GFS credentials on the way out with thediff --git a/scripts/tests/test-minikube-t2-scenarios.sh b/scripts/tests/test-minikube-t2-scenarios.shindex 6aff9ad3d..8bed1fab8 100755--- a/scripts/tests/test-minikube-t2-scenarios.sh+++ b/scripts/tests/test-minikube-t2-scenarios.sh@@ -278,6 +278,8 @@ grep -Fq 'GFS_RESTORE_ACTIVE_NOLOGIN=true' "$ROOT/scripts/e2e/minikube-real-postgrep -Fq 'GFS_RECOVER_ABANDONED_STATE=true' "$ROOT/scripts/e2e/minikube-real-postgres.sh" || fail 'T1 GFS restore must resume an interrupted gfsc-reader rollout claim'grep -Fq 'settle-gfs-reader-rollout.sh' "$ROOT/scripts/e2e/minikube-real-postgres.sh" || fail 'T1 GFS restore must settle a Ready gfsc-reader leftover rollout claim first'grep -Fq 'gfs-rollout-shim' "$ROOT/scripts/e2e/minikube-real-postgres.sh" || fail 'T1 GFS restore must use the HCC-safe reader rollout wait'+grep -Eq 't2_kc[^|]*port-forward' "$ROOT/scripts/e2e/minikube-real-postgres.sh" && fail 'T1 must background the port-forward as a direct kubectl child, not through the t2_kc function'+grep -Fq 'kubectl --context="$T2_CONTEXT" -n "$PG_NAMESPACE" port-forward' "$ROOT/scripts/e2e/minikube-real-postgres.sh" || fail 'T1 must launch the control-postgres port-forward with an explicit kubectl context'grep -Fq 'GFS_RESTORE_ACTIVE_NOLOGIN=true' "$ROOT/scripts/minikube/pre-gate-sync.sh" || fail 'pre-gate-sync must restore a NOLOGIN GFS role from the committed Secret DSN'grep -Fq 'GFS_RECOVER_ABANDONED_STATE=true' "$ROOT/scripts/minikube/pre-gate-sync.sh" || fail 'pre-gate-sync must resume an interrupted gfsc-reader rollout claim'grep -Fq 'settle-gfs-reader-rollout.sh' "$ROOT/scripts/minikube/pre-gate-sync.sh" || fail 'pre-gate-sync must settle a Ready gfsc-reader leftover rollout claim before reconcile'