Files
nixos/pkgs/gitea-actions-vm-image/runner.service
JakeHillion e595c866a4
commit-validation / validate-single-commit (pull_request) Successful in 9s
buildbot/nix-eval Build done. (521 warnings)
buildbot/nix-build Build done.
buildbot/nix-effects Build done.
gitea-actions-vm: deliver runner credentials via cloud-init user-data
The per-VM runner credentials (.runner and config.yaml) were shipped as
loose files on a custom cidata disk: locally an ISO attached to QEMU,
and on GCP the same ISO wrapped in a tar.gz, uploaded to GCS, turned
into a per-VM custom image, and attached as a second hyperdisk padded
to its 4 GiB minimum — with matching per-VM image and GCS object
cleanup on teardown and in the orphan sweep.

The credentials now travel as ordinary #cloud-config user-data using
write_files, which places them in /var/lib/gitea-runner before the
runner unit starts. Locally the user-data rides the existing NoCloud
ISO; on GCP it is passed as instance metadata
(--metadata-from-file=user-data=...) and picked up by the native GCE
datasource, so the second disk and the per-VM GCS/image pipeline are
gone entirely. The in-VM runner.service no longer mounts the cidata
device, and the cloud image name is now keyed on the qcow2 content
hash passed in from Nix rather than parsed out of the GCE tarball
path.

Of the per-VM resource safety nets, only the instance-delete on a
failed `instances create` still has anything to clean, so launch_one
keeps that and drops the image/GCS handling. sweep_orphans stays as-is
(modulo its comment): new VMs no longer create per-VM cidata images or
GCS tarballs, but resources leaked before this switch still need
reaping.

Test plan:
- CI
- Built boron's toplevel locally (covers the rebuilt VM image, the
  launcher shellcheck, and the reconcile script's flake8 pass)
- After deploy: verify a local actions-vm runner picks up a job, and
  that a burst VM launches on GCP with user-data metadata and a single
  boot disk
2026-06-13 00:58:08 +01:00

39 lines
1.6 KiB
Desktop File

[Unit]
Description=Gitea Actions Runner (ephemeral)
# Wait for cloud-init's final stage so the datasource's network config has
# been applied and write_files has placed the runner credentials before
# act_runner tries to reach Gitea.
# WantedBy=cloud-init.target rather than multi-user.target — cloud-init.target
# is After=multi-user.target, so combining After=cloud-final with
# WantedBy=multi-user creates an ordering cycle.
After=cloud-final.service
Wants=cloud-final.service
# Written by cloud-init from the per-VM user-data (write_files); if it's
# missing the VM was booted without runner credentials, so stay down.
ConditionPathExists=/var/lib/gitea-runner/.runner
[Service]
Type=simple
User=runner
Group=runner
WorkingDirectory=/var/lib/gitea-runner
ExecStart=/usr/local/bin/gitea-runner daemon --config /var/lib/gitea-runner/config.yaml
ExecStopPost=+/sbin/poweroff -f
Restart=no
TimeoutStartSec=5min
# SIGTERM goes only to act_runner (the main process), not to its job's
# child processes — act_runner is expected to drain the current job on
# SIGTERM and exit when it's done. SIGKILL escalates to the whole cgroup
# after TimeoutStopSec as a safety net; the reconcile unit drops a /run
# drop-in raising this to infinity during rebuilds.
TimeoutStopSec=30min
KillMode=mixed
# Mirror runner output to /dev/console (ttyS0 here) so the host's
# `journalctl -fu gitea-actions-vm-N` shows live runner state — ttyS0 is
# bridged to the host unit's stdout via qemu's -serial mon:stdio.
StandardOutput=journal+console
StandardError=journal+console
[Install]
WantedBy=cloud-init.target