Skip to content

fix(sysext): apply merged sysusers and tmpfiles before the manager reload on a live refresh - #474

Merged
bketelsen merged 3 commits into
mainfrom
lucilla/live-refresh-sysusers
Oct 28, 2026
Merged

bketelsen merged 3 commits into
mainfrom
lucilla/live-refresh-sysusers

Conversation

@frostyard-machines

@frostyard-machines frostyard-machines commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A live refresh activated a sysext before its own sysusers.d accounts existed. In lab run dev-snow-bootc-lifecycle-kb7qb (frostyard/lab#163, Snow 20261028124727), updex features enable notesd --now and maild --now returned 0 and merged, but frostmail, frostnotes, lodge and lodge-apps did not exist. systemd-sysext refresh reloaded the manager (EXTENSION_RELOAD_MANAGER=1), multi-user.target's Upholds= started frostnotes-lodge.socket and frostmail.socket at once, they failed (SocketUser=/SocketGroup= unknown) to start-limit-hit, and the services failed on the dependency. After a reboot all passed: snosi's reload-sysext.service runs systemd-sysusers and systemd-tmpfiles before daemon-reload at boot only.

sysext.DefaultRunner.Refresh now activates in the boot order (ADR-0019):

  1. systemd-sysext refresh --no-reload — merge; the manager does not see it yet
  2. systemd-sysusers
  3. systemd-tmpfiles --create --graceful (no --remove, no --boot)
  4. systemd-sysext refresh --always-refresh=yes — remount the same set with systemd's own reload and EXTENSION_RESTART_UNITS= handling (--always-refresh=yes because systemd 260+ skips a refresh with an unchanged set)

By version (systemd-sysext --version): 260+ or unreadable → as above; 255–259 → plain step 4; <255 → one plain refresh (it never reloads), then steps 2 and 3.

Failures: step 1 returns at once (as before). A sysusers failure is a refresh failure, but steps 3 and 4 still run; when step 4 succeeds the error wraps sysext.ErrActivationIncomplete, and enable/disable/rollback say the extensions are merged and a reboot finishes activation (not "all extensions are unmerged"). A tmpfiles failure is one stderr warning (snosi#1167 rule). Step 4 failure is a refresh failure. SDK call sites are unchanged, so enable --now, update (without --no-refresh), rollback --now and disable --now all get it; the timer (--no-refresh) runs none of it.

Why updex and not snosi: updex runs the only live refresh on these hosts, and systemd has no hook between merge and reload, so a snosi unit could only run after the reload (too late) and would fix snosi only. Why a second refresh and not --no-reload + systemctl daemon-reload: updex would have to copy systemd's EXTENSION_RELOAD_MANAGER= decision and the systemd 262 EXTENSION_RESTART_UNITS=/EXTENSION_RELOAD_OR_RESTART_UNITS= handling.

Costs (in the ADR): two overlay remounts per live refresh (two brief gaps instead of one); on 260+ the last refresh remounts and reloads even when nothing changed; sysusers/tmpfiles act on the whole merged config; sysext sysctl.d stays boot-only; a unit that already hit its start limit needs systemctl reset-failed. updex never restarts units itself.

Checks

  • make fmt
  • make ci — passed locally (umask 022), including lint, race, e2e, cross-builds
  • CLI/e2e unchanged; go test ./cmd/updex ./tests/e2e/... green inside make ci
  • sysext/runner_test.go: order of the 4 commands; step 1 failure stops; sysusers failure continues and wraps; tmpfiles failure warns only; step 4 failure; sysusers + step 4 joined; Merge/Unmerge wrapping
  • SDK tests: ErrActivationIncomplete messages for enable, disable, rollback
  • Coverage total 90.2%; .coverage-baseline bumped 90.1 → 90.2

Risk classification

  • Tier 1: Low
  • Tier 2: Moderate
  • Tier 3: High
  • Tier 4: Critical

Rationale:

  • Privileged operation: a live refresh now runs systemd-sysusers (writes /etc/passwd, /etc/group) and systemd-tmpfiles --create as root, and remounts the overlay twice. Both tools are idempotent and are what the boot runs. Compatibility: per-version sequence, older systemd still works. Rollback: revert this commit; nothing persistent beyond accounts/paths the boot would also create.

Docs housekeeping

  • README.md, docs/design/overview.md, docs/specs/sdk-api.md, AGENTS.md updated
  • ADR-0019 from TEMPLATE.md, indexed in docs/README.md
  • Conformance aliases untouched

Verification

  • node scripts/check-docs.mjs green (inside make ci)
  • Checked against the PR review rubric

After a release: re-run lab's sysext_probe mode (frostyard/lab#163) on a Snow image that carries this updex; the sysext-enable boot must report the 4 accounts present and both sockets and services active without the reboot.

…load on a live refresh

A live refresh (enable --now, update, rollback --now, disable --now) let
systemd-sysext reload the manager before the merged sysusers.d accounts
existed, so upheld sockets of a new sysext failed until the next boot
(lab run dev-snow-bootc-lifecycle-kb7qb, notesd and maild).

DefaultRunner.Refresh now runs systemd-sysext refresh --no-reload,
systemd-sysusers, systemd-tmpfiles --create --graceful, then a plain
systemd-sysext refresh, whose reload and unit handling stay systemd's.
ADR-0019 records the decision.
@github-actions github-actions Bot added documentation Improvements or additions to documentation go Pull requests that update go code labels Oct 28, 2026
@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.36145% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
sysext/runner.go 88.73% 6 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

…ed but unfinished activation

systemd 260 skips a refresh whose image set did not change, so the plain
second refresh skipped the manager reload. DefaultRunner.Refresh now reads
the systemd version and uses --always-refresh=yes on 260+ (and on an
unreadable version), a plain refresh on 255-259, and a single plain refresh
before sysusers and tmpfiles below 255.

A sysusers failure after a successful last refresh wraps the new
sysext.ErrActivationIncomplete; enable, disable and rollback then say the
extensions are merged and a reboot finishes activation, instead of claiming
they are unmerged.
…d refresh; omit tmpfiles --graceful before systemd 254
@frostyard-machines frostyard-machines added the ready-for-human Reviewed, CI green: ready for Brian to review and merge label Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation go Pull requests that update go code ready-for-human Reviewed, CI green: ready for Brian to review and merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants