Repository navigation
fix(openrc): keep the live-media serial autologin - #4742
Conversation
25_autologin.yaml puts a root autologin on tty1 and ttyS0 for an OpenRC live boot. 10_accounting.yaml then ran an unguarded sed 's/ttyS0.*//g' over the same /etc/inittab and appended a plain getty, so the serial console lost the autologin while tty1 kept it. Ordering made that unavoidable rather than racy. runstage.go applies a stage as [stage.before, stage, stage.after], so every initramfs step of every file runs before any initramfs.after step, and 10_accounting.yaml's step is the only one of the two in initramfs.after. The comment above it says the after stage keeps it from colliding with other inittab writers; it does the opposite, it makes it win. Guard it with the complement of the one 25_autologin.yaml already carries, so exactly one of the two applies on any boot, ttyS0 always ends up with a line, and neither step depends on running first. Fixing it here rather than by moving 25_autologin.yaml's step later: that step also writes tty1, and 52_installer.yaml overrides tty1 from the initramfs stage on an install-mode boot. Moving 25_autologin.yaml into initramfs.after would have bought serial back by taking tty1 away from the installer. The third spec pins that down. Fixes kairos-io#4741 Signed-off-by: Ettore Di Giacinto <mudler@kairos.io>
Taking this one for review. I'll read the diff and the linked issue and post findings here. |
itxaka-agent
left a comment
There was a problem hiding this comment.
Automated triage agent (
kairos-triage-agent) running as@itxaka-agent.
This comment was generated by software. A human maintainer can override
any action taken here.
Approving. The new guard on the ttyS0 getty step in 10_accounting.yaml is the exact complement of the one in 25_autologin.yaml, so exactly one of the two writes a ttyS0 line on any boot, and the live-media serial autologin survives the initramfs.after step. The new spec replays the real step order and fails without the guard.
@Itxaka the CI for this PR is waiting on approval. Could you authorize the run so it can go through QA? |
QA in progress: I'm testing this now (head |
QA: pass at |
Fixes #4741.
On an OpenRC live boot,
25_autologin.yamlinstalls a root autologin ontty1and
ttyS0, and10_accounting.yamlthen deleted thettyS0one and appended aplain
gettyin its place. Serial was the one console a live medium could not bereached on, which is exactly what that entry exists for.
It was not a race.
agent/pkg/utils/runstage.goapplies a stage as[stage.before, stage, stage.after], so every file'sinitramfsstep runs beforeany file's
initramfs.afterstep, and10_accounting.yaml's is the only one ofthe two in
initramfs.after. It always ran last and its unguardedsed 's/ttyS0.*//g'always won.The fix gives that step the complement of the guard
25_autologin.yamlalreadycarries,
[ ! -f /run/cos/live_mode ]. Exactly one of the two applies on anyboot,
ttyS0always ends up with a line, and neither step depends on ordering.Why here and not in
25_autologin.yamlMoving
25_autologin.yaml's step intoinitramfs.afteralso fixes serial, and itis the wrong fix: that step writes
tty1too, and52_installer.yamloverridestty1from theinitramfsstage on an install-mode boot. Moving it later buysserial back by taking
tty1away from the installer. The third spec pins thatdown, and fails on that alternative.
Test
kairos-init/pkg/validation/cloudconfigs_openrc_inittab_test.goreplays everybundled cloud-config step that touches
/etc/inittab, in the orderrunstage.goruns them, against the real/etc/inittabofquay.io/kairos/alpine:3.18-core-amd64-generic-v2.4.3. It runs theif:guardsand the commands through
sh -cwith the absolute paths pointed at a temp root,the same approach as
cloudconfigs_vm_test.go, so it tests behaviour rather thanasserting on strings. Three boots: live, installed, and live with
install-mode.Each layer mutation-checked separately:
if:guardthe serial console lost its autologin; the installed spec still passes[ -f /run/cos/live_mode ]no inittab step was replayed25_autologin.yamltoinitramfs.after, drop this guard)the installer must own tty1 on an install-mode bootfailsgo build ./...,go test ./kairos-init/...andgolangci-lint run ./kairos-init/pkg/validation/...are clean locally. Localgolangci-lint is 2.12.2 against the pinned
v2.13.2-alpine, so CI is the realcheck there.
Not booted. The OpenRC path has no CI coverage (
git grep -i alpine .github/workflows/finds nothing) and the Kairos Alpine flavor on quay is frozenat v2.4.3, so this is a unit-level proof of the inittab sequence, not a boot test.
Found by diffing the OpenRC and systemd halves of the bundled cloud-configs, the
same vein as #4709 and #4713.
AI was used to write this change. No human has read it yet.