Skip to content

fix(openrc): keep the live-media serial autologin - #4742

Merged
mudler merged 2 commits into
kairos-io:masterfrom
ci-forks:fix/4741-openrc-serial-autologin
Oct 12, 2026
Merged

mudler merged 2 commits into
kairos-io:masterfrom
ci-forks:fix/4741-openrc-serial-autologin

Conversation

@ci-robbot

Copy link
Copy Markdown
Collaborator

Fixes #4741.

On an OpenRC live boot, 25_autologin.yaml installs a root autologin on tty1
and ttyS0, and 10_accounting.yaml then deleted the ttyS0 one and appended a
plain getty in its place. Serial was the one console a live medium could not be
reached on, which is exactly what that entry exists for.

It was not a race. agent/pkg/utils/runstage.go applies a stage as
[stage.before, stage, stage.after], so every file's initramfs step runs before
any file's initramfs.after step, and 10_accounting.yaml's is the only one of
the two in initramfs.after. It always ran last and its unguarded
sed 's/ttyS0.*//g' always won.

The fix gives that step the complement of the guard 25_autologin.yaml already
carries, [ ! -f /run/cos/live_mode ]. Exactly one of the two applies on any
boot, ttyS0 always ends up with a line, and neither step depends on ordering.

Why here and not in 25_autologin.yaml

Moving 25_autologin.yaml's step into initramfs.after also fixes serial, and it
is the wrong fix: that step writes tty1 too, and 52_installer.yaml overrides
tty1 from the initramfs stage on an install-mode boot. Moving it later buys
serial back by taking tty1 away from the installer. The third spec pins that
down, and fails on that alternative.

Test

kairos-init/pkg/validation/cloudconfigs_openrc_inittab_test.go replays every
bundled cloud-config step that touches /etc/inittab, in the order
runstage.go runs them, against the real /etc/inittab of
quay.io/kairos/alpine:3.18-core-amd64-generic-v2.4.3. It runs the if: guards
and the commands through sh -c with the absolute paths pointed at a temp root,
the same approach as cloudconfigs_vm_test.go, so it tests behaviour rather than
asserting on strings. Three boots: live, installed, and live with install-mode.

Each layer mutation-checked separately:

mutation result
drop the new if: guard the two live specs fail, the serial console lost its autologin; the installed spec still passes
invert the guard to [ -f /run/cos/live_mode ] all three fail, including the anti-vacuity check no inittab step was replayed
the alternative fix (move 25_autologin.yaml to initramfs.after, drop this guard) serial passes, the installer must own tty1 on an install-mode boot fails

go build ./..., go test ./kairos-init/... and
golangci-lint run ./kairos-init/pkg/validation/... are clean locally. Local
golangci-lint is 2.12.2 against the pinned v2.13.2-alpine, so CI is the real
check 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 frozen
at 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.

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>
@ci-robbot

Copy link
Copy Markdown
Collaborator Author

Cross-reference for reviewers: #4862 fixes the same issue (#4741) with the same guard on the same step. Only one of the two needs to land.

@itxaka-agent

Copy link
Copy Markdown
Collaborator

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.

Taking this one for review. I'll read the diff and the linked issue and post findings here.

@itxaka-agent itxaka-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-agent

Copy link
Copy Markdown
Collaborator

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.

@Itxaka the CI for this PR is waiting on approval. Could you authorize the run so it can go through QA?

@itxaka-agent

Copy link
Copy Markdown
Collaborator

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.

QA in progress: I'm testing this now (head 9857cbea). Results and proof will follow on #4741.

@itxaka-agent

Copy link
Copy Markdown
Collaborator

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.

QA: pass at 9857cbea, details and proof: #4741 (comment)

@mudler
mudler merged commit 8ec6b30 into kairos-io:master Oct 12, 2026
46 checks passed
@github-project-automation github-project-automation Bot moved this from QA OK to Done โœ… in ๐Ÿง™Issue tracking board Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

openrc: 10_accounting.yaml deletes the live-media serial autologin that 25_autologin.yaml just installed

4 participants