argus's review on #5177: the git credential helper answered every `get`, so a config PR's own flake inputs could have git send the builder's forge token to any host. The helper is now configured under `credential.<forge-url>.helper` and itself answers only an https request whose host is the forge's; a test runs it as git does and checks that other hosts, http and non-get operations get nothing. Builds are bounded: every `build_agent` node needs the one `builder` jobq resource, so one runs at a time and the rest wait pending, and a newer head cancels its PR's pending build (a running one finishes and writes on its own commit). The builder also holds a one-permit semaphore around each build. `builder` and `review-classifier`, the forge logins swarm-controller owns, join nix/reserved-names.nix, with a test tying the list to both constants. The builder is now opt-in like the CI runner: `allSwarmServices` no longer turns it on, since it runs unreviewed config PRs through the host's nix daemon. mara had not answered atlas's question on the PR.
32 lines
1.6 KiB
Markdown
32 lines
1.6 KiB
Markdown
# swarm-builder
|
|
|
|
The swarm builder's build service, in the `swarm-builder` container on the
|
|
host that sets `deploy.builder.enable`. The design is
|
|
[`docs/swarm/builder.md`](../docs/swarm/builder.md).
|
|
|
|
swarm-controller sends one request per config PR head: an agent, a commit and
|
|
the PR. This service builds that agent config on the agent base this host was
|
|
deployed with, through the host's nix daemon, and answers with the system
|
|
closure's store path or the tail of what `nix` printed. The controller turns
|
|
the answer into a `swarm-builder` commit status on the PR's head.
|
|
|
|
## What a build is
|
|
|
|
- `nix build` of `nix/builder/check-flake`'s `check` output, with its three
|
|
inputs overridden: `hyperhive` and `nixpkgs` to this host's own sources, and
|
|
`agent` to `git+https://<forge>/agent-configs/<agent>?ref=refs/pull/<pr>/head&rev=<rev>`.
|
|
- The evaluation runs here, pure; the builds run in the host daemon's sandbox
|
|
as an untrusted client, so a config can neither set daemon options nor read
|
|
this service's environment.
|
|
- Nothing is pushed and nothing is recorded: the closure stays in the host's
|
|
store until it is collected.
|
|
|
|
## Credentials
|
|
|
|
The container holds one credential: its own store certificate, which nspawn
|
|
hands in at start without a copy on disk. With it the service reads its
|
|
queue client secret at start and its read-only forge token at every build.
|
|
`git` gets the token through a credential helper reading the child's
|
|
environment, never in a URL or an argument, and the helper answers only an
|
|
`https` request for the forge's host. Its store role reads exactly
|
|
those two paths.
|