carlos / platform Public

Rootfs resident is dark ~15 min after a box reboot: shutdown can't prove the instance unit stopped, so the lease is never released closed

Found during the overnight Rails test on dev (2026-10-27). The setup: fleet r10r, box box-1 (i-0c966f9d7826ed65d, Debian 13 arm64, v0.29.0). The instance is railsdemo.bab.dev.oncarlos.com, a Rails 8 rootfs app and always-on resident.

What happens on ec2 reboot-instances (a clean OS shutdown):

  • 22:46:30.45: systemd stops carlos-instance-rootfs-gen@railsdemo...:3.service first. It deactivates cleanly.
  • 22:46:30.96: systemd starts stopping carlos-edge.service.
  • 22:46:31 to 22:47:30: the activator logs railsdemo...: unit state: exit status 1 once a second. It can't prove the unit's stop, probably because the root control service or systemd's state query is going away at the same time.
  • 22:47:30: carlos-edge reaches its 60 s stop timeout and is stopped. The lease is not released, which is the safe direction.
  • After boot (22:47:41): the resident's first starts are refused with "box not ready" while the rootfs probe runs. Then LEASE HELD ... by "box/v1;ref=box-1;iid=i-0c966f9d7826ed65d;pid=9632" — a previous incarnation hasn't released repeats until the lease expires.
  • 23:01:34: the app serves again with all its data. Visitors got 503 "waking elsewhere" for about 15 minutes.

What is fine: systemctl restart carlos-edge (what a platform roll does) passed 60 of 60 probes with no failed request. A SIGKILL of Puma recovered in about 18 s with the data intact. The overlap deploy of a release with a migration (v1 to v2) failed no request.

Why it matters: an always-on Rails app goes dark for 15 minutes after every box reboot (kernel updates, instance maintenance), and the box's shutdown takes 60 s longer.

Possible fixes, not investigated:

  1. Order the shutdown so the agent stops and proves its instances while the root control service and systemd still answer. That would mean After= or Before= between carlos-edge, the instance-control socket and service, and the rootfs templates.
  2. Let the same box retake a lease held by its own earlier boot: the lease owner names this iid, and the boot id has changed since. Today the owner string carries the pid but no boot id.
  3. Treat a unit systemd reports as gone or not-found during shutdown as proven stopped.

The run log is in the rootfs session's scratch folder. Plan 3 Groups R and W are being built tonight; this is a separate fix.

Fix MERGED to main as 4029ac5 (2026-10-30), not released. Branch managed-fleets-1c-451, #457 phase 1c. A box now takes an unexpired legacy (non-HA) lock immediately when its owner is this same EC2 instance (same iid and ref) under a different kernel boot id; the legacy owner string carries ;boot=<id>. Same-boot (agent restart), other instance, older-binary owners and HA locks still wait as before. Failed systemctl state reads now log systemctl's own stderr, to confirm the shutdown cause (D-Bus guess). Astra R1 READY; census approved on #280. Native instances benefit too (leo, 2026-10-26). Still open here: the dev reboot drill (Task 6, needs a release on dev and Paul's go), then close.

Drill PASSED on dev (2026-10-30), v0.31.2 (4029ac56). v0.31.2 is on every dev box and the dev console since 17:32Z: https://github.com/carlosframework/releases/releases/tag/v0.31.2

box-1 (r10r) carrying railsdemo and shop, both rootfs always-on. Before: both locks owned box/v1;ref=box-1;iid=i-0c966f9d7826ed65d;pid=544451;boot=630ce0a3-.... Public probe of railsdemo every 1 s.

  • 17:39:02Z ec2 reboot-instances. Last 200 at 17:39:00; then 503/timeouts while the box was down.
  • 17:40:15Z kernel up (new boot c38793e6), 17:40:27Z edge up and tunnel connected, 17:40:28-34Z wakes wait for the box's rootfs probe (normal).
  • 17:40:37Z / 17:40:38Z: lease: taking instances/{railsdemo,shop}.../lock.json from this box's previous boot (630ce0a3... -> c38793e6...).
  • 17:40:42.6Z first 200 on railsdemo: 15 s after the edge started (was ~15 min). shop 200 over its socket; its worker started 17:41:04Z; no nokey or cannotopen; no failed units.

Cause confirmed from journalctl -b -1: every shutdown unit-state read failed with Failed to get properties: Transport endpoint is not connected (the edge loses systemd's bus while stopping instances). Filed as #475 (unit ordering). Closing this one: the dark-after-reboot symptom is fixed.