diff --git a/dashboard/pyspy-scheduler.sh b/dashboard/pyspy-scheduler.sh index 91c2cc45..b7ff802d 100755 --- a/dashboard/pyspy-scheduler.sh +++ b/dashboard/pyspy-scheduler.sh @@ -12,7 +12,7 @@ done # What went wrong goes to stderr, and only a dump to stdout: the cockpit saved this line as # "scheduler stacks" when it came on stdout (found in review, 2026-09-24). [ -n "$PYSPY" ] || { echo "py-spy not installed (pip install py-spy, or copy the binary to /usr/local/bin/py-spy)" >&2; exit 3; } -for cont in qwen38-flash qwen38-sglang; do +for cont in qwen38-flash qwen38-sglang qwen38-lfm25 qwen38-inkling; do pid="$(docker top "$cont" -o pid,comm 2>/dev/null | awk '/schedul/{print $1}' | head -1 || true)" if [ -n "$pid" ]; then echo "== $cont scheduler pid $pid, state $(awk '{print $3}' /proc/$pid/stat 2>/dev/null || echo ?) ==" diff --git a/tests/test_pyspy_forensics.py b/tests/test_pyspy_forensics.py index c85999c1..36ee8081 100644 --- a/tests/test_pyspy_forensics.py +++ b/tests/test_pyspy_forensics.py @@ -6,19 +6,25 @@ running") on stdout, and the cockpit took any text back, stderr merged in, for a the complaint was saved as wedge-*.txt under "scheduler stacks saved" (found in review, 2026-09-24). The wrapper runs here from a copy whose py-spy and docker are stubs.""" import pathlib +import re import subprocess +import sys import tempfile import unittest REPO = pathlib.Path(__file__).resolve().parents[1] +sys.path.insert(0, str(REPO)) +import lane_registry # noqa: E402 + WRAPPER = (REPO / "dashboard" / "pyspy-scheduler.sh").read_text() COCKPIT = (REPO / "dashboard" / "cockpit.py").read_text() -def run(pyspy_exists): +def run(pyspy_exists, container=""): d = pathlib.Path(tempfile.mkdtemp(prefix="pyspy-")) (d / "bin").mkdir() - (d / "bin" / "docker").write_text("#!/bin/sh\nexit 1\n") # no container answers + # no container answers, or the one that serves, with its scheduler's process (comm is 15 characters) + (d / "bin" / "docker").write_text(f'#!/bin/sh\n[ "$1 $2" = "top {container}" ] || exit 1\nprintf "PID COMMAND\\n1 python3\\n2 sglang::schedul\\n"\n') (d / "bin" / "docker").chmod(0o755) fake = d / "py-spy" if pyspy_exists: @@ -45,6 +51,24 @@ class TheWrapperKeepsStdoutForTheDump(unittest.TestCase): self.assertIn("no serving container running", err) +class EverySGLangLanesSchedulerIsDumped(unittest.TestCase): + """The wrapper named two containers: a wedge of the LFM2.5 or the Inkling lane, which the same probe and the same + autoheal watch, left "no serving container running" for evidence (found in an audit, 2026-11-30).""" + CONTAINERS = {f["unit"][:-len(".service")] for f in lane_registry.LANES.values() if f["engine"] == "sglang"} + + def test_each_of_them_is_found(self): + for cont in sorted(self.CONTAINERS): + with self.subTest(container=cont): + rc, out, err = run(True, cont) + self.assertEqual((rc, out.splitlines()[-1:]), (0, ["stacks"]), err) + self.assertIn(f"== {cont} scheduler pid 2", out) + + def test_the_wrapper_and_the_cockpits_probe_name_the_same(self): + named = set(re.search(r"^for cont in (.+); do$", WRAPPER, re.M).group(1).split()) + probed = set(re.findall(r'"(qwen38-[a-z0-9-]+)"', re.search(r"^SGL_CONTAINERS = \((.+?)\)", COCKPIT, re.M).group(1))) + self.assertEqual((named, probed), (self.CONTAINERS, self.CONTAINERS)) + + class TheCockpitReadsTheStatus(unittest.TestCase): def test_a_dump_is_saved_only_on_success(self): i = COCKPIT.index('"/usr/local/bin/qwen38-pyspy-scheduler"]')