perf(egress-proxy): hostNetwork benchmark acceptance + single-active benchmark guard for #1077

Document the per-target egressProxy.hostNetwork YAML option and the
real-deps-500m production-ready throughput acceptance profile in
docs/reference/platform-infra.md, and add a single-active guard to the
k3s-build-benchmark start path so a new run deletes any prior target+profile
Job before applying the new one (preventing concurrent runs from making
status report the wrong Job, observed during #1077 regression on D518).

Basis: merges PR #1065 (real k3s dependency proxy benchmark + hostNetwork
egress proxy) as the production-ready scaffold; validated on D601 and D518
with real-deps-500m (both succeeded, apk=1231/npm=850/go=693/real_deps=2774
MiB, proxyserver cumulative 2.4 GiB / 10 GiB).
This commit is contained in:
Codex
2026-06-26 19:05:08 +00:00
parent b9257db269
commit 6017b4a117
2 changed files with 19 additions and 2 deletions
@@ -241,7 +241,10 @@ function startBenchmarks(plans: readonly TargetPlan[], options: K3sBuildBenchmar
function startRowDetail(row: TargetPlan & { started: boolean; state: string; jobName: string; runId: string; result: unknown }): string {
if (!row.ok) return `${row.blocker}: ${row.detail}`;
if (row.started) return "status/logs/traffic";
if (row.started) {
const replaced = record(row.result).replaced;
return replaced === undefined || replaced === 0 ? "status/logs/traffic" : `status/logs/traffic replaced=${replaced}`;
}
const result = record(row.result);
const stderr = text(result.stderrPreview, "");
const stdout = text(result.stdoutPreview, "");
@@ -807,8 +810,18 @@ tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
manifest="$tmp/k3s-build-benchmark.yaml"
printf '%s' '${encoded}' | base64 -d > "$manifest"
selector="app.kubernetes.io/name=${BENCHMARK_APP},unidesk.ai/benchmark-profile=${profile.id},unidesk.ai/runtime-node=${target.id.toLowerCase()}"
# Single-active guard: delete any prior benchmark Jobs for this target+profile before applying the new
# one, so a new run cannot race with a stale/slow prior run and make status report the wrong Job.
# The benchmark is fire-and-forget and uses emptyDir, so deleting the prior Job is the safe way to keep
# exactly one active run per target.
replaced="$(kubectl -n ${shQuote(target.namespace)} get jobs -l "$selector" --no-headers 2>/dev/null | wc -l | tr -d ' ')"
[ -z "$replaced" ] && replaced=0
if [ "$replaced" != "0" ]; then
kubectl -n ${shQuote(target.namespace)} delete jobs -l "$selector" --ignore-not-found >/dev/null 2>&1
fi
kubectl apply -f "$manifest" >/dev/null
printf '{"ok":true,"jobName":"%s","namespace":"%s","target":"%s","runId":"%s","profile":"%s"}\\n' ${shQuote(jobName)} ${shQuote(target.namespace)} ${shQuote(target.id)} ${shQuote(runId)} ${shQuote(profile.id)}
printf '{"ok":true,"jobName":"%s","namespace":"%s","target":"%s","runId":"%s","profile":"%s","replaced":%s}\\n' ${shQuote(jobName)} ${shQuote(target.namespace)} ${shQuote(target.id)} ${shQuote(runId)} ${shQuote(profile.id)} "$replaced"
`;
}