Public: anyone can read this; the crew can change it.

Hold a lane Job to its declared egress hosts, as a cell is #1907

Parked opened this
Closed without merging

A check placed as a Job can now be held to its declared egress hosts, but the NetworkPolicy half of this has not been run on a cluster. The new tests and tsc pass. The tests use a stand-in kube client, and the cell-only suites were skipped here, so the forge's check runs those.

Notes

stopped parked by the crew

opened this

A check placed as a Job can now be held to its declared egress hosts, but the NetworkPolicy half of this has not been run on a cluster. The new tests and tsc pass. The tests use a stand-in kube client, and the cell-only suites were skipped here, so the forge's check runs those.

Pod, not sidecar. The issue suggested a sidecar, but a NetworkPolicy selects whole pods, so a sidecar and the check would share the same allowance. The proxy therefore runs as a separate pod, and the policies let the check's pod reach that pod and nothing else.

What changed

  • Proxy: startEgress can now listen on TCP as well as a Unix socket. The new src/apps/egress_proxy.ts runs it as a process, with the declared hosts, the forge origin and the mode taken from validated environment variables.
  • Job flow: if the proxy image is set, runJob in src/cluster/jobs.ts starts the proxy pod and waits until it is ready before it makes the Job. It points the Job at the proxy through HTTP_PROXY/HTTPS_PROXY, so the Job never runs unheld. It deletes both at the end, and does so on every failure path too.
  • Refuse or report: cells.egress works as it does for a cell. enforce refuses undeclared hosts with a 403 that names them. report lets them through and records them as a cell's are.
  • Setup: FORGE_CHECKS_PROXY_IMAGE takes the forge's own image. Without it, behaviour is unchanged, and the run still says "egress not enforced on a cluster job". With it, the run is marked as contained.
  • Chart: charts/app/templates/lane.yaml holds two policies, behind lane.egressProxy (off by default). The check's pod gets egress to the proxy pod on port 3128 only. The proxy pod gets the forge, DNS and public 80/443, minus the private ranges.
  • Docs and tests: docs/APPS.md is updated. test/job-egress.test.ts covers the order of creation, the proxy address in the Job, cleanup, proxy startup failure, reported hosts, config validation and a live 403 over TCP.

Left out

  • lane.yaml did not exist in this repo, so the chart policies are new rather than narrowed.
  • Turn on lane.egressProxy only together with FORGE_CHECKS_PROXY_IMAGE. With the policies on and no proxy, a Job has no way out at all.
  • Clients that ignore proxy variables simply cannot connect, which is the intended outcome.
  • The policies need a CNI that enforces egress rules.

To try

  • Set FORGE_CHECKS_PLACEMENT=job with FORGE_CHECKS_PROXY_IMAGE=<forge image> and lane.egressProxy=true.
  • Push a check that fetches an undeclared host and see it fail with the 403, or show up in the reached hosts under report.
  • Locally, run bun test test/job-egress.test.ts.

Closes #1428

commented

A lane Job is now held to its declared egress hosts. The Job reaches those hosts through a proxy pod, and the network policies leave it no other way out.

The last check failed because test/job-egress.test.ts was in neither GATE nor EXCLUDED in scripts/gate.ts. I added it to EXCLUDED as "not yet admitted" under issue 1428. After that, bun scripts/gate.ts, test/check-list.test.ts and test/job-egress.test.ts pass (16 tests). I did not run the type check or the full suite; the forge runs those on the push.

I did not add it to GATE, because that needs ten flake-free runs under load (flake-hunt admit), which this pull doesn't carry. Until it is admitted, the forge's check does not run the egress tests.

Admitting the file is a separate follow-up.

🤖 Generated with Claude Code

commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs