Rewrite on the layout of agentos
os / os (push) Failing after 29s

Start again from agentos: a read-only, verity-checked /usr with A/B
updates, and a TPM-encrypted btrfs root made at first boot that holds
/etc and /var. On top of that the runner: gitea-runner from gitea.com,
a path unit that starts it once registered, and a drain before update
reboots. Jobs run in plain Fedora on root's podman.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Job79andClaude Opus 5.5 committed 2026-11-22 15:59:36 +00:00
1 parent 0569bce676
commit 0733ff55f3
49 files changed
+492 -509

No files matched your search

@@ -1,33 +0,0 @@
# The runner's configuration (gitea-runner.service).
# Every option: `gitea-runner config generate`.
runner:
# Parallel jobs, asked at first boot (stored in /var/lib/gitea-runner/runner.env).
capacity: ${GITEA_RUNNER_CAPACITY}
# On stop (before an update reboot), take no new jobs and give running ones this long to finish.
shutdown_timeout: 30m
envs:
# podman in jobs: the job's own storage plus the shared base images (see volumes below).
CONTAINERS_STORAGE_CONF: /usr/lib/gitea-runner/job/storage.conf
labels:
# Our job image (mkosi.images/job), loaded from /usr at boot by gitea-runner-images.service.
- "linux:docker://localhost/git-runner-job:latest"
# Plain Fedora.
- "fedora:docker://quay.io/fedora/fedora:45"
container:
# Jobs build OS images, which needs root: they run privileged on root's podman.
privileged: true
# podman can't keep its storage, or build contexts, on the job's own overlay root.
options: --volume /var/lib/containers --volume /var/tmp
# Jobs run their own podman, never the runner's.
docker_host: "-"
volumes:
# Base images, pulled at boot by gitea-runner-images.service; podman in jobs uses them read-only.
- /var/lib/containers/base-images:/var/lib/base-images:ro
# podman storage settings for jobs (see the file).
- /usr/lib/gitea-runner/job:/usr/lib/gitea-runner/job:ro
# Images are pulled when missing: our job image never is, fedora once per boot.
force_pull: false
cache:
# Jobs reach the cache on the host through their bridge; the firewall allows this port.
host: host.containers.internal
port: 8088
@@ -1,22 +0,0 @@
# Firewall: drop all incoming traffic except replies, loopback, ICMP and DHCPv6.
# Loaded by nftables.service. Jobs live on podman bridges (podman*): they may reach the
# internet, DNS on their bridge, and the runner's cache server (config.yaml), nothing else here.
destroy table inet firewall
table inet firewall {
chain input {
type filter hook input priority filter; policy drop;
ct state established,related accept
ct state invalid drop
iif lo accept
meta l4proto { icmp, ipv6-icmp } accept
ip6 saddr fe80::/10 udp dport 546 accept
iifname "podman*" meta l4proto { tcp, udp } th dport 53 accept
iifname "podman*" tcp dport 8088 accept
}
chain forward {
type filter hook forward priority filter; policy drop;
ct state established,related accept
ct state invalid drop
iifname "podman*" accept
}
}
@@ -1,9 +0,0 @@
# podman storage in jobs (CONTAINERS_STORAGE_CONF). The job's own images go to the /var/lib/containers
# volume; the base images the host pulls at boot are shared read-only, so jobs don't download them.
[storage]
driver = "overlay"
graphroot = "/var/lib/containers/storage"
runroot = "/run/containers/storage"
[storage.options]
additionalimagestores = ["/var/lib/base-images"]
+10
View File
@@ -0,0 +1,10 @@
# 50-root.conf makes the root filesystem at first boot, in the free space after
# /usr, and grows it with the disk. It holds all state: /etc and /var.
#
# The key is in the TPM, sealed to the signed PCR 11 policy of our UKIs
# (SignExpectedPcr= in mkosi.conf).
[Partition]
Type=root
Format=btrfs
Encrypt=tpm2
FactoryReset=yes
-4
View File
@@ -1,4 +0,0 @@
# Grow the /var partition to fill the disk at boot (systemd-repart); x-systemd.growfs in /etc/fstab
# then grows its filesystem.
[Partition]
Type=var
@@ -1,31 +0,0 @@
# Kernel hardening, mostly the KSPP recommendations (Talos sets these too), and one limit raised
# for containers. Left out on purpose: user.max_user_namespaces=0 breaks podman in jobs, and
# kernel.modules_disabled=1 breaks loading the network modules podman needs.
# Hide kernel addresses (they help exploits bypass KASLR), even from root.
kernel.kptr_restrict = 2
# Only root may read the kernel log; it leaks addresses.
kernel.dmesg_restrict = 1
# No perf events for non-root users.
kernel.perf_event_paranoid = 3
# Harden the BPF JIT against JIT spraying.
net.core.bpf_jit_harden = 2
# No BPF for non-root users, and no switching it back on at runtime.
kernel.unprivileged_bpf_disabled = 1
# No kexec: no booting another kernel past Secure Boot.
kernel.kexec_load_disabled = 1
# No core dumps of setuid programs; they can hold secrets.
fs.suid_dumpable = 0
# No loading TTY line disciplines on demand; old ones had exploitable bugs.
dev.tty.ldisc_autoload = 0
# userfaultfd only for root; it makes kernel race exploits reliable.
vm.unprivileged_userfaultfd = 0
# No opening FIFOs and files owned by others in sticky directories like /tmp.
fs.protected_fifos = 2
fs.protected_regular = 2
# ptrace only on your own descendants.
kernel.yama.ptrace_scope = 1
# Containers (file watchers, systemd in containers) run out of Fedora's 128 inotify instances
# per user; 8192 is common on Kubernetes nodes.
fs.inotify.max_user_instances = 8192
@@ -1,12 +1,8 @@
# DHCP on the real network cards. Kind=!* skips virtual links like the veths of podman's bridges,
# which netavark manages.
# 80-dhcp.network turns on DHCP on the real network cards. Kind=!* skips
# virtual links such as those of containers.
[Match]
Type=ether
Kind=!*
[Network]
DHCP=yes
[DHCPv4]
# The hostname is the runner's name (gitea-runner.service), not the DHCP server's.
UseHostname=no
@@ -1,12 +0,0 @@
# Services enabled in the image (mkosi runs systemctl preset-all). Fedora disables getty@.service, the
# login on the screen (tty1, and tty2-6 through its autovt@ alias); this file sorts first, so it wins.
enable systemd-networkd.service
enable systemd-resolved.service
enable nftables.service
enable podman.socket
enable getty@.service
enable gitea-runner-setup@.service tty1 ttyS0
enable etc-shadow.mount
enable gitea-runner.service
enable systemd-sysupdate-update.timer
enable systemd-sysupdate-reboot.timer
@@ -0,0 +1,24 @@
# 50-runneros.preset enables the services of the image. PID 1 applies it at
# first boot, so a change reaches existing machines only after a factory reset.
# It sorts before Fedora's presets, so it wins where they disagree.
# systemd-networkd is disabled by Fedora, which uses NetworkManager.
enable systemd-networkd.service
# gitea-runner.path starts the runner once it is registered.
enable gitea-runner.path
disable gitea-runner.service
# getty@.service is the login on the screen, which Fedora disables.
enable getty@.service
enable systemd-sysupdate-update.timer
enable systemd-sysupdate-reboot.timer
# authselect-apply-changes fails, because /etc/authselect is on read-only /usr.
disable authselect-apply-changes.service
# systemd-homed, systemd-userdbd and systemd-nsresourced are unused here.
disable systemd-homed.service
disable systemd-homed-activate.service
disable systemd-userdbd.socket
disable systemd-nsresourced.socket
@@ -1,14 +0,0 @@
# The root password. /etc is read-only, so gitea-runner-setup writes the shadow file to /var and
# this mounts it over /etc/shadow.
[Unit]
Description=Root password from /var
ConditionPathExists=/var/lib/shadow/etc/shadow
RequiresMountsFor=/var
[Mount]
What=/var/lib/shadow/etc/shadow
Where=/etc/shadow
Options=bind
[Install]
WantedBy=local-fs.target
@@ -1,18 +0,0 @@
# Before the runner starts: loads our job image from /usr into podman's storage (wiped at every
# boot), and pulls the base images that jobs share read-only (see /usr/lib/gitea-runner/config.yaml),
# so no job uses them while they change. Hosts reboot to update, so this runs about as often as
# there are updates.
[Unit]
Description=Images for Gitea Actions jobs
Wants=network-online.target
After=network-online.target
Before=gitea-runner.service
[Service]
Type=oneshot
Environment=IMAGES=/var/lib/containers/base-images
ExecStart=/bin/sh -c 'podman tag "$(podman pull -q oci:/usr/lib/gitea-runner/job-image)" localhost/git-runner-job:latest'
# Without network the runner still starts, with the images it has.
ExecStart=-/usr/bin/podman --root ${IMAGES} --runroot /run/containers/base-images pull -q --policy newer quay.io/fedora/fedora:45
ExecStart=/usr/bin/podman --root ${IMAGES} --runroot /run/containers/base-images image prune -f
TimeoutStartSec=30min
@@ -1,20 +0,0 @@
# First boot: asks for the root password and the runner's registration, on the screen (tty1) and
# the serial console (ttyS0) at once; whichever is answered first stops the other.
[Unit]
Description=Gitea runner first-boot setup on %I
ConditionPathExists=!/var/lib/gitea-runner/runner.env
Before=getty@%i.service serial-getty@%i.service kmsconvt@%i.service
[Service]
Type=oneshot
ExecStart=/usr/libexec/gitea-runner-setup
StandardInput=tty
StandardOutput=tty
TTYPath=/dev/%I
TTYReset=yes
TTYVHangup=yes
# Answering on one console stops the setup on the other (SIGTERM), which is no failure.
SuccessExitStatus=SIGTERM
[Install]
WantedBy=multi-user.target
@@ -0,0 +1,10 @@
# gitea-runner.path starts the runner once it is registered, so a new machine
# waits for `gitea-runner -c /etc/gitea-runner/config.yaml register`.
[Unit]
Description=Start the Gitea runner once registered
[Path]
PathExists=/var/lib/gitea-runner/.runner
[Install]
WantedBy=multi-user.target
@@ -1,28 +1,20 @@
# The Gitea Actions runner. Registers itself on its first start.
# gitea-runner.service runs the Gitea Actions runner, which runs each job in a
# container on root's podman. gitea-runner.path starts it once it is
# registered. It runs as root: whoever has podman's socket is root anyway.
#
# TimeoutStopSec is a bit longer than runner.shutdown_timeout in
# /etc/gitea-runner/config.yaml, so running jobs can finish on stop.
[Unit]
Description=Gitea Actions runner
Wants=network-online.target gitea-runner-images.service
# gitea-runner-setup writes runner.env on first boot.
After=network-online.target podman.socket gitea-runner-images.service
After=gitea-runner-setup@tty1.service gitea-runner-setup@ttyS0.service
Wants=network-online.target
After=network-online.target podman.socket
Requires=podman.socket
[Service]
# Runs as root: it drives root's podman, which is root access anyway. The jobs it starts never
# get the socket (see config.yaml).
WorkingDirectory=/var/lib/gitea-runner
EnvironmentFile=/var/lib/gitea-runner/runner.env
# HOME holds the cache of actions/cache, next to the registration.
Environment=HOME=/var/lib/gitea-runner
Environment=DOCKER_HOST=unix:///run/podman/podman.sock
# The hostname is the runner's name. /etc is read-only, so it is set on every start.
ExecStartPre=/usr/bin/hostnamectl hostname --transient ${GITEA_RUNNER_NAME}
# Register once; the result is kept in .runner.
ExecStartPre=/bin/sh -c '[ -f .runner ] || exec gitea-runner register --no-interactive --config /usr/lib/gitea-runner/config.yaml --instance "$GITEA_INSTANCE_URL"'
ExecStart=/usr/bin/gitea-runner daemon --config /usr/lib/gitea-runner/config.yaml
ExecStart=/usr/bin/gitea-runner -c /etc/gitea-runner/config.yaml daemon
Restart=on-failure
# A bit longer than runner.shutdown_timeout, so running jobs can finish on stop.
TimeoutStopSec=35min
RestartSec=10s
[Install]
WantedBy=multi-user.target
TimeoutStopSec=65min
@@ -1,8 +0,0 @@
# systemd-oomd for job containers, which podman runs in this slice: when jobs run the VM out of
# memory, kill the job container responsible, before the VM thrashes on zram swap or the kernel's
# OOM killer picks the runner or podman.
[Slice]
# Memory pressure above 60% for 30s: kill the container reclaiming the most memory.
ManagedOOMMemoryPressure=kill
# Swap over 90% full: kill the container using the most swap.
ManagedOOMSwap=kill
@@ -1,6 +0,0 @@
# Load our firewall (/usr/lib/gitea-runner/firewall.nft) instead of /etc/sysconfig/nftables.conf.
[Service]
ExecStart=
ExecStart=/usr/sbin/nft -f /usr/lib/gitea-runner/firewall.nft
ExecReload=
ExecReload=/usr/sbin/nft -f /usr/lib/gitea-runner/firewall.nft
@@ -1,5 +1,6 @@
# Daily at about 04:10, reboot into a downloaded update. Stop the runner first: it takes no new
# jobs and lets running ones finish (runner.shutdown_timeout).
# drain.conf stops the runner before an update reboots the machine, so running
# jobs can finish first (TimeoutStopSec= of gitea-runner.service). A plain
# reboot would stop the job containers at the same time as the runner.
[Service]
ExecStartPre=/bin/sh -c '/usr/lib/systemd/systemd-sysupdate pending || exit 0; systemctl stop gitea-runner'
TimeoutStartSec=40min
ExecStartPre=/bin/sh -c '/usr/lib/systemd/systemd-sysupdate pending || exit 0; systemctl stop gitea-runner.service'
TimeoutStartSec=70min
@@ -1,19 +0,0 @@
# Updates the root filesystem: writes the next version to the unused root partition.
# Verify=yes: SHA256SUMS.gpg must be signed by a key in /usr/lib/systemd/import-pubring.pgp, and
# SHA256SUMS checks each download.
[Transfer]
ProtectVersion=%A
Verify=yes
[Source]
Type=url-file
Path=https://git.plabble.org/api/packages/Job79/generic/git-runner/latest/
MatchPattern=git-runner_@v.root-%a.@u.raw.zst
[Target]
Type=partition
Path=auto
MatchPattern=git-runner_@v
MatchPartitionType=root
PartitionFlags=0
ReadOnly=1
@@ -0,0 +1,20 @@
# 10-usr.transfer writes the next version of /usr to the inactive /usr
# partition.
#
# systemd-sysupdate requires SHA256SUMS.gpg to be signed by a key in
# /usr/lib/systemd/import-pubring.pgp, and SHA256SUMS checks each download.
[Transfer]
ProtectVersion=%A
[Source]
Type=url-file
Path=https://git.plabble.org/api/packages/Job79/generic/runneros/latest/
MatchPattern=runneros_@v.usr-%a.@u.raw.zst
[Target]
Type=partition
Path=auto
MatchPattern=runneros_@v
MatchPartitionType=usr
PartitionFlags=0
ReadOnly=1
@@ -1,17 +0,0 @@
# Updates the root filesystem's dm-verity hashes, next to 10-root.transfer (see it for Verify=yes).
[Transfer]
ProtectVersion=%A
Verify=yes
[Source]
Type=url-file
Path=https://git.plabble.org/api/packages/Job79/generic/git-runner/latest/
MatchPattern=git-runner_@v.root-%a-verity.@u.raw.zst
[Target]
Type=partition
Path=auto
MatchPattern=git-runner_@v_verity
MatchPartitionType=root-verity
PartitionFlags=0
ReadOnly=1
@@ -0,0 +1,17 @@
# 11-usr-verity.transfer writes the dm-verity hashes that go with
# 10-usr.transfer, which explains how downloads are checked.
[Transfer]
ProtectVersion=%A
[Source]
Type=url-file
Path=https://git.plabble.org/api/packages/Job79/generic/runneros/latest/
MatchPattern=runneros_@v.usr-%a-verity.@u.raw.zst
[Target]
Type=partition
Path=auto
MatchPattern=runneros_@v_verity
MatchPartitionType=usr-verity
PartitionFlags=0
ReadOnly=1
@@ -1,17 +1,23 @@
# Installs the next UKI, which systemd-boot boots by default. Verify=yes: see 10-root.transfer.
# 20-uki.transfer installs the next UKI, which systemd-boot then boots by
# default. For how downloads are checked, see 10-usr.transfer.
#
# The new UKI gets three tries (boot counting: the +@l-@d in its name).
# systemd-bless-boot marks it good once a boot reaches boot-complete.target.
# If no boot does, systemd-boot goes back to the previous UKI, and with it to
# the previous /usr partition, because each UKI holds its usr hash.
[Transfer]
ProtectVersion=%A
Verify=yes
[Source]
Type=url-file
Path=https://git.plabble.org/api/packages/Job79/generic/git-runner/latest/
MatchPattern=git-runner_@v.efi
Path=https://git.plabble.org/api/packages/Job79/generic/runneros/latest/
MatchPattern=runneros_@v.efi
[Target]
Type=regular-file
Path=/EFI/Linux
PathRelativeTo=boot
MatchPattern=git-runner_@v.efi
Mode=0444
MatchPattern=runneros_@v+@l-@d.efi runneros_@v+@l.efi runneros_@v.efi
TriesLeft=3
TriesDone=0
InstancesMax=2
@@ -0,0 +1,30 @@
# factory-etc.conf links what the image needs from /usr/share/factory/etc
# (mkosi.finalize) into the empty /etc at boot, so updates to /usr take effect
# in /etc too. The rest of the factory is unused package config. /etc itself
# holds what the machine writes: passwd, shadow, group, machine-id, ld.so.cache,
# /etc/systemd and the networks of podman (/etc/containers/networks). Podman
# reads its own config from /usr/share/containers. systemd's own etc.conf sets
# up os-release, nsswitch.conf and pam.d.
#
# /etc/systemd is filled from the presets at first boot, by PID 1.
# gitea-runner holds the config of the runner.
L /etc/gitea-runner
# authselect holds the PAM files that /etc/pam.d links to.
L /etc/authselect
L /etc/security
L /etc/environment
L /etc/login.defs
L /etc/shells
# pki and ssl hold the CA certificates, and crypto-policies the TLS settings.
L /etc/pki
L /etc/ssl
L /etc/crypto-policies
L /etc/bashrc
L /etc/profile
L /etc/profile.d
L /etc/protocols
L /etc/services
L /etc/hostname
@@ -1,6 +1,7 @@
# The runner's directories, and a clean container storage on every boot.
# State: holds the registration (.runner) and the actions cache.
d /var/lib/gitea-runner 0700 root root -
# Wipe all job containers, volumes and images on every boot. The shared base images
# (/var/lib/containers/base-images) stay; gitea-runner-images.service updates them.
# gitea-runner.conf makes the state directory of the runner, which holds its
# registration (/etc/gitea-runner/config.yaml).
d /var/lib/gitea-runner 0700
# The storage of root's podman is wiped at every boot, so images and leftovers
# of jobs don't pile up. Jobs pull their images again.
R /var/lib/containers/storage