From c98ee7a82d671140ef753b507974e921fa042f95 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 30 Aug 2026 19:47:03 +0200 Subject: [PATCH] A machine that fell behind catches up without being named Broken with a package that does not exist, so the failure is real and fixable. The mesh reports it failed; the resources that could be applied were, because one broken thing no longer blocks the rest; `push --behind` names that machine and not the one that is fine; the module is corrected; and the machine recovers with nobody naming it. And with nothing behind, it says so rather than doing nothing quietly. --- test/integration/mesh.test.ts | 44 +++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/test/integration/mesh.test.ts b/test/integration/mesh.test.ts index f277d16..95223a5 100644 --- a/test/integration/mesh.test.ts +++ b/test/integration/mesh.test.ts @@ -340,3 +340,47 @@ test("a machine keeps what it was given when the mesh says nothing about it", { assert.ok((await on("laptop", `grep -q anchor.internal /etc/hosts`)).ok, "the mesh's names are gone"); }); + +test("a machine that fell behind catches up without being named", { skip, timeout: 900_000 }, async () => { + // `status` says which machines are not doing what they were told; something has to act on it. + // `push --behind` is that something, and it is a command rather than a timer to begin with — + // a scheduler is then a scheduler over this, rather than a second path to the same act. + + // Break one machine, in a way that is fixable: a package that does not exist yet. + await must("anchor", `printf %s '{"module":"fixable","version":"1","resources":[` + + `{"id":"pkg","type":"package","package":"a-package-that-does-not-exist-yet"},` + + `{"id":"note","type":"file","path":"/etc/mesh-fixable","content":"here"}]}' > /tmp/fix.json`); + await must("anchor", `docker cp /tmp/fix.json mesh-control:/fix.json`); + await mesh("module add /fix.json"); + await mesh("assign laptop fixable"); + await mesh("push laptop"); + await new Promise((r) => setTimeout(r, 8000)); + + assert.match(await mesh("status"), /laptop\s+failed/, "the machine did not report a failure"); + // And the resources that COULD be applied were — one broken thing no longer blocks the rest + // (novox/hq 04-ISSUES/011). + assert.ok((await on("laptop", `test -f /etc/mesh-fixable`)).ok, + "a resource after the failing one was never attempted"); + + // Nothing is behind on the other machine, so nothing is pushed to it. + const named = await mesh("push --behind"); + assert.match(named, /laptop/, named); + assert.doesNotMatch(named, /sent anchor/, `a machine that was fine was pushed to:\n${named}`); + + // Fix the cause, the way somebody would: the module stops asking for the impossible thing. + await must("anchor", `printf %s '{"module":"fixable","version":"1","resources":[` + + `{"id":"note","type":"file","path":"/etc/mesh-fixable","content":"here"}]}' > /tmp/fix.json`); + await must("anchor", `docker cp /tmp/fix.json mesh-control:/fix.json`); + await mesh("module add /fix.json"); + + // And nobody names the machine. + await mesh("push --behind"); + await new Promise((r) => setTimeout(r, 8000)); + + const after = await mesh("status"); + assert.doesNotMatch(after, /laptop\s+(failed|refused)/, + `the machine did not recover:\n${after}`); + + // With nothing behind, it says so rather than doing nothing quietly. + assert.match(await mesh("push --behind"), /every machine is doing what it was told/); +});