rollback: arm lock for the router pair (one merge armed both) #165
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
lab/iac!165
Loading…
Reference in a new issue
No description provided.
Delete branch "rollback-peer-lock"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes the race seen on #163: one merge applied rb5009-a and rb5009-b at the same moment, and both routers armed their rollback fuse at 09:20:01. The rule is never both at once.
Cause
arm.shchecked the peer's schedulers, then spent seconds to a minute on the probe wait and the backup before creating its own scheduler. Both runners started together, both read an unarmed peer, and both armed.Fix (
modules/rollback/scripts/arm.sh)/system/scriptr74-arm-lockon the pair's lower-sorting device, which is rb5009-a for the pair and r1 in the sim. RouterOS refuses a second script with the same name, so the create is an atomic test-and-set. The holder keeps the lock until its own scheduler exists, so the next holder's peer check sees it. A runner that finds the lock taken polls every 3 s, for up toR74_LOCK_WAIT(900 s).R74_PEER_WAIT(900 s). Its early confirm commits about 30 s after its apply, and its judge runs at N. Only then does the arm refuse. One merge therefore serializes the pair: the second router arms after the first commits, and neither apply fails.<owner> <epoch>, refreshed every 10 s while the holder waits. A lock with no refresh forR74_LOCK_TTL(120 s) belonged to a crashed runner and is broken with a warning.rollback-prefix, because arm's own leftover cleanup deletes those.ROLLBACK_PEER_PASSWORD). It now also creates and deletes the lock script there, which the terraform group allows.A tofu-controller
dependsOnbetween the two Terraform objects would not close this. Both objects see the new revision together, and the dependency still reads Ready from the previous revision.Sim results, 2026-11-19
sim/rollback/run.shon CHR 7.25.1, N=180 s./tmp/opencode/r74-lock-all.txt)R74_PEER_WAIT=20it refuses while r1 stays armed. After r1's judge, r2 appliesOne run was invalid. I paused the sandbox for about 2 h 40 min during P. On resume the CHR clocks caught up and pending judges fired mid-scenario. Even so, the lock broke the stale holder correctly. P, K and S were rerun on fresh routers and passed. P's sampler now counts a router that doesn't answer for a second as unarmed instead of aborting the run.
shellcheck passes on
arm.shandrun.sh.Order
Merge this before #164: it changes all three router roots and would race otherwise. This PR changes
modules/rollback, so its own merge re-arms all three roots, and the new script already runs in that apply.Not proven
The production runner image (the sim ran the host toolset, not
RUNNER=1), and HTTPS: the lock calls use the same--cacertpath as the peer check.