Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(minikube): avoid false negative gateway route guard
Alfredo Lopez38c6b02b3d37
diff --git a/.github/workflows/ci-public.yml b/.github/workflows/ci-public.ymlindex 1d25dd19c..596231727 100644--- a/.github/workflows/ci-public.yml+++ b/.github/workflows/ci-public.yml@@ -412,6 +412,9 @@ jobs:- name: Test pre-gate sync state contractrun: bash scripts/tests/test-minikube-pre-gate-sync-state.sh+ - name: Test pre-gate runtime assertions+ run: bash scripts/tests/test-minikube-pre-gate-runtime.sh+# ADMIN_PASSWORD is a required precondition of full-setup.sh Step 1 on the# default (minimal) seed profile. Two cases in this harness execute the# script against stubbed docker/minikube/kubectl, so without it they abortdiff --git a/scripts/minikube/pre-gate-runtime.sh b/scripts/minikube/pre-gate-runtime.shindex 5c34091fc..b3f7c03fe 100755--- a/scripts/minikube/pre-gate-runtime.sh+++ b/scripts/minikube/pre-gate-runtime.sh@@ -66,7 +66,8 @@ rollout_namespace_deployments() {assert_workflow_gateway_prompt_bridge_finalization_route() {local deployment="nginx-workflow-approval-gateway"local namespace="control-plane"- local candidate deletion ready pod_count=0+ local expected_route='location ~ ^/api/v1/mcp-host/plugin-workload-sdk/invocations/[^/]+/finalize$'+ local candidate deletion ready nginx_config inspect_rc pod_count=0if ! ${KC} get deployment "${deployment}" -n "${namespace}" >/dev/null 2>&1; thenlog "ERROR: ${namespace}/${deployment} is absent; refusing Plugin Workload SDK gate"@@ -86,8 +87,21 @@ assert_workflow_gateway_prompt_bridge_finalization_route() {-o jsonpath='{.status.containerStatuses[?(@.name=="nginx")].ready}' 2>/dev/null || true)"[[ "${ready}" == "true" ]] || continuepod_count=$((pod_count + 1))- if ! ${KC} exec -n "${namespace}" "${candidate}" -c nginx -- nginx -T 2>&1 | \- grep -Fq 'location ~ ^/api/v1/mcp-host/plugin-workload-sdk/invocations/[^/]+/finalize$'; then++ # Consume the complete command before searching it. With the caller's+ # `set -o pipefail`, piping `kubectl exec ... nginx -T` into `grep -q`+ # lets grep close the pipe as soon as it finds the route. kubectl can then+ # exit on SIGPIPE (141), turning a present route into a false failure.+ # Keeping execution and content validation separate also preserves the+ # distinction between an unreachable pod and a genuinely stale config.+ if nginx_config="$(${KC} exec -n "${namespace}" "${candidate}" -c nginx -- nginx -T 2>&1)"; then+ :+ else+ inspect_rc=$?+ log "ERROR: could not inspect the active nginx configuration in ${namespace}/${candidate} (kubectl exec rc=${inspect_rc}); refusing gate"+ return 1+ fi+ if [[ "${nginx_config}" != *"${expected_route}"* ]]; thenlog "ERROR: active ${namespace}/${candidate} does not serve the SDK finalization route; refusing gate"return 1fidiff --git a/scripts/tests/test-minikube-pre-gate-runtime.sh b/scripts/tests/test-minikube-pre-gate-runtime.shnew file mode 100755index 000000000..79c5e9df9--- /dev/null+++ b/scripts/tests/test-minikube-pre-gate-runtime.sh@@ -0,0 +1,114 @@+#!/usr/bin/env bash++set -uo pipefail++FAIL=0+REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"++pass() { printf 'PASS: %s\n' "$1"; }+fail() {+ printf 'FAIL: %s\n' "$1"+ FAIL=1+}++# Called indirectly by the sourced production helper.+# shellcheck disable=SC2329+log() { printf '[pre-gate-sync] %s\n' "$*"; }++# Exercise the real runtime guard without a cluster. The route-present fixture+# deliberately emits more than one pipe buffer after the match: under+# `set -o pipefail`, `grep -q` used to close its input early and turn a healthy+# `kubectl exec` into SIGPIPE (141), which the guard misreported as a missing+# route.+# Called through the production helper's KC command string.+# shellcheck disable=SC2329+kubectl() {+ case "$*" in+ *"get deployment nginx-workflow-approval-gateway -n control-plane"*)+ return 0+ ;;+ *"get pods -n control-plane -l app=nginx-workflow-approval-gateway"*)+ printf 'gateway-pod\n'+ return 0+ ;;+ *"get pod gateway-pod -n control-plane -o jsonpath={.metadata.deletionTimestamp}"*)+ return 0+ ;;+ *"get pod gateway-pod -n control-plane -o jsonpath={.status.containerStatuses"*)+ printf 'true'+ return 0+ ;;+ *"exec -n control-plane gateway-pod -c nginx -- nginx -T"*)+ case "${TEST_NGINX_MODE:?}" in+ route-present)+ trap 'exit 141' PIPE+ printf '%s\n' \+ 'location ~ ^/api/v1/mcp-host/plugin-workload-sdk/invocations/[^/]+/finalize$'+ local i=0+ while [[ "$i" -lt 4096 ]]; do+ printf 'trailing nginx configuration line %080d\n' "$i" || exit 141+ i=$((i + 1))+ done+ ;;+ route-absent)+ printf 'location = /health { return 200; }\n'+ ;;+ exec-failed)+ printf 'simulated nginx inspection failure\n' >&2+ return 42+ ;;+ *)+ printf 'unknown TEST_NGINX_MODE=%s\n' "$TEST_NGINX_MODE" >&2+ return 2+ ;;+ esac+ return 0+ ;;+ esac++ printf 'unexpected kubectl invocation: %s\n' "$*" >&2+ return 2+}++KC="kubectl --context=clerum-test"+PROFILE="clerum-test"+PROJECT_DIR="$REPO_ROOT"+GATE_NAME="plugin-workload-sdk"+export KC PROFILE PROJECT_DIR GATE_NAME++# shellcheck source=/dev/null+source "$REPO_ROOT/scripts/minikube/pre-gate-runtime.sh"++run_guard() {+ local mode="$1"+ TEST_NGINX_MODE="$mode" assert_workflow_gateway_prompt_bridge_finalization_route+}++output="$(run_guard route-present 2>&1)"+rc=$?+if [[ "$rc" -eq 0 ]] &&+ [[ "$output" == *'Workflow gateway serves the SDK promptBridge finalization route'* ]]; then+ pass "runtime guard accepts an exact route followed by a full nginx dump"+else+ fail "runtime guard rejected a present route (rc=${rc}): ${output}"+fi++output="$(run_guard route-absent 2>&1)"+rc=$?+if [[ "$rc" -ne 0 ]] &&+ [[ "$output" == *'does not serve the SDK finalization route'* ]]; then+ pass "runtime guard rejects a Ready pod whose nginx config omits the route"+else+ fail "runtime guard accepted an absent route or lost its diagnostic (rc=${rc}): ${output}"+fi++output="$(run_guard exec-failed 2>&1)"+rc=$?+if [[ "$rc" -ne 0 ]] &&+ [[ "$output" == *'could not inspect the active nginx configuration'* ]]; then+ pass "runtime guard distinguishes inspection failure from an absent route"+else+ fail "runtime guard did not fail closed on nginx inspection failure (rc=${rc}): ${output}"+fi++exit "$FAIL"diff --git a/scripts/tests/test-minikube-pre-gate-sync-state.sh b/scripts/tests/test-minikube-pre-gate-sync-state.shindex f29cb73d4..a4f47fc1e 100755--- a/scripts/tests/test-minikube-pre-gate-sync-state.sh+++ b/scripts/tests/test-minikube-pre-gate-sync-state.sh@@ -128,11 +128,13 @@ elsefiif runtime_contains 'assert_workflow_gateway_prompt_bridge_finalization_route()' &&- runtime_contains 'nginx -T' &&- runtime_contains 'invocations/[^/]+/finalize'; then- pass "pre-gate sync fails closed when the running gateway lacks SDK finalization"+ runtime_contains 'nginx_config="$(${KC} exec' &&+ runtime_contains 'could not inspect the active nginx configuration' &&+ runtime_contains '[[ "${nginx_config}" != *"${expected_route}"* ]]' &&+ ! grep -F 'nginx -T' "$RUNTIME_SCRIPT" | grep -Fq '|'; then+ pass "pre-gate runtime guard separates nginx inspection from route validation"else- fail "pre-gate sync does not verify the running SDK finalization route"+ fail "pre-gate runtime guard can confuse SIGPIPE or exec failure with a missing route"fiif contains 'fingerprint_dir packages/workflow-runtime-core' &&