Skip to content

Unconfirmed changes no longer survive a reboot (#9) - #50

Merged
Cd1s merged 1 commit into
mainfrom
fix/confirm-survives-reboot
Sep 25, 2026
Merged

Cd1s merged 1 commit into
mainfrom
fix/confirm-survives-reboot

Conversation

@Cd1s

@Cd1s Cd1s commented Sep 25, 2026

Copy link
Copy Markdown
Owner

What

  • The pending-confirm marker moves from tmpfs to /etc/mini-router/confirm-pending (JSON: snapshot, state = applying | pending | reverting, deadline, via). It is fsynced right after the snapshot and before the first new file is written, and removed (after a sync) only when the change is accepted (apply without --confirm, mr confirm) or a rollback has put the old files back.
  • New mr rollback --boot: restores the marker's snapshot offline — files back, files the change created removed, default runlevel links matched to the restored config (linkRunlevel), nothing restarted — and records it in /etc/router-changes.log (timestamp: best guess from the marker / mr-clock reference, the board has no RTC).
  • mr-preinit runs it after pivoting into the overlay, before firstboot and init (logged to the kernel log). Alpine installs (no preinit) get the mr-unconfirmed boot-runlevel service; install.sh enables it.
  • The confirm timer and the web UI's revert only act on a pending change and mark it reverting first (so they cannot both roll back); mr confirm refuses while the apply is still running or being rolled back; an explicit mr rollback settles a pending change.

Why

/run is tmpfs and the marker was written only after the apply had finished. A power cut, watchdog reset or kernel oops during an apply or inside the confirm window kept a configuration nobody had confirmed — the exact case the confirm window exists for (RouterOS Safe Mode and VyOS go back to the old config here).

Verification

  • tools/ci.sh passes (private and public trees). New unit tests (mr/apply_test.go): boot rollback of an unconfirmed change (restored and removed files, runlevel links incl. dangling per-WAN instances, change log, marker gone, no-op without a marker), interrupted apply, unreadable marker / missing snapshot (reported once, not retried every boot), mr confirm in every state, the timer leaves other changes alone.
  • nandsim selftest with an image built from this change: all cases pass, including the new P8 — rootfs_data prepared as an apply --confirm leaves it (snapshot, new router.yaml, a file created by the change, a runlevel link, the marker): after boot the old LAN address is back, the created file and the link are gone, marker removed, kernel log and change log have the rollback line; the same state without the marker (confirmed) boots with the new config.

Closes #9

https://claude.ai/code/session_01HWeUjo1dmS7gBkCYHrVjCr

…rker, rolled back at boot

The confirm state lived in tmpfs (/run/mini-router/confirm-pending) and was written only after the
apply had finished, so a power cut, watchdog reset or crash during an apply or inside the confirm
window kept a configuration nobody had accepted.

- The marker is /etc/mini-router/confirm-pending (JSON: snapshot, state applying|pending|reverting,
  deadline, origin), fsynced right after the snapshot and before the first new file; it goes away
  (after a sync) only when the change is accepted (apply without --confirm, `mr confirm`) or the
  rollback has put the old files back.
- `mr rollback --boot`: restores the marker's snapshot offline (files, removed files, default
  runlevel links; nothing restarted) and logs it. mr-preinit runs it after pivoting into the
  overlay, before firstboot and init; Alpine installs get the mr-unconfirmed boot service.
- The confirm timer and the web UI's revert only act on a pending change and mark it reverting;
  `mr confirm` refuses while the apply is still running or being rolled back; an explicit
  `mr rollback` settles a pending change.
- Tests: boot rollback, interrupted apply, unreadable marker / missing snapshot, confirm states,
  timer; nandsim selftest P8 (power cut in the window -> old config at boot; confirmed -> kept).

Closes #9
@Cd1s
Cd1s merged commit 5f7f2df into main Sep 25, 2026
2 of 3 checks passed
@Cd1s
Cd1s deleted the fix/confirm-survives-reboot branch September 25, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

确认窗口内断电 / 重启会永久保留未确认的配置(待确认状态只在 tmpfs)

1 participant