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

Checks and crew runs as cluster Jobs on any node: the lane moves to the vxrail (80 cores) instead of one pod's 5 GiB #1429

Closed opened this in answer to
Closed without merging

I've added checks as cluster Jobs, the first part of #1423. Setting checks.placement to job sends the next check to a batch/v1 Job on the nodes the operator picks. Placement defaults to process, which is unchanged.

Notes

stopped closed without shipping deploy b4e50c9

opened this

I've added checks as cluster Jobs, the first part of #1423. Setting checks.placement to job sends the next check to a batch/v1 Job on the nodes the operator picks. Placement defaults to process, which is unchanged. Everything is tested through a stand-in Job client; nothing has run against a real cluster yet.

How a placed check runs

  • Same preparation. The forge prepares the checkout in data/checks/<run> as before.
  • Fetched, not mounted. The data volume is local-path, which only one node can mount, so a Job on the vxrail can't reach it. Instead the Job runs bun /app/src/cluster/lane.ts from the forge's own image and fetches the checkout as a tar from the new GET /-/lane/:id/tree. That route only answers a token signed with the forge's key for that one checkout; the token expires at the Job's deadline. The route returns 404 once the check ends.
  • Same steps and log. The lane runs install and check with the same runStep a process uses. The pod log streams into the run's log, and a failure gets the same summary words.
  • Limits and placement. The cell's limits become the pod's requests, limits and emptyDir size. The pod runs as uid 1000 with no service account token. Node selector, tolerations, pull secrets and image come from FORGE_JOB_* (jobSettings); bad values are refused before anything reaches the cluster.
  • Fallback. A forge that can't start Jobs (not in a cluster, no FORGE_JOB_IMAGE) runs the check as a process and says why in the log.

What else changed

  • Run row: new placement and node columns (migration 74). For a process run, node is NODE_NAME (now passed in by the chart from spec.nodeName), else the hostname.
  • Vanished Jobs: a Job that is deleted or evicted, loses its node, or leaves the API unreachable for a minute ends its check as cancelled with interrupted: its Job vanished; queued again. The check is queued once more and fails if it vanishes a second time, so it never hangs. How a Job ended is decided by a pure function, judge in src/cluster/jobs.ts.
  • Kube client: src/cluster/jobs.ts talks to the API directly over the service account, with no dependency. It needs to create, get, list, watch and delete Jobs, get and list pods, and read pod logs, all in its own namespace. docs/CLUSTER.md has that Role. charts/app/templates/lane.yaml adds the ServiceAccount, Role, RoleBinding and the lane's NetworkPolicy behind lane.enabled: false.
  • Gate fix: test/review-from-check.test.ts was in neither gate list, so test/check-list.test.ts was failing on main. I added it to GATE; it passes.

Not done:

  • Egress is looser in a Job than in a cell. A NetworkPolicy can't name hosts, so the lane can reach DNS, the forge and any public host on ports 80/443, but no private ranges. A cell only reaches declared hosts. Tracked in #1428.
  • Crew runs and deploy builds still run as processes. Follow-ups #1426 and #1427, both waiting on #1423.
  • The ledger's cgroup numbers from the Job's pod (#1386): that ledger isn't in this tree yet. This pull only records node and placement for it.

Look closely at:

  • runInJob in src/checks/service.ts.
  • judge in src/cluster/jobs.ts.
  • The token check in src/cluster/tree.ts.

To try it, run FORGE_TEST_SOCKET=port bun test test/checks-job.test.ts. That runs a check to a verdict through the stand-in cluster, which runs the real lane over HTTP, plus the process placement and a vanished Job. test/checks.test.ts, test/capacity.test.ts, the five cross files and tsc pass. On the cluster, set lane.enabled: true in the chart and switch "Where checks run" to job on Settings → Capacity.

🤖 Generated with Claude Code

Closes #1423

2 earlier comments
commented

Checks can now run as Jobs on the cluster (#1423). When checks.placement is job, a check runs as a Kubernetes Job instead of as a child process of the forge. A forge that can't place Jobs records why and runs the check locally, as before. Each run records where it ran in run.placement and on which node in run.node. The chart has an opt-in lane for this: a Role, RoleBinding and NetworkPolicy, the FORGE_JOB_* env, and pull secrets for the Job's image.

This push brings the branch up to date with main, which no longer merged cleanly:

  • src/checks/service.ts: main added the fast check's merge into the base. That part merged on its own. The conflict was the child environment, which this branch moved out of the try so the Job and local paths share one. That shared environment now has main's FORGE_COMMIT: x.commitOid, so it names the pull's head and not the merge commit.
  • src/core/schema.ts: both branches added a migration 74. main keeps 74 (the look's attached_by/note), and this branch's run.placement/run.node becomes migration 75.
  • scripts/gate.ts: the gate's list check failed on main too after the merge. test/plan-route.test.ts was listed twice in EXCLUDED, and I kept the #1468 entry. test/review-from-check.test.ts was listed twice in GATE, and I kept one. test/attach-look.test.ts was in neither list; it passes (5 tests, 1.7 s), so it is now in GATE.

The type check passes, and these tests pass after the merge: check-list, checks, checks-job, review-from-check, attach-look and the two schema-migration suites. I didn't run the full check here; the forge runs it on this push.

🤖 Generated with Claude Code

commented

Lets a check run as a Kubernetes Job in the cluster instead of as a child process of the forge, when checks.placement is job (#1423). Process placement is still the default, so nothing changes unless that setting is turned on.

  • Running checks as Jobs: src/cluster/jobs.ts creates the Job, watches it until it finishes and reads its log; src/cluster/lane.ts holds the settings the Job runs under; src/cluster/tree.ts covers the files the Job is given. src/checks/service.ts picks process or Job per run.
  • Recording placement: migration 75 in src/core/schema.ts adds a column saying where each run ran (process or job); src/core/runs.ts fills it in.
  • Chart: the Helm chart gets an opt-in Role, RoleBinding and NetworkPolicy, plus the FORGE_JOB_* environment and image pull secrets the Job needs. docs/CLUSTER.md explains how to switch it on.
  • Tests: test/checks-job.test.ts is new and joins the gate. review-from-check is also added to the gate; it was in neither list, which turned the gate's own list check red.

Fix for the failed check: current main moved test/attach-look.test.ts to a different place in GATE. Merging main kept both copies, so test-shards stopped with "a file is named twice". Main is merged in again and the second copy removed. An earlier merge had also dropped main's exclusion of test/plan-route.test.ts, leaving it in neither list; it is restored. scripts/gate.ts now differs from main only by adding checks-job.

Checked here: the type check passes, and the check-list, check-tiers, checks-job, hollow, checks and crew-loop tests pass. The Job path is tested here against stand-ins (test/checks-job.test.ts), not against a real cluster.

To try it: set checks.placement to job on a deployment whose chart has the lane switched on (see docs/CLUSTER.md), push to a pull, and the run's placement should read job.

🤖 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