fix(migration): apply the reviewed reservation plan, not a recomputed one
This caused a real outage. unifi-reserve-all.py recomputed its plan at --apply time by re-reading stat/sta, so a client that renewed between the dry run and the apply was pinned to whatever transient address it happened to hold at that instant. worker1-k8s0 was reviewed at 192.168.8.13 and written as 192.168.8.242. On its next reboot it could not get an address at all, taking a k8s node down. A plan that gets reviewed and a plan that gets applied must be the same object. The dry run now WRITES the plan to a file and --apply READS it and applies exactly that, reporting any client whose current address has since drifted rather than silently preferring the new value. 1 of 51 diverged; the rest were verified against the reviewed list and were correct. worker1 has been restored to .13 and confirmed: DHCPOFFER for its own MAC returns 192.168.8.13, and the node is up with a full lease and working internet. The second half of the outage was drift between controller and device: the USG was still running config from ~16h before these changes, so the controller looked perfectly correct while the gateway handed out something else. Writing the controller is only half the job, so the script now says so explicitly and gives the force-provision and DHCP-probe commands to verify with. `nmap --script broadcast-dhcp-discover --script-args broadcast-dhcp-discover.mac=...` is the way to prove a specific reservation is live without disturbing the client -- it elicits an OFFER without ever sending a REQUEST. _unifi.py gains post() for device commands. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DMVzWZgiKW2wquf5z8S1yH
This commit is contained in:
@@ -51,6 +51,20 @@ def get(opener, base, site, path):
|
||||
return {"__error__": f"{type(exc).__name__}: {exc}"}
|
||||
|
||||
|
||||
def post(opener, base, site, path, payload):
|
||||
"""POST to /api/s/<site>/<path> -- used for device commands (cmd/devmgr)."""
|
||||
req = urllib.request.Request(
|
||||
f"{base}/api/s/{site}/{path}",
|
||||
data=json.dumps(payload).encode(),
|
||||
headers={"Content-Type": "application/json"}, method="POST")
|
||||
try:
|
||||
return json.loads(opener.open(req, timeout=30).read()).get("data", [])
|
||||
except urllib.error.HTTPError as exc:
|
||||
return {"__error__": f"HTTP {exc.code}: {exc.read()[:300].decode(errors='replace')}"}
|
||||
except Exception as exc:
|
||||
return {"__error__": f"{type(exc).__name__}: {exc}"}
|
||||
|
||||
|
||||
def put(opener, base, site, path, payload):
|
||||
"""PUT to /api/s/<site>/<path>. Returns the `data` list or an __error__ dict.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user