refactor: gitea runners
runner nix smoke / nix label and flake smoke (push) Failing after 1m22s
runner ubuntu smoke / ubuntu-latest label smoke (push) Successful in 0s

This commit is contained in:
2026-10-03 12:30:42 +00:00
parent e215c11b0b
commit be4ea774b2
14 changed files with 1463 additions and 626 deletions
+29 -13
View File
@@ -576,20 +576,36 @@ only, never to a lower-RAM server type. Current Hetzner public pricing for
Germany/Finland CCX53 is 0.8550 EUR/hour excluding IPv4, so one 480-minute
allocation reserves 6.84 EUR against the controller budget before VM creation.
These are maximum lifetimes. Failed, cancelled, skipped, and unbootstrapped jobs
still trigger immediate VM teardown; failed jobs retain pre-destroy diagnostics.
After a successful job, its bootstrapped VM stays running until next hourly
boundary measured from original VM creation, capped by profile TTL. Same-repo,
same-label queued work can atomically claim that idle VM. Reuse preserves
original Hetzner labels and runner name, creates no server, fetches no new
registration token, and makes no second budget reservation. Idle VMs are still
billed: controller deletes them at slot expiry and never relies on stopping a
server to avoid charges.
These are maximum lifetimes. Unbootstrapped or profile-invalid VMs trigger
immediate teardown; failed jobs retain pre-destroy diagnostics. A healthy,
bootstrapped terminal VM may stay running until the next hourly boundary
measured from original VM creation, capped by its original hard TTL.
Reuse retains runner host filesystem and registration identity. It is therefore
restricted to same repository and exact label inside this trusted-only pool;
allowed repositories must not run untrusted fork or pull-request code. A failed
or otherwise non-successful job is never reused.
Retention first enters a durable retirement state. The controller disables the
exact repository runner registration, deletes it, and confirms its absence
before clearing repository, label, and runner ownership into generic idle. A
queued job from any allowed repository can atomically claim generic idle only
when persisted server type, location, architecture, and image match one of the
job label's candidates. The VM then remains unschedulable while Hetzner rebuilds
its root disk from that clean image. Controller verifies rebuild action and
server identity, current image/profile, and current IP before fetching a fresh
destination-repository token and bootstrapping a new runner name. Old runner
registration and filesystem are never reused.
For every creation and reuse rebuild, the controller generates a unique SSH
host key, injects it through authenticated Hetzner `user_data`, and pins that
exact public key before sending a registration token. Shared image host keys
and trust-on-first-use are not used. Runner images must process Hetzner
cloud-init `write_files` during create and rebuild; verify this image gate before
dispatching jobs. If host-key injection fails, bootstrap remains fail-closed.
Reuse preserves original Hetzner VM creation time, hard TTL, and budget charge;
it creates no server and makes no second reservation. Provider or registration
uncertainty remains in a non-schedulable durable state, and unrecoverable rebuild
uncertainty destroys the VM. Idle VMs are still billed: controller deletes them
at slot expiry and never relies on stopping a server to avoid charges. Allowed
repositories remain trusted-only and must not run untrusted fork or pull-request
code.
Active and idle VMs are deleted at profile hard TTL without grace. Idle reuse is
allowed only when at least one configured reconcile interval remains before both