Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix: match Linux HH:MM:SS in T2 port-forward awk

Alfredo Lopeze30fd90b8630
diff --git a/.cursor/rules/minikube-t2-harness.mdc b/.cursor/rules/minikube-t2-harness.mdc
index 9fa8f1721..3a640e674 100644
--- a/.cursor/rules/minikube-t2-harness.mdc
+++ b/.cursor/rules/minikube-t2-harness.mdc
@@ -34,6 +34,8 @@ Invariants that must never regress:
`pre-gate-sync` with `--skip-port-forwards`.
- `t2_process_check` accepts only real `kubectl` (`comm=kubectl`) port-forward
PIDs recorded in the profile cache or legacy `/tmp/pf-<profile>-*.pid`.
+ The awk argv0 filter anchors on the `ps -ef` TIME token in both macOS
+ (`N:MM[.ss]`) and Linux (`HH:MM:SS`) forms.
- Stable failure codes (`BOOTSTRAP_REQUIRED`, `HEAD_MARKER_MISMATCH`,
`PORT_FORWARD_CONFLICT`, `PROFILE_BUSY`, ...) keep their meanings.
diff --git a/.cursor/skills/minikube-t0-t1-t2/reference.md b/.cursor/skills/minikube-t0-t1-t2/reference.md
index c06c51e50..646827216 100644
--- a/.cursor/skills/minikube-t0-t1-t2/reference.md
+++ b/.cursor/skills/minikube-t0-t1-t2/reference.md
@@ -26,7 +26,9 @@ Companion to `SKILL.md`. Source of truth: `scripts/minikube/t2.sh`,
argv** when avoidable. `t2_process_check` accepts only real `kubectl`
processes (`comm=kubectl`) whose PIDs are recorded in the profile cache or
legacy `/tmp/pf-<profile>-*.pid`; a lookalike wrapper trips
- `PORT_FORWARD_CONFLICT`.
+ `PORT_FORWARD_CONFLICT`. The argv0 pre-filter keys off the `ps -ef` TIME
+ field immediately before `kubectl` and must match both macOS `N:MM[.ss]`
+ and Linux `HH:MM:SS`.
- **Do not commit** `.local-notes/`, lockfiles produced by an incidental
`npm ci`, generated ports/profile metadata, or anything secret-like. Run
`make minikube-t2-public-boundary` first.
diff --git a/docs/testing/minikube-t2-runbook.md b/docs/testing/minikube-t2-runbook.md
index 85b7be21b..9ccc2323e 100644
--- a/docs/testing/minikube-t2-runbook.md
+++ b/docs/testing/minikube-t2-runbook.md
@@ -107,7 +107,8 @@ Never remove a lock with a live owner, and never remove the whole lock root.
The runner checks required namespaces, Services, Secret names, ConfigMap names,
the `control-postgres` PVC/deployment, all required deployment readiness, the
image manifest/source, and real `kubectl port-forward` processes for this
-profile. Allowed port-forward PIDs live in
+profile. The conflict check keys argv0 off the `ps -ef` TIME field and accepts
+both macOS `N:MM[.ss]` and Linux `HH:MM:SS`. Allowed port-forward PIDs live in
`$HOME/.cache/clerum/minikube-profiles/<profile>/pids/*.pid` (and the
legacy `/tmp/pf-<profile>-*.pid` files written by `pf-all-stack.sh`).
`make minikube-t2` invokes `pre-gate-sync` with `--skip-port-forwards` so the
diff --git a/scripts/minikube/t2-common.sh b/scripts/minikube/t2-common.sh
index 543ab8a41..40b58ac3d 100755
--- a/scripts/minikube/t2-common.sh
+++ b/scripts/minikube/t2-common.sh
@@ -514,6 +514,7 @@ t2_process_check() {
# Only real kubectl port-forward processes. A wrapper whose argv merely
# mentions those words is not a port-forward.
# Default IFS so UID/PID/PPID split. `IFS=` left pid empty and skipped every line.
+ # awk keys argv0 off the ps -ef TIME column: macOS N:MM[.ss], Linux HH:MM:SS.
while read -r uid pid ppid rest; do
[ -n "$pid" ] || continue
command_line="$uid $pid $ppid $rest"
@@ -543,7 +544,7 @@ t2_process_check() {
T2_NEXT_COMMAND='stop the unrelated profile port-forward or select the owner worktree; do not share it'
t2_fail PORT_FORWARD_CONFLICT 'a port-forward for this profile is owned by another process'
fi
- done < <(ps -ef 2>/dev/null | awk '/[[:space:]][0-9]+:[0-9]+(\.[0-9]+)?[[:space:]]+([^[:space:]]*\/)?kubectl[[:space:]]+port-forward([[:space:]]|$)/ {print}' || true)
+ done < <(ps -ef 2>/dev/null | awk '/[[:space:]][0-9]+:[0-9]+(:[0-9]+)?(\.[0-9]+)?[[:space:]]+([^[:space:]]*\/)?kubectl[[:space:]]+port-forward([[:space:]]|$)/ {print}' || true)
}
t2_classify_transition() {
diff --git a/scripts/tests/test-minikube-t2-contract.sh b/scripts/tests/test-minikube-t2-contract.sh
index 4a89f4ac8..98556e4a9 100755
--- a/scripts/tests/test-minikube-t2-contract.sh
+++ b/scripts/tests/test-minikube-t2-contract.sh
@@ -32,6 +32,10 @@ if grep -Eq 'while IFS= read -r uid pid ppid rest' "$COMMON"; then
exit 1
fi
grep -Fq 'while read -r uid pid ppid rest' "$COMMON"
+if ! grep -Fq '[0-9]+:[0-9]+(:[0-9]+)?(\.[0-9]+)?' "$COMMON"; then
+ echo 'FAIL: t2_process_check awk TIME token must accept Linux HH:MM:SS' >&2
+ exit 1
+fi
grep -Fq 'CONTROL_API_REAL_PG_CONTEXT' "$T1"
grep -Fq 'CONTROL_API_REAL_PG_ADMIN_URL=' "$T1"
grep -Fq 'CONTROL_API_REAL_PG_REQUIRED=1' "$T1"
diff --git a/scripts/tests/test-minikube-t2-scenarios.sh b/scripts/tests/test-minikube-t2-scenarios.sh
index 3c223ccf2..134efc692 100755
--- a/scripts/tests/test-minikube-t2-scenarios.sh
+++ b/scripts/tests/test-minikube-t2-scenarios.sh
@@ -257,13 +257,21 @@ grep -Fq 'PORT_FORWARD_CONFLICT' "$COMMON"
grep -Fq 'while read -r uid pid ppid rest' "$COMMON" || fail 't2_process_check must split ps -ef fields'
grep -Fq 'IFS= read -r uid pid ppid rest' "$COMMON" && fail 'IFS= read disables PID split and silences PORT_FORWARD_CONFLICT'
grep -Fq '([^[:space:]]*\/)?kubectl[[:space:]]+port-forward' "$COMMON" || fail 't2_process_check awk must match argv0 kubectl, not a wrapper mention'
+grep -Fq '[0-9]+:[0-9]+(:[0-9]+)?(\.[0-9]+)?' "$COMMON" || fail 't2_process_check awk TIME token must accept Linux HH:MM:SS as well as macOS N:MM[.ss]'
bare_pf='user 12345 1 0 10:00 ttys000 0:00 kubectl port-forward --context=clerum-feat-scenario svc/x 8080:80'
path_pf='user 124 1 0 10:00 ttys000 0:00 /usr/local/bin/kubectl port-forward --context=clerum-feat-scenario svc/y 9090:80'
+macos_frac_pf='user 12346 1 0 10:00 ttys000 0:00.03 kubectl port-forward --context=clerum-feat-scenario svc/x 8080:80'
+linux_pf='user 126 1 0 10:00 pts/0 00:00:00 kubectl port-forward --context=clerum-feat-scenario svc/z 7070:80'
+linux_path_pf='user 127 1 0 10:00 pts/0 00:00:00 /usr/bin/kubectl port-forward --context=clerum-feat-scenario svc/z 7070:80'
wrapper_pf='user 125 1 0 10:00 ttys000 0:00 bash -c echo kubectl port-forward'
-awk_pf='/[[:space:]][0-9]+:[0-9]+(\.[0-9]+)?[[:space:]]+([^[:space:]]*\/)?kubectl[[:space:]]+port-forward([[:space:]]|$)/ {print}'
-printf '%s\n' "$bare_pf" "$path_pf" "$wrapper_pf" | awk "$awk_pf" >"$tmp/pf-awk.out"
+linux_wrapper_pf='user 128 1 0 10:00 pts/0 00:00:00 bash -c echo kubectl port-forward'
+awk_pf='/[[:space:]][0-9]+:[0-9]+(:[0-9]+)?(\.[0-9]+)?[[:space:]]+([^[:space:]]*\/)?kubectl[[:space:]]+port-forward([[:space:]]|$)/ {print}'
+printf '%s\n' "$bare_pf" "$path_pf" "$macos_frac_pf" "$linux_pf" "$linux_path_pf" "$wrapper_pf" "$linux_wrapper_pf" | awk "$awk_pf" >"$tmp/pf-awk.out"
grep -Fq 'kubectl port-forward --context=clerum-feat-scenario svc/x' "$tmp/pf-awk.out" || fail 'awk missed a bare kubectl port-forward'
grep -Fq '/usr/local/bin/kubectl port-forward' "$tmp/pf-awk.out" || fail 'awk missed a path kubectl port-forward'
+grep -Fq '0:00.03 kubectl port-forward' "$tmp/pf-awk.out" || fail 'awk missed a macOS fractional TIME kubectl port-forward'
+grep -Fq '00:00:00 kubectl port-forward --context=clerum-feat-scenario svc/z' "$tmp/pf-awk.out" || fail 'awk missed a Linux HH:MM:SS kubectl port-forward'
+grep -Fq '/usr/bin/kubectl port-forward' "$tmp/pf-awk.out" || fail 'awk missed a Linux path kubectl port-forward'
grep -Fq 'bash -c echo kubectl port-forward' "$tmp/pf-awk.out" && fail 'awk matched a wrapper that only mentions kubectl'
read -r uid pid ppid rest <<<"$bare_pf"
[ "$pid" = 12345 ] || fail "ps field split left pid='$pid' instead of 12345"