mirror of
https://github.com/pollen-robotics/microduck.git
synced 2026-12-03 02:47:45 +08:00
daemon-dev-autonomous-map
4
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
b64def7b73 |
updaterd: automatic rollback is off unless asked for
`[update_gate] auto_rollback` in robotd.toml, default false, a row in `robotctl configure`. It gates every path that reverts without being asked: - the health gate after `update apply`, `select` and `rollback`; - the boot counter on a trial that never confirmed; - `robot-boot-check` handing over to `robot-rescue`. Off, the gate still runs and decides. A release that fails stays live, reported `Stuck` with `robotctl update rollback <component>` in the reason; the trial is cleared, and the journal entry is aborted rather than rolled back, so `known_bad` does not blacklist it. The boot check names the failed units and the manual `robot-rescue --reboot`, and exits 2. `--dry-run` is unchanged, since the OS slot gate reads it. Releases now reach robots as tested Yocto images, and a separate daemon update is the dev-board case, where an unasked revert replacing the code under whoever holds the robot does more damage than it prevents. A soft deprecation: the code stays, tested, one setting away. `updaterd` reads the key from `robotd_config` (new, defaults to /etc/robot/robotd.toml), both layers, at the moment of deciding, like `allow_community` and the board. Test fixtures turn it on where they test what a revert does. Assisted-by: Claude:claude-opus-5-5 |
||
|
|
0357f5976e |
robot-boot-check: decide once the daemons settle, not 180 s in
The boot check slept until 180 s after boot and looked once. On a Yocto board every member is up by 16 s, so a healthy boot waited nearly three minutes for a verdict nothing needed it to wait for — and the OS's own gate, which copies the deadline, held the OS update page on "rebooting" for as long. The timer now starts the script a second in, and it looks every 2 s until the first of: a member that did not come up (hand over at once; the predicate is unchanged), every member `active` for 10 s straight (the release came up — about 25 s in on a Yocto board), or the deadline. The deadline is `[update_gate] boot_deadline_s` in robotd.toml, 60 s by default. It is when a boot that never settles is judged, by restart count, and updaterd's 10 s RestartSec needs about 45 s to show a crash loop. The script clamps it to 20-300 rather than robotd-params refusing it, since every daemon reading the file exits on a refused value. `robotctl configure` says it applies at the next boot. `--dry-run` now exits 3 where it would have handed over, so microduck-slot-health can ask the same question instead of copying it. Assisted-by: Claude:claude-opus-5-5 |
||
|
|
93afa4ed18 |
docs: one page owns the boot recovery net
The net is built, so its description belongs in `design/` rather than in a dated
`project/` record: `design/` is how it works and why, and one page owns a mechanism
while the others link to it.
`boot-recovery-net.md` owns the deadline and its predicate, the membership rule, the
rescue, the `golden` symlink and the loop guard — including the reasoning that is
invisible in the code it describes:
- why a deadline and not `OnFailure=`. All four members use `Restart=always` for
reasons argued in their own unit files, and none overrides the default start
limit, so a `btd` restarting every 5s crash-loops forever without ever entering
`failed`. `OnFailure=` would only fire if those units were retuned to give up.
- why the predicate is two conditions of positive evidence rather than "is it
active". A false negative costs a diagnosis, a false positive costs a good
release, so a stopped unit, an unloaded one and a slow one are all left alone.
- why the rescue parses nothing, why `golden` is a symlink `updaterd` republishes
on every start, and why a configured golden that is not installed publishes no
link at all.
- why clearing the breadcrumb precedes the boot counter: the trial would revert to
`previous` while the rescue already went to golden, so an armed trial moves
`current` back off golden a boot later.
- what is not tested, which is systemd itself.
Two owners of overlapping mechanisms now point here instead of describing it.
`updater-design.md` carried a paragraph specifying the `OnFailure=` design that was
never built, and its on-disk layout gains the `golden` symlink. `restart-order.md`
owns the startup sequence, so `record_rescue` and `refresh_golden_links` are listed
there as the steps they are, with the reasons kept on this page — and §4 now says
that everything it describes presupposes an `updaterd` that starts, which is the gap
the net exists for.
Assisted-by: Claude:claude-opus-5
|
||
|
|
0dfae4fd83 |
The recovery net fires without a human
Steps 1 and 2 built the parts: a rescue that can put a board back on golden with no update daemon, and four daemons that wait for their hardware rather than exiting, so that a unit which is down means a broken release and not a broken board. This is what asks the question. `robot-boot-check.timer` fires 180 seconds into every boot — `hci0` does not exist until roughly 73 seconds in, and the daemons wait rather than exit, so a slow boot must not read as a failed one. Its oneshot asks `systemctl show` for each member and hands over to `robot-rescue` when the answer is bad. A deadline rather than `OnFailure=` on each daemon. `OnFailure=` fires when a unit enters `failed`, which these units are configured to avoid: all four use `Restart=always` for reasons argued in their own unit files, and none overrides the default start limit, so a `btd` restarting every 5s crash-loops indefinitely without ever entering `failed`. Making `OnFailure=` fire would mean retuning those units so the daemons give up — degrading the normal case to enable the rescue case. **Two conditions, both positive evidence.** A member is `failed`, or it has restarted three or more times this boot. Everything else is left alone, and the asymmetry is the point: a unit an operator stopped is `inactive` with no restarts and must not cost the board its release; a unit the release predates answers nothing and reads the same way; a daemon still waiting for hardware is `active`; and one crash that recovered leaves one or two restarts, not three. A false negative costs a diagnosis, a false positive costs a good release. **Three ways this refuses to fire when it should not.** The `Conflicts=shutdown.target` on the oneshot, because a daemon killed on the way down can be recorded as `failed` and `systemctl poweroff` would otherwise eventually reboot a robot into golden. An uptime guard, because being invoked long after boot means something other than the timer started it. And the oneshot carries **no `[Install]` section**, which both installers now read as "do not enable this" — without it, `hooks/postinstall` running `enable --now` over the units it just wrote would run a rollback check in the middle of the update that installed it, with daemons legitimately mid-restart. Timers are enabled but not started for the same reason: an `OnBootSec=` timer started past its deadline fires at once. **The loop guard, and what opens it.** The rescue already refused when `current` is already golden, which covers the ordinary case because a successful rescue leaves exactly that state. It now also refuses while a breadcrumb from a previous attempt is on record, which covers the case that misses — an update moved `current` away from golden and failed again. `Engine::record_rescue` clears the breadcrumb on the next start, after copying it into the update log, so the guard opens exactly when the board proves it can run its update daemon again and stays shut when it cannot. `--force` is the way past by hand. That clearing runs **before** the boot counter, and the ordering is load-bearing: the trial would revert to `previous` while the rescue already went further, to golden. Left armed, `record_boot` would advance it and eventually move `current` off the release the rescue chose — the recovery net and the never-brick guarantee undoing each other one boot apart. A test pins it. The breadcrumb is `key=value` rather than JSON, though `updaterd` parses it: the writer is a shell script running on a board where things are already going wrong, and quoting JSON correctly in `sh` is a way to produce a record nothing can read. The reader is lenient for the same reason — every field is optional, because a breadcrumb that cannot be parsed is a guard that never opens. Tested without a board: the check's decision is a pure function of what `systemctl show` answers, so a stub supplies unit states and records whether a reboot was asked for. Nine cases, including a stopped daemon, a unit the release does not carry, an `active` unit with five restarts, and the two refusals. `board-test.sh` gains the installer half — that the timer is enabled and never started, that the oneshot is installed and never touched, and that both scripts land in /usr/local/sbin. What is **not** covered is systemd itself: whether the timer fires at `OnBootSec=180`, whether `Conflicts=shutdown.target` keeps the oneshot off the way down, and whether `NRestarts` reads the way this assumes on a crash-looping unit. That needs a privileged container with systemd as pid 1 — `install-path-gap.md` option C — which this is now the second argument for. Assisted-by: Claude:claude-opus-5 shellcheck |