lab: restart-policy no, sane healthcheck retries, launcher recovery hint #36

Merged
ginjiruu merged 1 commit from lab-restart-resilience into main 2026-11-16 16:59:25 +00:00
Owner

A host reboot turns the lab into a silent zombie: this morning the
workstation booted from a clean power-off and docker's restart policy
respawned clab-lab-test-01/02/03, each crash-looping 194 times at ~64 s
intervals while the CHR nodes stayed down.

Mechanism (verified this morning)

  • containerlab plugs the data links (test-0N:eth1 <-> labsw-sfpN) by moving
    veths into the container's netns at deploy time. A docker-level restart
    builds a fresh netns and nothing re-plugs them; on the host, the labsw
    bridge itself is gone after boot.
  • The launcher waits 60 s for its NICs, exits with
    "only 0 of 1 data NICs appeared" (correct), and the always policy
    respawns it forever. linux-kind nodes got restart=always, mikrotik_chr
    nodes policy=no, so a reboot leaves the lab half up.
  • The image healthcheck (test -e /run/vm-node/ready, Interval 2 s,
    Retries 300) needs 10 min of consecutive failures to go unhealthy, longer
    than the 64 s respawn cycle, so docker reported healthy for 8 hours.

VM disks were untouched (the loop dies before qemu starts). All three state
files said stopped; recovery is task lab:up && task lab:boot.

Changes

  • lab/lab.clab.yml: defaults: restart-policy: "no". Auto-restart can
    never help a node whose links containerlab will not re-plug; a reboot now
    leaves the lab uniformly down and task lab:up (already
    deploy --reconfigure + switch ports + wait-healthy + cert push) is the
    single recovery path.
  • modules/flake-parts/lab-node-image.nix: healthcheck Retries 300 -> 5,
    so healthy means something again.
  • lab/vm-node-launcher.sh: the NIC-timeout exit now names the recovery:
    "links are not re-plugged after a container restart - run task lab:up".

Testing

Reproduction observed live (RestartCount 194, log line every ~64 s).
Recovery + verification with this branch checked out: task lab:image,
task lab:up, task lab:boot, task lab:cluster-check, then the
resilience test: docker restart clab-lab-test-01 must leave it stopped
with no respawn, and task lab:up must bring it back. Results posted as a
comment.

A host reboot turns the lab into a silent zombie: this morning the workstation booted from a clean power-off and docker's restart policy respawned clab-lab-test-01/02/03, each crash-looping 194 times at ~64 s intervals while the CHR nodes stayed down. ## Mechanism (verified this morning) - containerlab plugs the data links (test-0N:eth1 <-> labsw-sfpN) by moving veths into the container's netns at deploy time. A docker-level restart builds a fresh netns and nothing re-plugs them; on the host, the labsw bridge itself is gone after boot. - The launcher waits 60 s for its NICs, exits with "only 0 of 1 data NICs appeared" (correct), and the `always` policy respawns it forever. linux-kind nodes got restart=always, mikrotik_chr nodes policy=no, so a reboot leaves the lab half up. - The image healthcheck (`test -e /run/vm-node/ready`, Interval 2 s, Retries 300) needs 10 min of consecutive failures to go unhealthy, longer than the 64 s respawn cycle, so docker reported `healthy` for 8 hours. VM disks were untouched (the loop dies before qemu starts). All three state files said `stopped`; recovery is `task lab:up && task lab:boot`. ## Changes - `lab/lab.clab.yml`: `defaults: restart-policy: "no"`. Auto-restart can never help a node whose links containerlab will not re-plug; a reboot now leaves the lab uniformly down and `task lab:up` (already `deploy --reconfigure` + switch ports + wait-healthy + cert push) is the single recovery path. - `modules/flake-parts/lab-node-image.nix`: healthcheck `Retries` 300 -> 5, so `healthy` means something again. - `lab/vm-node-launcher.sh`: the NIC-timeout exit now names the recovery: "links are not re-plugged after a container restart - run task lab:up". ## Testing Reproduction observed live (RestartCount 194, log line every ~64 s). Recovery + verification with this branch checked out: `task lab:image`, `task lab:up`, `task lab:boot`, `task lab:cluster-check`, then the resilience test: `docker restart clab-lab-test-01` must leave it stopped with no respawn, and `task lab:up` must bring it back. Results posted as a comment.
lab: a rebooted host must not crash-loop the VM nodes
Some checks failed
Validate Nix Flake / validate-nix (push) Has been cancelled
8381eee7fc
containerlab does not re-plug data links when docker restarts a container, so
restart=always on the linux-kind nodes turned every host reboot into a silent
194-restart loop ("only 0 of 1 data NICs appeared" every ~64s) while the CHR
nodes stayed down. restart-policy: no everywhere makes a reboot leave the lab
uniformly down and task lab:up the only recovery path; healthcheck Retries
300 -> 5 so a dead launcher cannot report healthy (300 x 2s outlives nothing);
the launcher now names the fix in its own exit line.
Author
Owner

Verification (2026-11-16, from this branch)

Reproduction, pre-fix. Live this morning: test-01/02/03 at
restarts=194 each, only 0 of 1 data NICs appeared every ~64 s, docker
healthy throughout, r1/r2/isp down, labsw bridge absent, test-01 netns
held only lo+eth0.

Deploy with the fix. task lab:image, task lab:up: containerlab
accepts defaults.restart-policy, every node came up policy=no restarts=0, test-01 has eth1 again, labsw recreated, 7/7 healthy,
router certs re-issued and pushed ("REST over HTTPS verifies against the lab
root"). task lab:boot: 3 Raft voters unsealed, contract applied, hosts
enrolled. task lab:cluster-check: passed.

Resilience test. docker restart clab-lab-test-01 against the healthy
lab: one run, clean VM stop (qemu signal 15), launcher logged

vm-node[test-01]: only 0 of 1 data NICs appeared; links are not
re-plugged after a container restart - run task lab:up

then status=exited exit=1 restarts=0 and stayed there. No respawn, other
nodes untouched. Pre-fix this was the infinite loop.

Recovery test. task lab:up (7/7 healthy) -> task lab:boot (enrolled,
k3s restarts) -> lab:cluster-check passed; VIP failover re-elected to
test-02 along the way.

## Verification (2026-11-16, from this branch) **Reproduction, pre-fix.** Live this morning: test-01/02/03 at `restarts=194` each, `only 0 of 1 data NICs appeared` every ~64 s, docker `healthy` throughout, r1/r2/isp down, `labsw` bridge absent, test-01 netns held only `lo`+`eth0`. **Deploy with the fix.** `task lab:image`, `task lab:up`: containerlab accepts `defaults.restart-policy`, every node came up `policy=no restarts=0`, test-01 has `eth1` again, `labsw` recreated, 7/7 healthy, router certs re-issued and pushed ("REST over HTTPS verifies against the lab root"). `task lab:boot`: 3 Raft voters unsealed, contract applied, hosts enrolled. `task lab:cluster-check`: passed. **Resilience test.** `docker restart clab-lab-test-01` against the healthy lab: one run, clean VM stop (qemu signal 15), launcher logged vm-node[test-01]: only 0 of 1 data NICs appeared; links are not re-plugged after a container restart - run task lab:up then `status=exited exit=1 restarts=0` and stayed there. No respawn, other nodes untouched. Pre-fix this was the infinite loop. **Recovery test.** `task lab:up` (7/7 healthy) -> `task lab:boot` (enrolled, k3s restarts) -> `lab:cluster-check` passed; VIP failover re-elected to test-02 along the way.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lab/machine-configs!36
No description provided.