Not approved as drafted -- four things came out of checking them against each other, and one was a bug that would have broken every upgrade. The bug: 0059 specified Restart=on-failure while 0057 has the host restart onto a new binary by exiting CLEANLY. on-failure does not restart a process that exited zero, so every upgraded node would have been left stopped, having successfully upgraded. Found by reading the two records against each other rather than by either alone. Now Restart=always in all three places that mention it. The host cannot run in a container, and the reason is decisive rather than stylistic: step 0 of the substrate bootstrap installs the container runtime, so a host inside a container would need the thing it exists to install. It would also break 0041 -- copy it onto a machine and run it stops being true when the machine must already have a runtime. Everything above tier 0 is a container; the host is not. That split is the tier boundary, not an inconsistency. systemd is named rather than abstracted. An init is not a dependency in 0041's sense: 0041 is about what must be installed before the host works, and an init is not installed, it is what the machine already is. The unit file is the only systemd-specific artefact and it belongs to the package, so a machine with a different supervisor ships a different package. The mesh is a watchdog, and my first draft was half an answer. Recovery must be local -- nothing dials a node, and a host that cannot start cannot report. But detection is the mesh's, and a local supervisor structurally cannot do it: it sees one process failing and cannot tell a broken machine from a broken release. Only something watching every node can, and that distinction decides whether the response is "fix this machine" or "stop shipping this version". So a host rollout is staged -- a few nodes, wait for heartbeats, continue or stop on silence. Local rollback still needed, because the canary nodes break and because a node offline during the rollout gets the declaration later with no batch around it. The first declaration is the overlay and nothing else. Forced, because a node's address and peers are assigned rather than chosen. But also the way back in: a node reachable over the overlay can be fixed by hand if a later declaration breaks it, and a large first declaration risks a node that is broken and unreachable at once. Also stated plainly, because it reads as a contradiction: nodes reach each other over the overlay and every node consumes from the broker; what 0039 forbids is an inbound CONTROL surface, not reachability. And in 06: no node holds a credential to any control-plane store, for reads or writes. Four ADRs already say this separately and none of them said it in one place. Nodes state over the broker; the owning context writes. With a note that most high-frequency writes are observability's, not the registry's -- routing logs into the registry would be the shared-schema mistake arriving through a door marked performance.
189 lines
9.4 KiB
Markdown
189 lines
9.4 KiB
Markdown
---
|
|
status: accepted
|
|
date: 2026-08-27
|
|
deciders: jochen
|
|
reconstructed: false
|
|
extends: 0057-the-host-is-a-root-service-installed-as-a-package.md
|
|
---
|
|
|
|
# 59. Two watchdogs: the mesh stages the rollout, the supervisor recovers the node
|
|
|
|
## Context
|
|
|
|
[`09-the-node-lifecycle.md`](../03-DESIGN/01-to-be/09-the-node-lifecycle.md) left one thing
|
|
unsolved: a host upgraded to a version that crashes on start. The supervisor restarts it, backs
|
|
off, and the node is stuck on a binary that will not run.
|
|
|
|
It was left because automatic recovery looked like *the host judging its own health*, which is
|
|
the self-reference the rest of that document avoids.
|
|
|
|
**That objection does not survive being asked properly.** A keepalive is not the host judging
|
|
itself — it is something else judging the host.
|
|
|
|
### There are two watchdogs, and they cannot do each other's job
|
|
|
|
A first draft of this record concluded the watchdog must be local, and stopped there. That was
|
|
half an answer: it is true that recovery must be local, and false that the mesh has no part.
|
|
|
|
| | can see | can act |
|
|
|---|---|---|
|
|
| **the service manager**, on the node | that *this* process keeps dying | **yes** — restart it, replace it |
|
|
| **the mesh** | that *eleven of twelve nodes* went quiet after one declaration | **no** — nothing dials a node |
|
|
|
|
**Recovery must be local**, and that half stands:
|
|
|
|
- **Nothing dials a node.** [ADR 0039](0039-the-link-is-the-security-boundary.md) makes the link
|
|
outbound and node-initiated, with no listening control surface. The mesh has no way to reach
|
|
in and act.
|
|
- **The failure removes the reporting path.** A host that cannot start cannot link, so the mesh
|
|
learns nothing *from that node* to act on.
|
|
|
|
**But detection is the mesh's**, and it is the half a local watchdog structurally cannot do. A
|
|
node's supervisor sees one process failing and has no idea whether that is a broken machine or a
|
|
broken release. **Only something watching every node can tell those apart** — and telling them
|
|
apart is what decides whether the right response is *fix this machine* or *stop shipping this
|
|
version immediately*.
|
|
|
|
### The failure this actually prevents
|
|
|
|
Sharper than "the node is down", and it is the reason to bother:
|
|
|
|
> **A host that will not start looks exactly like a machine that was switched off.**
|
|
|
|
[ADR 0036](0036-a-node-is-a-managed-machine.md) makes disconnection ordinary, and
|
|
[`09`](../03-DESIGN/01-to-be/09-the-node-lifecycle.md) deliberately puts no alarm on it — a
|
|
laptop shut for three weeks is doing nothing wrong. **A bad upgrade is therefore invisible**: it
|
|
presents as the one condition the design has decided not to be alarmed by.
|
|
|
|
Worse, it arrives fleet-wide. A declaration naming a bad version reaches every node, and each
|
|
one applies it, restarts, and stops talking. The mesh would report a fleet of quiet nodes and
|
|
nothing else.
|
|
|
|
## Decision
|
|
|
|
**The mesh stages the rollout and stops when nodes go quiet. The service manager recovers the
|
|
node it is on.** Prevention and recovery, and neither substitutes for the other.
|
|
|
|
### The mesh stages a host rollout
|
|
|
|
A host version does not reach every node at once. The delivery context updates a few nodes'
|
|
declarations, **waits for those nodes to heartbeat on the new version**, and only then continues.
|
|
|
|
```
|
|
update 2 nodes ─► heard from both, running the new version ─► continue
|
|
└► silence past the window ─► STOP. Report.
|
|
```
|
|
|
|
**Silence is the signal, and it is available because of the heartbeat**
|
|
([ADR 0057](0057-the-host-is-a-root-service-installed-as-a-package.md)). A node that upgraded
|
|
and cannot start stops reporting; that is indistinguishable from a switched-off machine *for one
|
|
node*, and completely distinguishable across a batch that was all told the same thing at the
|
|
same time.
|
|
|
|
**This is what keeps a bad release from becoming a fleet outage.** Local rollback repairs a node
|
|
after the fact; staging means most nodes never receive the bad version at all. A stopped rollout
|
|
is two broken nodes and a report, rather than every node quiet at once.
|
|
|
|
**It does not replace local recovery**, for two reasons. The canary nodes still break, and
|
|
somebody has to be able to fix them. And a node that was offline during the staged rollout gets
|
|
the declaration when it reconnects, with no batch around it and nothing watching — so it must be
|
|
able to recover alone.
|
|
|
|
### On the node: the service manager rolls back
|
|
|
|
Four parts, and each one is chosen so it works when the host does not:
|
|
|
|
### 1 — A version is confirmed by starting, not by seeming well
|
|
|
|
On start, the host completes one full reconcile. If it does, it writes the running version to a
|
|
plain file — `/var/lib/mesh-host/known-good` — and that is the whole of "confirmed".
|
|
|
|
**Deliberately not health.** Not *the link is up*, because a disconnected node is ordinary and a
|
|
laptop on a train would roll itself back. Not *everything applied cleanly*, because a resource
|
|
that fails is the machine's problem and not the binary's. The claim is narrow and checkable: **it
|
|
started, and it got through a reconcile.**
|
|
|
|
### 2 — The rollback is not the host binary
|
|
|
|
The obvious mistake, and it would make the whole mechanism a no-op: `nox-mesh-host rollback`
|
|
cannot be the recovery path for a `nox-mesh-host` that does not run.
|
|
|
|
Rollback is a **small script shipped by the package**, which reads the `known-good` file and
|
|
asks the package manager to install that version. It shares no code with the host and does not
|
|
import it.
|
|
|
|
### 3 — The supervisor triggers it, after giving up
|
|
|
|
```ini
|
|
[Service]
|
|
Restart=always
|
|
StartLimitBurst=3
|
|
StartLimitIntervalSec=120
|
|
|
|
[Unit]
|
|
OnFailure=nox-mesh-host-rollback.service
|
|
```
|
|
|
|
**`Restart=always`, not `on-failure`**, and the difference is load-bearing rather than a
|
|
preference. [ADR 0057](0057-the-host-is-a-root-service-installed-as-a-package.md) has the host
|
|
restart onto a new binary by **exiting cleanly** — and `on-failure` does not restart a process
|
|
that exited zero. An earlier draft of this record specified `on-failure` and would have left
|
|
every upgraded node stopped, having successfully upgraded. Caught by reading the two records
|
|
against each other rather than by either alone.
|
|
|
|
Three failures in two minutes is a binary that does not work, not a transient. The supervisor
|
|
stops trying, the unit enters a failed state, and `OnFailure` runs the rollback unit — which
|
|
downgrades and starts the host again.
|
|
|
|
### 4 — With nothing to roll back to, it does not try
|
|
|
|
A machine whose host has *never* completed a reconcile has no `known-good`. The rollback unit
|
|
finds nothing, does nothing, and says so.
|
|
|
|
That is the right outcome: there is no previous version, so the node was never working, and the
|
|
failure belongs to the installation rather than to an upgrade. Attempting a rollback here would
|
|
mean guessing at a version, which is how a recovery mechanism becomes a second fault.
|
|
|
|
### 5 — It rolls back once
|
|
|
|
The rollback unit records that it fired. If the rolled-back version *also* fails to start, it
|
|
does **not** fire again — the node stops, loudly, in a failed state.
|
|
|
|
**Because a second rollback is a different diagnosis.** Once the previously-working binary also
|
|
fails, the binary is not the problem: the machine is. Rolling back further would flap between
|
|
two versions forever and bury the actual cause under a loop.
|
|
|
|
## Consequences
|
|
|
|
- **The node keeps its own recovery**, which is the property the whole tier-0 design rests on:
|
|
the host depends on nothing, and now its recovery depends on nothing either.
|
|
- **The package cache must retain the previous version**, and that is a real requirement rather
|
|
than an assumption — a package manager configured to clean its cache would delete the thing
|
|
rollback needs. The package must pin that, and it is the sort of dependency that is discovered
|
|
by the rollback failing.
|
|
- **A fleet-wide bad upgrade becomes self-limiting.** Each node fails, rolls back, and comes
|
|
back on the previous version — so the blast radius of a bad host release is one restart cycle
|
|
per node rather than the entire fleet stopping.
|
|
- **It catches "will not start" and nothing else.** A version that starts and is subtly wrong
|
|
will not roll back, and should not: that is a bad release, which is delivery's problem
|
|
([ADR 0058](0058-delivery-ends-in-a-declaration.md)), not a supervision problem.
|
|
- **It adds a unit and a script the host does not own**, which is
|
|
[ADR 0057](0057-the-host-is-a-root-service-installed-as-a-package.md)'s line holding: the
|
|
installation owns the host, and now it owns the host's recovery too. Consistent, and it means
|
|
both arrive and are versioned together.
|
|
- **A node in permanent failure is silent, and that is now the last gap.** After a second
|
|
failure the node is stopped and cannot report it. What notices is the mesh seeing a node that
|
|
has not been heard from — which `09` records as a fact with no threshold, and which this makes
|
|
more important to look at than it was.
|
|
- **The rollback path is exercised only when it is needed**, which is when nobody can afford it
|
|
to be wrong. It wants a test that boots a lab node onto a deliberately broken host and asserts
|
|
the previous version comes back.
|
|
|
|
## References
|
|
|
|
- [ADR 0057](0057-the-host-is-a-root-service-installed-as-a-package.md) — the restart-by-exiting
|
|
this protects.
|
|
- [ADR 0039](0039-the-link-is-the-security-boundary.md) — why the watchdog cannot be remote.
|
|
- [ADR 0036](0036-a-node-is-a-managed-machine.md) — why the failure is invisible without this.
|
|
- [`09-the-node-lifecycle.md`](../03-DESIGN/01-to-be/09-the-node-lifecycle.md) — the gap this closes.
|