mirror of
https://github.com/hasso5703/alzeo.git
synced 2026-12-05 20:34:17 +01:00
- C1: sampler() isolates each collector (one exception ended the tier's thread; the 1 s tier carries the memory floor's abort), collect_jobs has its @guard, and JOBS is read and changed under a lock (22 snapshot errors in 1.3 s under churn before) - C2: /api/state is serialised under STATE_LOCK and written outside it; a reader that stopped reading held every sampler for the write - C3: jobs run in their own process group with a deadline that does not wait for output; the group gets TERM then KILL. switch-model.sh's download runs with --init: measured, without it the container outlived a TERM and a KILL of its docker client (python3 as PID 1 ignores TERM) - C4: the relay closes the browser's connection when opencode cuts a fixed-length answer short, and a cut HTML document is a 502 - C5: install-agent.sh reads both ports, the relay's address and the service PATH back from the installed units; the environment still wins Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
1.4 KiB
Python
32 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""A switch the cockpit stops takes its download with it.
|
|
|
|
The cockpit stops a job that overruns its timeout with a TERM to the job's whole process
|
|
group (since v1.18.7; it used to kill only the job's own process). For a switch, that
|
|
group holds switch-model.sh and the `docker run` that downloads the checkpoint, and
|
|
docker run passes the TERM on to its container, where python3 is PID 1: a PID 1 with no
|
|
handler for a signal ignores it. Measured on the reference box, 2026-09-24, with the
|
|
pinned flash image: without --init the container outlived the TERM, then a SIGKILL of
|
|
its docker client, and went on with nobody attached; with --init both were gone within
|
|
6 s. This keeps the flag on every container switch-model.sh runs.
|
|
"""
|
|
import pathlib
|
|
import re
|
|
import unittest
|
|
|
|
REPO = pathlib.Path(__file__).resolve().parents[1]
|
|
TEXT = (REPO / "switch-model.sh").read_text()
|
|
|
|
|
|
class EveryContainerOfASwitchCanBeStopped(unittest.TestCase):
|
|
def test_every_docker_run_has_an_init(self):
|
|
# a command, not a comment that names one: at the start of a line
|
|
runs = [m.group(0) for m in re.finditer(r"(?m)^[ \t]*docker run(?:[^\n]*\\\n)*[^\n]*", TEXT)]
|
|
self.assertTrue(runs, "switch-model.sh runs no container any more: this test is stale")
|
|
for run in runs:
|
|
self.assertIn("--init", run.split("--entrypoint")[0], run[:160])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main(verbosity=2)
|