ODS V3 Pre-Release: Public testing and refinement ahead of the official V3 launch. Turn your PC, Mac, or Linux box into a private AI server.
Python ai-agentsamdcomfyuidockerllama-cppllmlocal-ain8nnvidiaopen-webuiragself-hostedspeech-to-textstrix-halotext-to-speechworkflow-automation
fix(pixel): restart the preview inspection broker when it cannot start (#8177)
Mike Bradleyec80800f3e6e
diff --git a/ods/extensions/services/pixel-agent/host/preview-inspection-protocol.md b/ods/extensions/services/pixel-agent/host/preview-inspection-protocol.mdindex df7ac01c1..12456d3c6 100644--- a/ods/extensions/services/pixel-agent/host/preview-inspection-protocol.md+++ b/ods/extensions/services/pixel-agent/host/preview-inspection-protocol.md@@ -258,6 +258,9 @@ socket, never ambient Docker context/environment.CLI: `serve` accepts authenticated local requests; `request` runs the fixednative helper request; `health` verifies the installed image identity withoutexecuting a site; `export` reads only `/previews` in the publisher container.+`request`, `health` and `export` print one JSON result and exit 0, also on+failure. `serve` prints its failure receipt and exits non-zero when it cannot+start or stops with an error, so the unit's `Restart=on-failure` retries it.Native export uses fixed `docker exec` argv and actual container UID ownership.Export grants the publisher no Docker authority. Snapshots are reopened withthe publisher's stable no-symlink file checks and rehashed, then rehashed againdiff --git a/ods/extensions/services/pixel-agent/host/preview_inspection.py b/ods/extensions/services/pixel-agent/host/preview_inspection.pyindex 7eb73d877..a7a84b8a6 100644--- a/ods/extensions/services/pixel-agent/host/preview_inspection.py+++ b/ods/extensions/services/pixel-agent/host/preview_inspection.py@@ -520,6 +520,13 @@ def main():raise Invalid("invalid invocation")except Exception:result = failure("unavailable", request)+ if sys.argv[1:] == ["serve"]:+ # No caller reads a serving broker's receipt, and systemd restarts+ # the broker only after a failed exit. A broker that cannot start+ # yet, as during boot, or that stops with an error logs the receipt+ # and crashes with its cause so Restart=on-failure retries it.+ sys.stdout.buffer.write(canonical(result) + b"\n")+ raisesys.stdout.buffer.write(canonical(result) + b"\n")diff --git a/ods/tests/ci-suite.txt b/ods/tests/ci-suite.txtindex 9c67fbe12..2e9396529 100644--- a/ods/tests/ci-suite.txt+++ b/ods/tests/ci-suite.txt@@ -299,6 +299,7 @@ tests/test_pixel_release_resume.pytests/test_pixel_source_upgrade_diagnostics.pytests/test_pixel_verify_lifecycle.pytests/test_portal_identity.py+tests/test_preview_inspection.pytests/test_preview_inspection_delayed_entrance.pytests/test_preview_inspection_paint.pytests/test_preview_inspection_press.pydiff --git a/ods/tests/test_preview_inspection.py b/ods/tests/test_preview_inspection.pyindex b10253753..4f6865be0 100644--- a/ods/tests/test_preview_inspection.py+++ b/ods/tests/test_preview_inspection.py@@ -340,6 +340,46 @@ class ProtocolTests(unittest.TestCase):with self.assertRaises(publisher.PreviewError):broker.snapshot_bundle(previews, request)+ def test_serve_exits_nonzero_when_it_cannot_start(self):+ # Seen live under WSL2 + Docker Desktop: after the VM restarted, the+ # broker could not start, printed its receipt and exited 0. Its unit+ # restarts only on failure, so the broker stayed down and every Portal+ # build failed browser inspection until a manual restart.+ import subprocess++ # Paths that are not ready, as during boot. The child never reads the+ # installed configuration or replaces a live broker's socket.+ child = (+ "import pathlib, sys\n"+ "sys.path.insert(0, sys.argv[1])\n"+ "import preview_inspection as broker\n"+ "broker.CONFIG = pathlib.Path(sys.argv[2], 'missing.json')\n"+ "broker.SOCKET = pathlib.Path(sys.argv[2], 'run', 'control.sock')\n"+ "sys.argv[1:] = sys.argv[3:]\n"+ "raise SystemExit(broker.main())\n"+ )+ host = str(Path(broker.__file__).resolve().parent)+ with tempfile.TemporaryDirectory() as tmp:++ def run(mode):+ return subprocess.run(+ [sys.executable, "-B", "-c", child, host, tmp, mode],+ stdin=subprocess.DEVNULL,+ capture_output=True,+ timeout=30,+ )++ serving = run("serve")+ # Restart=on-failure retries an exit status above 0; the journal+ # keeps the receipt and names the cause.+ self.assertGreater(serving.returncode, 0, serving.stderr.decode(errors="replace"))+ self.assertEqual(protocol.strict_json(serving.stdout)["errorCode"], "unavailable")+ self.assertIn(b"missing.json", serving.stderr)+ # Callers parse the other modes' receipt, which still exits 0.+ health = run("health")+ self.assertEqual(health.returncode, 0, health.stderr.decode(errors="replace"))+ self.assertEqual(protocol.strict_json(health.stdout)["errorCode"], "unavailable")+STORAGE_ERROR = ("Failed to read the 'sessionStorage' property from 'Window': The document "