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

A check runs as a cluster Job when checks.placement is job, through a stand-in Job client in tests #1630

Closed opened this
Closed without merging

A check now runs as a cluster Job when checks.placement is job, and process stays the default and unchanged. The new test file and the nearby suites pass, and tsc is clean. The real kube client (kubeJobClient) has not run against a cluster; tests use a stand-in.

Notes

stopped closed without shipping deploy eb5f41a

opened this

A check now runs as a cluster Job when checks.placement is job, and process stays the default and unchanged. The new test file and the nearby suites pass, and tsc is clean. The real kube client (kubeJobClient) has not run against a cluster; tests use a stand-in.

Two things behave differently from what you might assume:

  • Checkout delivery: the pod does not fetch the source. The checkout is written on a shared claim that the pod mounts at the forge's checks directory.
  • Pod environment: the pod gets only the check's own env (CI, FORGE_URL, FORGE_CHECK* and the like), not the forge's.

What changed

  • src/cluster/jobs.ts is new and has no dependency. It builds the Job manifest, with no service-account token in the pod and no retries.
    • runJob creates the Job, streams the pod's log into the run's log, polls for the verdict, and deletes the Job on pass, fail or abort.
    • The node selector and tolerations are validated at the boundary.
    • JobClient is the small interface tests stand in for; kubeJobClient is the real one, using fetch with the service-account token and CA.
  • src/checks/service.ts: when placement is job, the install and check commands run as one Job instead of in a cell. ChecksOptions.jobs lets tests inject the client. A bad config (no image, no claim, not in a cluster) fails the check with a plain message.
  • Placement setting: checks.placement (process or job) is a capacity setting, so it is live on the Capacity page and falls back to FORGE_CHECKS_PLACEMENT.
  • Job config: the image, claim, namespace, node selector and tolerations come from FORGE_CHECKS_* env vars, listed in docs/APPS.md.
  • Run record: migration 77 adds placement and node to run. They are set for every check; node is filled in once the pod has one.
  • Tests: test/check-job.test.ts (added to GATE in scripts/gate.ts) covers the manifest, parsers and runJob. It also checks that a check reaches ok and failed verdicts through the stand-in, that the log, node and placement are recorded, and that a missing image fails the check. A process-placement check still records placement: process and creates no Job.

What I left out

  • Node selector and tolerations are env-only. They are not editable on the Capacity page, which only holds counts and choices.
  • Nothing exists in charts/ for the claim, RBAC or image. Jobs need a PVC that the forge and the pods both mount, and a role allowing jobs and pods in the namespace.
  • The merge gate (gate()) also runs as a Job when placement is job, since it shares the same code path, but only the push-check path is tested.

To try it

  • Run bun test test/check-job.test.ts.
  • In a cluster, set FORGE_CHECKS_IMAGE and FORGE_CHECKS_CLAIM. Optionally set FORGE_CHECKS_NODE_SELECTOR and FORGE_CHECKS_TOLERATIONS. Then switch "Where checks run" to job on the Capacity page.

test/capacity.test.ts fails if FORGE_CHECK_SHARDS is set in the environment, as it is in my sandbox. It passes with that variable unset. That is not from this change.

Closes #1592

commented

Parked by the crew: the check failed ("the asks page > when nothing asks, it says All fine, and so does the header") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs