Repository navigation
tools/lab: host-wide lab id lock; change follows a LAN renumber; scenarios 06 LAN renumber, 07 require_public_ip - #155
Merged
Merged
Conversation
…new address); scenarios 06 LAN renumber, 07 require_public_ip behind CGNAT Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…med, reset takes the id first, lock records written once and only under the flock - change: lan.ip / cookies switch to the new address only after a "confirmed":true answer (or, with --no-confirm, once the router answers there); a failure leaves the lab on the old address - reset takes the id lock before teardown, so two resets of a free id cannot destroy each other's lab - the holder writes its record with one printf (timestamp first); a held lock with an empty record or a dead PID is a takeover in progress: id_guard, status and id_acquire wait for the new record - stale records are emptied only under a short flock (MRLAB_FORCE takeover, MRLAB_FORCE down of another checkout's lab, own stale down) - 07: sessions() prints one number when nothing matches; 06: unused helpers removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…new no longer stretches it) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Host-wide lab id lock (#152). A lab's namespaces (
mrlab<id>-*), taps and QEMU are host-wide while its state lives in each checkout, so two checkouts could take the same id — areset 1in one checkout tore down another agent's running lab.upstarts a holder process (own session, host namespace) thatflocks/run/mrlab/<id>.lockuntildownand writespid=,checkout=,since=into it. Contenders open the file append-only, so they never touch the owner's data; only the winner rewrites it.up down reset isp install lan ssh console api change run reboot powercut) refuses an id held by another checkout, naming the owner and PID.reset/downwere the dangerous ones, not onlyup.statusshows"lock": free | ours | held | stalewithowner/owner_pid.down(stale): the same checkout takes it back; another checkout needsMRLAB_FORCE=1(MRLAB_FORCE=1 lab.sh reset <id>).downempties the file while the holder still has the flock, then stops the holder (verified by name and by its fd on the lock file); the file itself stays, so a contender can never end up locking an unlinked inode.lab.sh changefollows a LAN renumber (#153). When the apply answers withconfirm_ip/confirm_token, the lab records the new router address, the LAN client renews (as a wired PC whose port flaps), and the change is confirmed on the new address with the one-time token; later commands use the new address.Scenarios.
06-lan-renumber: 192.168.1.1/24 → 192.168.1.6/24 → 192.168.2.1/24 through the API — confirmed on the new address, client lease and gateway follow, panel/API on the new address, no rollback after the 120 s window, old addresses removed.07-require-public-ip: PPPoE behind CGNAT withwan[].require_public_ip(gap 30 s) — cron re-check redials, stops after 5 private addresses with a risk event, no further redials, public address once the ISP offers one.README: the quick reference says ids are host-wide, how to check one (
status) and how to take over a stale one; the new scenarios are listed.Verification
tools/ci.sh's invocation (-S warning) and the stricter default onlab.sh,guest/*.sh,scenarios/*.sh: clean.up 7; Bup 7,reset 7,down 7,isp 7 1 dhcp,console 7 true→ all refused with A's checkout and holder PID; A's lab untouched (QEMU, 4 namespaces). Bstatus 7shows"lock":"held"and A as the owner.down 7→ lock file empty, no holder → Bup 7succeeds.up 7refused (stale, MRLAB_FORCE hint) →MRLAB_FORCE=1Areset 7takes over. A's own holder killed → Aup 7takes it back without force.up 8at the same time, 8 rounds (after fixing a race the first rounds found: a loser that saw the lock already held treated it as its own): every round exactly one winner and one holder, the loser refused naming the owner.run 7 01-fresh-dhcp6/6 andrun 8 06-lan-renumber14/14 in parallel; Bup 8refused meanwhile; both locks free and no holders afterwards (the scenario's exit trap runsdown).mr doctorby design; the stop is the risk event) — that line is a recorded diagnostic now.Closes #152
🤖 Generated with Claude Code