Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Site
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software/vole.git

Self-hosted forge that lives in your Git repo.

Restructure documentation around reader tasks

348a43c364fbb04be834af44a7cd43a0931fa280 · Keenan Nemetz · 20d ago · parent b7383c19

Restructure documentation around reader tasks

Group the site by getting started, collaboration, CI, publishing, and administration. Rewrite the guides as executable procedures and move issue formats, merge semantics, configuration defaults, customization, and access-control mechanics into dedicated references.

Verify the quickstart and review flow against a throwaway instance, execute the service recipe, inspect the rendered site, and run the complete verify workflow.

Closes: 01M7B6X6RDYBAP3JVA5SYSA1K8

docs/runner.md +224−461

@@ -1,404 +1,209 @@
1 # Runners
1 # Runner reference
2 2
3 A runner is a machine that leases jobs over SSH, executes their steps in
4 containers, and reports the result. Workflows themselves are described in
5 [Workflows](workflows.md); this page is about the machines that run them.
3 A runner leases jobs over SSH, executes their steps in OCI containers, and
4 reports results to the instance. Use [Set up a runner](deploy/runner.md) for the
5 installation procedure and [Workflows](workflows.md) for job definitions. This
6 page defines the runner's execution, trust, storage, and queue behavior.
6 7
7 8 ## Start a runner
8 9
9 To have a machine set up for you — the unit, the account rootless Podman needs,
10 and the pinned host key — see [CI runners](deploy/runner.md).
11
12 A runner needs an OCI runtime: Docker, rootless Podman, or nerdctl. Rootless
13 Podman is preferred, because membership in the Docker group is effectively root on
14 the host. Start a runner anywhere it can reach the Vole server and that runtime:
10 A runner needs Docker, rootless Podman, or nerdctl and network access to the
11 instance's SSH listener. Rootless Podman is preferred because Docker-group
12 membership is effectively host root.
15 13
16 14 ```sh
17 15 vole runner --remote ssh://git@host:2222 --container-runtime podman
18 16 vole runner --remote ssh://git@host:2222 --container-runtime podman --once
19 ```
20
21 You can describe the machine and limit which repositories it serves:
22
23 ```sh
24 17 vole runner --remote ssh://git@host:2222 --label linux --label arm64
25 18 vole runner --remote ssh://git@host:2222 --repos demo --repos docs
26 19 ```
27 20
28 - `--label` says what the machine is. A job is sent only to a runner that has
29 every label in its `runs-on`. A job with no `runs-on` can run anywhere.
30 - `--repos` narrows what the account is already allowed to run. It cannot grant
31 access to a repository.
32 - `--dir` chooses where checkouts and caches are kept.
33 - `--jobs` is how many jobs this machine runs at once. Each gets its own container;
34 see [Running several jobs at once](#running-several-jobs-at-once).
35 - `--once` leases one job and exits, which is useful for a runner that is
36 scheduled per job.
37
38 ## Before it takes a job
39
40 The runtime is probed once at startup: the runner runs `<runtime> info` and refuses
41 to serve if it fails, before it connects and before anything is leased. A runtime
42 whose binary is installed but which cannot create a container — a missing OCI
43 runtime, a run root it cannot write, a storage driver the kernel will not load — is
44 the machine's problem, and a runner that took a job in that state would spend an
45 attempt and put the machine's failure on a commit that never ran a step.
21 `--label` advertises machine labels; a job must find every label in its
22 `runs-on`. `--repos` narrows the repositories the account may already serve and
23 cannot grant access. `--dir` selects checkout and cache storage, and `--once`
24 exits after the selected jobs finish.
46 25
47 The message repeats the runtime's own last line:
26 At startup, the runner executes `<runtime> info` and refuses to serve if the
27 runtime cannot run containers. This prevents a broken machine from consuming a
28 job attempt before the first step. The probe does not pull an image and runs
29 again only when the runner restarts.
48 30
49 ```
50 vole runner: cannot run a container with podman: Error: default OCI runtime "crun" not found: invalid argument
51 ```
31 The [CLI reference](cli.md#runner) lists every runtime, resource, cache, and host
32 key option and its default.
52 33
53 The probe is one query and pulls no image. It runs once: a runtime that breaks while
54 the runner is serving fails the job it was building, and restarting the runner probes
55 again. As a system service the unit exits on this error, so `Restart=on-failure`
56 retries it and `journalctl -u vole-runner` carries the message. `vole workflow run`
57 makes the same check before a local run.
58
59 ## Running several jobs at once
34 ## The runner's account
60 35
61 A build is usually one step waiting on one thing at a time, so most of a big machine
62 sits idle behind it. `--jobs` puts more jobs on the one machine:
36 The SSH account behind a runner is its identity in the allowlist, logs, and run
37 records. Create a bot and trust it per repository:
63 38
64 39 ```sh
65 vole runner --remote ssh://git@host:2222 --container-runtime podman --jobs 4
40 vole admin account create ci-runner-1 --bot --key ci-runner-1.pub
41 vole admin acl runners add demo ci-runner-1
42 vole admin acl set-role demo ci-runner-1 read
66 43 ```
67 44
68 Each job slot is a session of its own, so the instance hands work to each one
69 independently and the runners page shows four rows rather than one. The slots share
70 the machine: one cache, one set of saved checkouts, one set of images. What they do
71 not share is a container.
72
73 Two things need sizing for it:
74
75 - **The container limits are per job.** `--container-memory`, `--container-cpus` and
76 `--container-pids` apply to each container, so a machine running four jobs needs
77 four times what they allow. On the instance, `max_jobs_per_repo` is what stops one
78 repository's burst from claiming every slot (see
79 [Configuration](configuration.md)).
80 - **A job's cache is shared with the same repository's other jobs.** Two jobs of the
81 same repository, trust and image get the same `/cache`, which is what lets them
82 reuse each other's downloads. The tools in the image are what make that safe: `go`,
83 `cargo` and `npm` all lock their own caches. A job that empties `/cache` or keeps
84 state there between runs is competing with its own siblings, so give it a path of
85 its own or its own runner.
86
87 An idle slot holds one open connection while it waits for work, so a machine with
88 `--jobs 8` uses eight of the instance's SSH connections (`ssh_max_connections`).
89 Losing a connection costs that slot its job — the job is requeued when its lease
90 expires — and the slot reconnects rather than stopping the rest.
91
92 With `--once`, `--jobs 4` starts up to four jobs, finishes them, and exits, which is
93 the shape a scheduler that starts a container per job wants.
45 The allowlist authorizes its results. The `read` grant lets it clone a private
46 repository without giving it write access; a public repository does not need
47 that explicit grant. Admins are implicitly trusted reporters, but bots cannot be
48 instance admins, preventing a runner key from bypassing repository allowlists.
94 49
95 ## Stopping a runner
50 Keep one long-lived key per runner machine, readable only by its service user.
51 Remove the key or retire the account to revoke the machine. This key belongs to
52 the runner process. A job using `acts-as:` receives a separate per-run credential
53 that cannot lease work.
96 54
97 A runner that is asked to stop — `systemctl stop`, Ctrl-C, a `SIGTERM` — stops
98 taking work and lets the jobs it already has finish and report. That is the
99 difference between a build that is nearly done being published and being thrown
100 away, and it means the run is not left unclaimed until its lease expires. A second
101 signal ends the process at once.
55 A runner can read every secret declared by its jobs. The allowlist therefore
56 trusts both the machine and the people controlling it, not only its container
57 runtime.
58
59 ## Host key verification
102 60
103 Under systemd the packaged unit allows 60 seconds for that
104 (`TimeoutStopSec`), so a job that runs longer than that is killed anyway. If builds
105 on a machine take longer and you would rather wait for them, raise it:
61 The runner verifies the instance against `known_hosts` and rejects unknown or
62 changed host keys. Pin the host out of band before starting it:
106 63
107 64 ```sh
108 sudo systemctl edit vole-runner # [Service] / TimeoutStopSec=30min
65 ssh-keyscan -p 2222 host >> ~/.ssh/known_hosts
66 vole runner --remote ssh://git@host:2222 --known-hosts ~/.ssh/known_hosts
109 67 ```
110 68
111 ## The runner's account
69 `--known-hosts` selects another file. `--insecure-host-key` accepts any host and
70 is only for throwaway tests. `VOLE_KNOWN_HOSTS` and `VOLE_INSECURE_HOST_KEY`
71 apply the corresponding policy to other Vole remote commands too.
112 72
113 A runner connects as an account, and that account is the runner's identity: it is
114 what the repository's runner allowlist names, what the audit log records, and what
115 the server checks before it hands over a job. For a machine nobody signs in to,
116 make the account a bot:
73 The runner applies its host-key policy to both the control channel and Git
74 commands. A caller-provided `GIT_SSH_COMMAND` cannot disable verification because
75 the runner's own SSH options take precedence.
117 76
118 ```sh
119 vole admin account create ci-runner-1 --bot --key ci-runner-1.pub
120 vole admin acl runners add demo ci-runner-1
121 vole admin acl set-role demo ci-runner-1 read # private repositories only
122 ```
77 ## Running several jobs at once
123 78
124 From another machine, name the instance; the key file is read where the command
125 runs:
79 `--jobs <n>` creates independent job slots:
126 80
127 81 ```sh
128 vole admin --remote ssh://git@host:2222 account create ci-runner-1 --bot --key ci-runner-1.pub
82 vole runner --remote ssh://git@host:2222 --container-runtime podman --jobs 4
129 83 ```
130 84
131 A bot has no browser sign-in, so its key cannot be turned into a web session, and
132 it cannot be an instance admin. That second part matters for a runner: admins
133 count as trusted reporters even when a repository's allowlist does not name them,
134 so an admin account would make every result count and quietly bypass the list. A
135 named runner needs no repository role for its result to count — the allowlist is
136 that decision — but the build still has to clone the code, and a private
137 repository grants no read role by default. The `set-role ... read` line covers the
138 clone without giving the machine write access.
139
140 The `--key` is long-lived: it authenticates the runner process for as long as the
141 account is active. It is not the credential a job uses. A workflow job that names
142 a bot with `acts-as:` still gets a key minted for that run, scoped to the repository
143 and the run, and gone when the run ends; that key cannot lease work. Keep one key
144 per runner machine, readable only by the runner user, so a host you stop trusting
145 is revoked by removing that key or retiring the account.
85 Each slot has its own SSH session and appears separately on the Admin page. The
86 slots share saved checkouts, images, and applicable cache namespaces, but not job
87 containers or working trees.
146 88
147 ## Host key verification
89 Size the host for `n` times the per-container memory, CPU, PID, and tmpfs limits.
90 Each idle slot also consumes an SSH connection. Losing one connection requeues
91 that slot's job after its lease expires while the other slots reconnect
92 independently.
93
94 With `--once --jobs 4`, the runner starts up to four jobs, waits for them, and
95 exits. Jobs of the same repository, trust namespace, and image share `/cache`;
96 use toolchains that tolerate concurrent cache access or separate stateful jobs.
148 97
149 A runner executes repository code, so the instance it trusts is a security
150 boundary: a host that can answer in its place can send it any job. The SSH host
151 key is verified against your known_hosts, and an unknown or changed host is
152 refused. Populate the file once, out of band:
98 ## Stopping a runner
99
100 The first `SIGTERM` or Ctrl-C stops new leases and lets active jobs finish and
101 report. A second signal terminates the process immediately. The packaged systemd
102 unit waits 60 seconds by default:
153 103
154 104 ```sh
155 ssh-keyscan -p 2222 git@host >> ~/.ssh/known_hosts
156 vole runner --remote ssh://git@host:2222 --known-hosts ~/.ssh/vole_known_hosts
105 sudo systemctl edit vole-runner
157 106 ```
158 107
159 - `--known-hosts <path>` checks against that file instead of the default
160 `~/.ssh/known_hosts`.
161 - `--insecure-host-key` turns verification off and accepts any host that answers.
162 It exists for tests and throwaway instances; a real runner should not use it.
163 - `VOLE_KNOWN_HOSTS` and `VOLE_INSECURE_HOST_KEY` do the same for every command,
164 including `vole attach`, `vole admin --remote`, and the CLI verbs.
108 Set a longer `[Service]` `TimeoutStopSec` when jobs should outlive that window.
109 Without a clean report, the job becomes eligible for another attempt after its
110 lease expires.
165 111
166 The policy covers git's own ssh calls as well as the runner's control channel, so
167 a clone, a fetch, a release push and the job stream all verify the same host. An
168 environment variable cannot loosen it: an explicit
169 `GIT_SSH_COMMAND=... StrictHostKeyChecking=no` is overridden by the runner's own
170 options, which come first.
112 ## How a job runs
171 113
172 ## Images and image builds
114 The runner creates one job container and one container per declared service. It
115 removes them and their private network afterward. The runner process, its SSH
116 key, trusted saved checkout, and result channel remain on the host.
173 117
174 Every job names its image in the workflow. A registry reference is used as
175 written; an `image-file` definition is built locally first. The definition fields
176 are described in the [Image reference](reference/image-reference.md).
177
178 For a custom definition, the runner receives the pinned definition text and its
179 digest from the queue, so it cannot build a definition that changed after the job
180 was queued. It renders the definition to a Dockerfile, builds it with the
181 configured OCI runtime — so a rootless Podman runner builds rootless — and tags
182 the result by the definition digest. A later job with the same definition reuses
183 that tag.
184
185 With `--jobs`, jobs that name the same definition build it once: a job whose image
186 another job is already building waits for that build, saying so at the top of its
187 log, and keeps its lease alive while it waits. If the build fails, the jobs waiting
188 on it fail with the same reason.
189
190 The image build uses the runtime's own default network (bridge), because the base
191 image and any `run:` commands need to fetch packages. If builds should have no
192 network, preload the base image and set the runtime's default network to none on
193 that host. The job's own network request applies to the job container, not to the
194 build.
195
196 An image definition is code. Its build runs on the runner through the OCI
197 builder, so approving a contributor tip that changes a definition also approves
198 that build. Prefer rootless Podman, and pin the base image in `from:` by digest
199 (`image@sha256:...`) when you need the build itself to be reproducible.
200
201 ## What a job may name
202
203 The server validates a workflow when it is pushed, and the runner validates the
204 job again before it acts on it, because the runner is the party that turns the
205 payload into paths, container arguments and scripts. A job whose repository,
206 commit, ref, branch, tag, pages path, artifact pattern, step or environment does
207 not have the shape the instance documents is refused, and the runner stops rather
208 than running it. In particular a path that climbs out of the checkout (`..`), an
209 absolute path, a `:` or NUL in a value used to build a container argument, and a
210 commit id that is not a commit id are all refused at the runner, not only at the
211 server.
118 Each job receives a fresh clone of the saved repository, so Git hooks and working
119 tree changes do not leak into another job. The container has:
212 120
213 ## What a job may consume
121 - no host mounts other than the job tree, cache, and pinned event directory;
122 - no Docker socket, SSH agent, host environment, or added capabilities;
123 - `no-new-privileges` enabled;
124 - a writable, executable tmpfs at `/tmp`;
125 - the runner user's numeric uid and gid by default;
126 - a writable container layer that is discarded afterward.
214 127
215 A job runs untrusted build code, and everything it produces is stored by the
216 instance or kept on the runner, so each of those channels has a bound:
217
218 - **Logs.** One attempt's log is capped at 32 MiB. Past that the runner keeps the
219 first 32 MiB and appends a line saying it was truncated, so a build that loops
220 printing cannot fill the runner's disk or the instance's log directory. The log
221 is written straight to a file on the runner and streamed to the server in chunks
222 while the job runs; it is not held in memory.
223 - **Artifacts.** A workflow declares at most 32 patterns, and a run may publish at
224 most 256 files totalling 4 GiB. The expanded set is checked before anything is
225 uploaded; a pattern that matches a directory tree is the usual way to hit this.
226 - **Cache.** `--cache-size` (5 GiB by default) caps the cache root, enforced by
227 evicting whole namespaces, and a namespace a job has mounted is left for a later
228 pass. Each repository gets its own namespace, and each
229 contributor account gets its own inside a repository, so one contributor's
230 branch cannot seed the cache another contributor's branch builds from. A
231 protected branch never shares a cache with a contributor branch. The saved
232 checkouts jobs clone from are bounded separately; see
233 [Saved checkouts](#saved-checkouts).
234 - **Container.** `--container-memory`, `--container-cpus`, `--container-pids` and
235 `--container-tmpfs` are the runtime's own limits, per container, so `--jobs`
236 multiplies them. `--container-pids` (2048) and `--container-tmpfs` (1G) have
237 defaults and cannot be removed: `/tmp` is a tmpfs, so its size is memory, and a job
238 that can fork without a bound is a fork bomb away from taking the machine. Set
239 `--container-memory` — the runtime's default is the whole machine — and see the
240 unit's `MemoryMax` backstop below. `--container-network` is what this machine can
241 offer — `none` (the default) or `bridge` — and a job's own `network:` decides what
242 it gets, so a bridge runner can still run a job that asks for none. See
243 [Network](#network). The runtime's storage driver, not Vole, is what bounds the
244 container's writable layer, so size it on the host.
245 - **Disk.** A job's tree is a host directory the runtime cannot quota, so the runner
246 keeps `--disk-reserve` (2G) free under `--dir` and stops a job that takes the
247 filesystem below it while the job is running. It is one `statfs` per second, and the
248 log says what was left and what the reserve is. That is the promise — the runner
249 notices — rather than a hard bound; for one of those, put `--dir` on its own
250 filesystem and size that. The unit's `MemoryMax` is the same idea for RAM.
128 An image needs `/bin/sh` and POSIX `sleep`. Tools that look up a user name, such
129 as OpenSSH, also need a passwd entry for the numeric uid or an explicit
130 `--container-user`. Running the job as root lets it modify root-owned image
131 files, so the runner warns at startup when its own user is root.
251 132
252 ## How a job runs
253
254 One container is created for the job, plus one for each service the job declares;
255 all are removed afterward. The workflow's steps run inside the job container, but
256 the runner process stays on the host: the SSH key, the trusted Git cache, and the
257 finish channel are never exposed to the job. Each job gets a fresh
258 clone of the runner's saved copy of the repository (see
259 [Saved checkouts](#saved-checkouts)), so a job cannot leave a Git hook or a modified
260 checkout behind for the next one.
261
262 A service is a second container on a private user-defined network created for the
263 attempt. It gets the job's user, capabilities, and resource limits, but no job tree,
264 no cache, and no secrets. Its declared name is the network alias a step connects to.
265 The runner starts services after the image is ready and before the first step,
266 fails the job if one is not running, and adds the end of their output to a failed
267 attempt's log. Services, the job, and the network are removed together; a killed
268 runner finds its leftovers by label on the next start.
269
270 Container defaults are intentionally closed:
271
272 - no network unless the job asks for one with `network: bridge`, or the runner was
273 started with it and the job says nothing;
274 - no capabilities, `no-new-privileges`, and no host mounts except the job tree;
275 - no Docker socket, SSH agent, or host environment;
276 - `/tmp` is a writable, executable tmpfs (compilers write their output there and
277 run it);
278 - the steps run as the runner user's `uid:gid` by default.
279
280 A run started by a non-push trigger also gets a directory mounted at `/run/vole`
281 with the pinned event as `event.json`, plus `VOLE_EVENT`, `VOLE_EVENT_ACTION`, and
282 `VOLE_EVENT_PATH`. The file is data for a step to read; a workflow cannot replace
283 those variables through `env:`. See [Workflow reference § Event data available to steps](reference/workflow-reference.md#event-data-available-to-steps).
284
285 A job that declares `secrets:` gets the same directory, with a `secrets.env` beside
286 the event. The runner writes one `export NAME='value'` line per secret, quotes it so
287 a value keeps its line breaks, and sources the file before each step, so a secret is
288 a variable in the step's shell and never an argument to the runtime. Values are at
289 most 128 KiB each, are delivered only for the job that declared them, and a name the
290 repository does not have leaves its variable unset with one line in the log. The
291 value arrives over the SSH channel with the lease, is written `0600` in the job's
292 directory, and is removed with it.
293
294 Every delivered value is replaced with `***` in the log as the log is written, so
295 the file the server stores never holds one, and a value split across two writes is
296 still caught. The runner's own error text goes through the same mask. It is best
297 effort: a re-encoded value (base64, hex, a URL escape) no longer matches, and a
298 value shorter than 4 bytes is left alone because masking every occurrence of it
299 would rewrite the log. A step that writes a secret into an artifact publishes it —
300 the mask covers the log, not the files a job chooses to upload.
301
302 **A runner can read every secret a repository's jobs declare.** That is what running
303 the job means: the values arrive on the machine. The runner allowlist is the control
304 that decides whose machine it is, not the container. See
305 [Accounts and access § Roles](accounts-and-access.md#roles).
306
307 The container's own filesystem is writable, and thrown away with the container:
308 nothing a job writes there survives the run, and an unprivileged uid cannot write
309 the image's root-owned paths anyway. What protects the machine is the mount set —
310 the job tree is the only host path a job can see — not the writability of the
311 container's own layer.
312
313 Because the uid is the runner's own, an image whose tools call `getpwuid` — OpenSSH
314 is the common case — needs a passwd entry for that uid, or `ssh` and `ssh-keygen`
315 exit with `No user exists for uid N`. Define one in the image definition, or pass
316 `--container-user` naming a user the image already has. This is the same container
317 `vole workflow run` starts, so an image that fails here fails there too.
318
319 The uid decides how immutable the image is. An ordinary user cannot write the
320 image's root-owned files, so a job's view of its own toolchain is the one that was
321 built. If the runner runs as root (or `--container-user` says so), the job can
322 rewrite its own image, and the runner prints a warning at startup: run the runner
323 as an unprivileged user.
324
325 Use `--container-runtime` to choose `docker`, `podman`, or `nerdctl`. The runner
326 user must be able to talk to that runtime; rootless Podman is preferred. Do not
327 mount the host's Docker socket into a job; that would undo the isolation.
328
329 `--container-pull` controls whether an image is pulled (`missing`, `always`, or
330 `never`). `--container-user`, `--container-userns`, `--container-memory`,
331 `--container-cpus`, and `--container-pids` override the user, namespace mode, and
332 resource limits. Rootless Podman uses `keep-id` by default so the numeric user can
333 write the bind-mounted job tree; for rootless Docker, choose a user that matches
334 the runtime's mapping (container root is the runner user) or use a runtime with
335 `keep-id`.
336
337 The run record names the image, the definition digest when there is one, and the
338 runtime, so the run page says what actually executed.
133 Non-push events mount `event.json` under `/run/vole` and set `VOLE_EVENT`,
134 `VOLE_EVENT_ACTION`, and `VOLE_EVENT_PATH`. Jobs with secrets receive a
135 mode-`0600` `secrets.env` beside it. The runner sources that file before each
136 step, keeping values out of container arguments. It removes the directory with
137 the job.
339 138
340 139 ## Network
341 140
342 `--container-network` says what this machine can give a job: `none` (the default) or
343 `bridge`. It is a capability, not a setting for every job. The job's `network:`
344 decides what the container gets, and the runner applies it:
141 `--container-network` states the most networking this runner offers: `none` by
142 default or `bridge`. The job's `network:` field selects what the container gets:
345 143
346 | Job says | This runner says `bridge` | This runner says `none` |
144 | Job request | Bridge-capable runner | None-only runner |
347 145 |---|---|---|
348 | nothing | bridge | none |
146 | Unset | bridge | none |
349 147 | `none` | none | none |
350 | `bridge` | bridge | the runner never receives the job |
351
352 So a machine with a network is not a machine that hands it to every build. A job
353 that asks for none is isolated on either kind of runner, and a job that asks for
354 bridge waits in the queue for a runner that advertises one instead of running
355 without the network it needs. A bridge job that declares services gets a
356 user-defined network for that attempt rather than the runtime's default bridge; the
357 job and its services are its only members, so the service names resolve there and
358 nowhere else. The runner advertises this with every lease, the same
359 way it advertises `--label`, and the job's request is pinned with the run when it is
360 queued.
361
362 A runner can be started with `--container-network bridge` and nothing breaks; that
363 is a policy choice for a machine whose owner trusts everything it builds. What no
364 runner can do is take the choice away from the job, and this is why. A job runs code
365 from the repository, including a contributor branch a maintainer approved for
366 reasons that had nothing to do with network access. With a network, that code
367 reaches whatever the machine can reach: the instance handing out the work, since a
368 deployed instance listens beyond loopback, the other services on that host, and
369 anything on the internet to send out what the job can read. With no network the only
370 things it can touch are the job tree and the container itself, both of which are
371 discarded, so a job that declares a secret and does not need to reach anything
372 cannot send it anywhere. No network also keeps a build honest: a job that fetches
373 its dependencies at run time builds whatever the remote serves that day, while a
374 closed job builds what its image carries, which is the image the run pinned by
375 digest.
148 | `bridge` | bridge | job is not leased |
376 149
377 ## Caching
150 A bridge request waits for a capable runner rather than silently running without
151 its required network. A `none` request remains isolated on either runner.
378 152
379 A job starts with an empty container, so without help every run downloads its
380 dependencies and compiles them again: in this repository that is about 23 seconds
381 of `go build`/`go vet` that a warm cache turns into one. The runner keeps a directory
382 per job and mounts it at `/cache`.
153 Services require bridge networking and join a private user-defined network with
154 the job. Their declared names resolve only inside that attempt. Services receive
155 the job user and resource limits, but no checkout, cache, or secrets.
383 156
384 It mounts the directory and sets **no** variable that points at it. Which tool uses
385 `/cache`, and therefore whether a job shares state with the job before it, is the
386 repository's decision. A runner that guessed would be making a claim about a
387 toolchain it does not test, and a job that wants no shared state would have to
388 defend against a default it never asked for.
157 Networked repository code can reach anything the runner can reach, including the
158 instance and internal services. Review both workflow changes and image builds
159 before allowing contributor CI. A no-network job cannot exfiltrate over the
160 network, but it can still publish declared artifacts or sites.
389 161
390 Opt in where the environment already lives — the image definition:
162 ## Images and image builds
391 163
392 ```yaml
393 # .vole/images/verify.yaml
394 version: 1
395 from: golang:1.27-bookworm
396 env:
397 GOMODCACHE: "/cache/go-mod"
398 GOCACHE: "/cache/go-build"
399 ```
164 A registry `image:` is used as named. For `image-file:`, the runner receives the
165 pinned definition and digest, renders a Dockerfile, builds with the configured
166 runtime, and tags the result by digest. Later jobs reuse that tag.
167
168 Concurrent jobs needing the same definition share one build. Waiting jobs keep
169 their leases alive, and all waiting jobs receive the same build error if it
170 fails.
400 171
401 or per job, which works for a registry image too:
172 The image build uses the runtime's default network because it may fetch the base
173 image and packages; the job's `network:` does not constrain the build. To build
174 without network access, preload dependencies and configure the runtime host
175 accordingly.
176
177 Image definitions execute code on the runner. Pin base images by digest and
178 review contributor changes to `.vole/images/` before allowing CI. See the
179 [image reference](reference/image-reference.md).
180
181 ## What a job may consume
182
183 | Channel | Bound and behavior |
184 |---|---|
185 | Logs | 32 MiB per attempt; the runner keeps the beginning and appends a truncation notice |
186 | Artifacts | At most 32 workflow patterns, 256 files, and 4 GiB per run, checked before upload |
187 | Job cache | `--cache-size` evicts whole least-recently-written namespaces; active namespaces are deferred |
188 | Containers | Memory, CPU, PID, and tmpfs flags apply per container, so parallel jobs multiply them |
189 | Checkout disk | `--disk-reserve` checks free space once per second and stops a job below the reserve |
190 | Images | The OCI runtime owns image storage and writable-layer quotas |
191
192 PID and tmpfs limits have non-removable defaults because `/tmp` consumes memory
193 and unbounded process creation can exhaust the host. Set an explicit memory
194 limit; otherwise the runtime may allow the whole machine. The disk reserve is a
195 detected threshold, not a hard filesystem quota. Put `--dir` on a dedicated
196 filesystem when a hard boundary is required.
197
198 The runner revalidates repository, commit, ref, path, artifact, environment, and
199 step fields before acting on a lease. Absolute paths, traversal, malformed commit
200 ids, and values unsafe for container arguments are rejected even if a server-side
201 check was bypassed.
202
203 ## Caching
204
205 The runner mounts a job cache at `/cache` but sets no tool-specific variables.
206 Opt in through the image or job environment:
402 207
403 208 ```yaml
404 209 jobs:
@@ -411,148 +216,106 @@ jobs:
411 216 - run: go test ./...
412 217 ```
413 218
414 The variables for the common toolchains are the tools' own; there is nothing
415 Vole-specific to learn. `GOMODCACHE`/`GOCACHE` for Go, `CARGO_HOME`,
416 `npm_config_cache`, `PIP_CACHE_DIR`, `MAVEN_ARGS`/`-Dmaven.repo.local`,
417 `GRADLE_USER_HOME`, `NUGET_PACKAGES`, `PUB_CACHE`, `COMPOSER_CACHE_DIR`,
418 `CCACHE_DIR`, and `XDG_CACHE_HOME` for anything that follows the XDG convention.
419 An image that sets none of them gets an empty directory and no behaviour change.
420
421 The cache lives under `--dir/cache`, keyed by repository, trust, and image:
422 `<dir>/cache/<repo>/<direct|contrib>/<image>`. The parts matter. A cache is shared
423 mutable state: a repository never sees another's, and a contributor branch gets its
424 own namespace, so a branch nobody has vouched for cannot seed the cache a protected
425 branch builds into. A combined result derived from a contributor branch belongs to
426 that contributor's namespace for the same reason. The image is part of the key so a
427 cache built with one toolchain is not consumed by another.
428
429 Namespaces are evicted whole and least-recently-written first, so a cache is never
430 left half-deleted — a Go module cache missing one file is a checksum error deep in
431 a build rather than a download. A job holds its namespace for as long as it runs,
432 and eviction leaves a held namespace for a later pass, so two runners sharing one
433 `--dir` never delete each other's tree in the middle of a build. `--cache-size` caps
434 the total (5G by default), and the runner enforces it at startup and then on its own
435 timer: a cache that is in use when the cap is reached comes down when the job
436 finishes, not under it. `--no-cache` keeps nothing between jobs: the directory is
437 still mounted — an image that points at `/cache` has to work either way — but it is
438 emptied after every job, while that job still holds it, so a shared `--dir` is not
439 emptied under somebody else's build.
219 Common variables include `GOCACHE` and `GOMODCACHE` for Go, `CARGO_HOME`,
220 `npm_config_cache`, `PIP_CACHE_DIR`, `GRADLE_USER_HOME`, `NUGET_PACKAGES`,
221 `CCACHE_DIR`, and `XDG_CACHE_HOME`.
440 222
441 ## Saved checkouts
223 Cache paths are keyed by repository, trust, and image:
442 224
443 The first job for a repository downloads it once, and the runner keeps that copy
444 under `--dir`. A later job clones from the copy and fetches only the commits it does
445 not have — usually none at all — so history crosses the network once instead of once
446 per run. The copy is never mounted into a job: the workflow gets a clone with its own
447 `.git`, which is why a hook it writes still dies with the job.
225 ```text
226 <dir>/cache/<repo>/<direct|contrib>/<image>
227 ```
448 228
449 Two things keep the copies from filling the disk:
229 Each contributor has a separate namespace inside a repository. Protected branches
230 never share with contributor branches, and a combined result derived from a
231 contributor retains that contributor's namespace. Image identity prevents one
232 toolchain from consuming another's cache.
450 233
451 - **Repacking.** A copy that is most of the cap is repacked. That drops history no
452 branch or tag can reach any more: commits from a force-push or a deleted branch,
453 and a commit a job once pinned by id. Nothing a job can still ask for is touched,
454 so the next job for the same revision is still a local copy with no download.
455 - **Deleting.** When the cap is still reached, the copy nobody has built from in the
456 longest time is deleted, whole. The next job for that repository downloads it
457 again, which is why it is the last resort rather than the first.
234 Eviction removes whole namespaces rather than individual files. Active namespaces
235 are deferred until their jobs finish. `--no-cache` still mounts `/cache` but
236 empties that job's namespace afterward.
458 237
459 `--git-cache-size` caps all saved checkouts together (10G by default; `0` keeps
460 every one). A copy another runner process is using is passed over, and the
461 repository this runner is about to build is never the one deleted.
238 ## Saved checkouts
239
240 The runner keeps one saved clone per repository under `--dir`. A job clones from
241 that copy and fetches only missing commits. The saved clone itself is never
242 mounted into the job.
243
244 `--git-cache-size` caps saved checkouts. Near the cap, Vole repacks copies and
245 removes unreachable objects; when more space is needed, it deletes the least
246 recently used inactive copy. It never deletes a copy in use or the repository
247 about to run. A value of `0` disables the size cap.
462 248
463 249 ## Who can run jobs and report results
464 250
465 A job runs repository code, so Vole uses a runner allowlist for both taking a job
466 and reporting its result:
251 Manage the trusted-runner allowlist with:
467 252
468 253 ```sh
469 vole admin acl runners list demo # show the list
470 vole admin acl runners set demo ci-runner-1 # replace the list
471 vole admin acl runners add demo ci-runner-2 # add one account
472 vole admin acl runners remove demo ci-runner-1 # remove one account
473 vole admin acl runners clear demo # back to admins only
254 vole admin acl runners list demo
255 vole admin acl runners set demo ci-runner-1
256 vole admin acl runners add demo ci-runner-2
257 vole admin acl runners remove demo ci-runner-1
258 vole admin acl runners clear demo
474 259 ```
475 260
476 Admins always count. For everyone else, a maintainer running CI on their laptop does
477 not turn a required check green. The result is still recorded, and the run page
478 says whether it counts.
261 Admins always count. Results from other accounts are recorded but do not satisfy
262 required checks unless the account is allowlisted and active. The run page shows
263 whether a result counts.
479 264
480 While a job runs, the runner streams its log to the server in chunks over the same
481 SSH channel that leased it. The server writes one file under `data/logs/` and the
482 run page can open it before the job finishes. When the job ends, the runner sends
483 the attempt's record with its finish message; Vole checks that the record names the
484 account holding the lease, that it describes the job the queue handed out, and that
485 every artifact pointer exists in the store. It then stores the attempt and the run's
486 result in `data/runs.db` in one transaction. A tagged build that publishes release
487 artifacts also pushes those pointers to the `vole` branch after the record is
488 stored.
489
490 The runner did the work, so the runner reports the result. The SSH connection
491 identifies the runner, and `data/audit.log` records the decision.
265 The runner streams logs and finishes the attempt over the authenticated channel
266 that leased it. The server checks that the account holds the lease, the record
267 matches the assigned job, and uploaded artifact pointers exist. It then stores
268 the attempt and result in `data/runs.db` in one transaction. Tagged release
269 pointers are written to the `vole` branch separately.
492 270
493 271 ## Logs
494 272
495 The runner streams the log while the steps run. The server appends each chunk to
496 the attempt's file, and the run page serves that file directly with range requests,
497 so it does not read a large log into memory. The file is complete when the attempt's
498 record is stored.
499
500 The stored attempt also names each step's byte range in that one log, so the run
501 page can show a step's output without downloading the image build and other steps.
502 Step timing is recorded beside the range.
273 Each attempt has one log file under `data/logs/`. The server appends streamed
274 chunks and supports range requests, so readers do not load the whole file into
275 memory. Stored step ranges let the web page and CLI select one step.
503 276
504 277 ```text
505 /<repo>/runs/<id>/log # latest attempt
506 /<repo>/runs/<id>/log?attempt=N # a particular retry
507 /<repo>/runs/<id>/log?step=N # one step inside that attempt
278 /<repo>/runs/<id>/log
279 /<repo>/runs/<id>/log?attempt=N
280 /<repo>/runs/<id>/log?attempt=N&step=N
508 281 ```
509 282
510 The same bytes are one command away from a terminal:
511
512 283 ```sh
513 vole run logs <id> # the default attempt, whole
514 vole run logs <id> --attempt 2 --step 1 # step 1 of the second attempt
515 vole run show <id> # status, steps, attempts, artifacts
516 vole run list --state failed --limit 5 # find the run to open
284 vole run logs <id>
285 vole run logs <id> --attempt 2 --step 1
286 vole run show <id>
287 vole run list --state failed --limit 5
517 288 ```
518 289
519 `vole run show` and `vole run list` read the queue; `vole run logs` writes the log to
520 stdout and sends a refusal to stderr, so a redirect gets the log or an empty file.
521 Reading is the repository's read capability. `vole change show` lists the runs for a
522 change's head and for its combined result, which is where the id usually comes from
523 when a check is red.
290 `run logs` writes log bytes to stdout and errors to stderr, so redirection does
291 not mix the two. An attempt whose runner disappeared may have no complete log.
524 292
525 If a runner is killed, its attempt has no log. A record written before step
526 timing existed still opens; it simply has no step ranges to show.
293 Delivered secrets are replaced with `***` while the log is written, including
294 values split across writes and runner error text. Masking is best effort: it does
295 not detect transformed values, values shorter than four bytes, or secrets copied
296 into artifacts and sites.
527 297
528 298 ## Scheduling and the queue
529 299
530 All runners share one pool. An idle runner waits for work instead of asking
531 repeatedly, and Vole gives the next job to the repository with the least work in
532 progress. Set `max_jobs_per_repo` when you need a hard limit per repository.
533
534 The instance-admin **Admin** page at `/-/admin?tab=runners` shows who is connected,
535 what each runner is building, and how much work is queued. The old `/-/runners` URL
536 redirects there.
537
538 How the queue behaves:
539
540 - Finished runs are stored in `data/runs.db`, not on the `vole` branch. A clone or
541 backup of the repository does not carry CI history, so back up `runs.db`.
542 - A push normally reaches the queue in under a second. Every 30 seconds Vole also
543 compares each branch and tag with the last tip it queued, so a missed
544 notification still produces a run.
545 - Pushing again cancels queued runs for the commit it replaced. It never stops a run
546 that is already in progress. A maintainer can stop one from its page or with
547 `vole run cancel <id>`: the queue records the request, the runner sees it on its next
548 heartbeat, stops the container, and reports the partial attempt. The run stays
549 `canceled` rather than becoming a failure, and its page says who asked.
550 - If a runner disappears, its job is requeued. After five attempts the job fails
551 instead of cycling forever.
552 - A job whose attempt stops before its first step — the image build, the container,
553 the network — is recorded as `error` (the page says **could not run**) with the
554 runner's reason, not as a failure of the commit. A required check waits on it
555 rather than going red; rerunning the job clears it.
556 - Deleting `data/runs.db` loses CI history and attempts that were in flight. Current
557 branch and tag tips are queued again from Git, but only a backup can restore the
558 finished runs.
300 All runners share one queue. Idle runners wait for work, and the instance favors
301 the repository with the least work in progress. `max_jobs_per_repo` adds a hard
302 per-repository concurrency cap. The Admin page's **Runners** tab shows connected
303 slots, active work, and queued jobs.
304
305 - Run records live in `data/runs.db`, not the repository's metadata branch.
306 - A push normally queues work immediately; a 30-second reconciliation compares
307 refs with queued tips to recover missed notifications.
308 - A replacement push cancels queued runs for the old commit but does not stop an
309 active run.
310 - `vole run cancel <id>` asks the runner to stop at its next heartbeat and records
311 who requested cancellation.
312 - A lost lease is requeued. After five attempts, the run fails instead of cycling.
313 - An attempt that stops before its first step has status `error` and appears as
314 **could not run**; a required check waits rather than treating the commit as
315 failed.
316 - Rerunning a finished run creates another attempt with the same pinned workflow,
317 image, and secrets.
318
319 Deleting `data/runs.db` loses CI history, queued work, in-flight attempts, and
320 contributor CI allow decisions. Current refs can be queued again from Git, but
321 only a backup restores finished history. Back up this database with the instance.