Skip to content

fix(personhog): move harness ports out of the ephemeral range - #71099

Merged
z0br0wn merged 2 commits into
masterfrom
zbrown/harness-port-fix
Jul 15, 2026
Merged

fix(personhog): move harness ports out of the ephemeral range#71099
z0br0wn merged 2 commits into
masterfrom
zbrown/harness-port-fix

Conversation

@z0br0wn

@z0br0wn z0br0wn commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Problem

The e2e harness's fixed listen ports (51051-51160) sit inside Linux's ephemeral port range (default 32768-60999), where the kernel allocates the local port of every outbound connection. During stack bring-up, eight services open Kafka, Postgres, and etcd connections in the same instant the listeners bind, so a listener occasionally loses its port to someone's outbound socket and dies with EADDRINUSE. This is a pure lottery that has now failed the gate on unrelated PRs (observed twice in CI: a leader gRPC port and a leader metrics port), always passing on retry.

The failure reports for those crashes were also nearly useless. The harness forced RUST_BACKTRACE=1 into every spawned service, so the panic printed ~50 frames of runtime internals that pushed the panic message itself out of the 30-line log tail the report embeds. The one line naming the cause was the one line missing, and what did survive was wrapped in raw ANSI escape codes rendered as literal \x1b[2m soup.

Changes

  • All harness ports move from 51xxx to 24xxx, below the ephemeral floor, where the kernel never allocates local ports. The collision becomes structurally impossible instead of merely unlikely, and the port-range comment now documents the below-32768 constraint so the range does not drift back up.
  • Spawned services run without RUST_BACKTRACE (a panic prints just its message, which fits the log tail) and with NO_COLOR=1. log_tail additionally strips ANSI escape sequences as a guarantee for anything that ignores NO_COLOR.
  • The gate CI steps drop their RUST_BACKTRACE: 1 env. The harness's own errors are context-rich anyhow chains, and the 35-frame tokio backtrace appended to each one carried no signal. The workspace cargo test step keeps its backtrace setting, where it is actually useful.

How did you test this code?

All automated, no manual testing beyond running the harness locally:

  • cargo test -p personhog-test-harness passes (10 tests). One new unit test covers the ANSI stripper, since a broken stripper would silently degrade every future failure report rather than fail any run.
  • A full gate run passes on the new ports (100 persons, 10s, zero violations), and the service log files from that run were verified byte-for-byte free of ANSI escapes, confirming the services honor NO_COLOR at the source.
  • clippy with -D warnings and fmt are clean; the workflow YAML parses.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Built with Claude Code. The port collision was diagnosed from two CI failures with the same shape (EADDRINUSE at bring-up on the very first gate step, so no leftover-process explanation was possible, and green on retry). The readability problem was found while diagnosing the second failure: the embedded log tail showed backtrace frames 44 through 53 but not the panic message, which turned out to be the harness's own doing via the forced RUST_BACKTRACE=1. An alternative considered for the ports was reserving them via ip_local_reserved_ports in CI, rejected as runner-specific plumbing when moving the range fixes it everywhere, including local runs.

z0br0wn added 2 commits July 15, 2026 10:00
The harness's fixed listen ports (51xxx) sat inside Linux's ephemeral
range (32768-60999), where the kernel allocates the local port of every
outbound connection. During bring-up all eight services open Kafka, PG,
and etcd connections in the same instant the listeners bind, so a
listener occasionally lost its port to someone's outbound socket and
died with EADDRINUSE — observed in CI on the very first gate step,
passing on retry. The whole range moves to 24xxx, below the ephemeral
floor, where the collision is structurally impossible.
A service crash produced an unreadable dump: the harness forced
RUST_BACKTRACE=1 into every spawned service, so a panic printed fifty
frames of runtime internals that pushed the panic message itself out of
the 30-line log tail the failure report embeds — the one line naming
the cause was the one line missing. Spawned services now run without
backtraces (the panic message is the signal) and with NO_COLOR, and
log_tail strips any remaining ANSI escapes, which previously rendered
as literal escape-code soup when re-emitted through the harness's own
logging. The gate CI steps also drop RUST_BACKTRACE so the harness's
own anyhow errors, which already carry full context, stop appending
35-frame tokio backtraces.
@z0br0wn
z0br0wn requested a review from a team July 15, 2026 14:32
@z0br0wn z0br0wn self-assigned this Jul 15, 2026
@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team July 15, 2026 14:32
@greptile-apps

greptile-apps Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix(personhog): make harness failure rep..." | Re-trigger Greptile

@z0br0wn
z0br0wn merged commit 828bab7 into master Jul 15, 2026
226 checks passed
@z0br0wn
z0br0wn deleted the zbrown/harness-port-fix branch July 15, 2026 14:47
@trunk-io

trunk-io Bot commented Jul 15, 2026

Copy link
Copy Markdown

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

@deployment-status-posthog

deployment-status-posthog Bot commented Jul 15, 2026

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-07-15 15:19 UTC Run
prod-us ✅ Deployed 2026-07-15 15:46 UTC Run
prod-eu ✅ Deployed 2026-07-15 15:48 UTC Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants