refactor(gateway): rename bootstrap's _Supervisor to _DaemonManager
tracker-policy-pr / check-pr (pull_request) Successful in 11s
test / integration-docker (pull_request) Successful in 17s
lint / lint (push) Failing after 53s
test / unit (pull_request) Successful in 2m4s
test / integration-firecracker (pull_request) Successful in 3m32s
test / coverage (pull_request) Successful in 18s
test / publish-infra (pull_request) Has been skipped

The PID-1 process manager in gateway/bootstrap.py was named _Supervisor,
which collided conceptually with the supervise permissions service
(Supervisor / gateway.supervisor). It manages the _DaemonSpec child set,
so _DaemonManager names what it does without the "supervise" echo.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-24 17:08:34 -04:00
parent ce744a85c4
commit 74dc984cf8
2 changed files with 22 additions and 22 deletions
+2 -2
View File
@@ -173,7 +173,7 @@ def _spawn(spec: _DaemonSpec) -> subprocess.Popen[bytes]:
return proc return proc
class _Supervisor: class _DaemonManager:
"""Holds the running children + shutdown state. Pulled out so """Holds the running children + shutdown state. Pulled out so
the test suite can drive it with fake commands.""" the test suite can drive it with fake commands."""
@@ -387,7 +387,7 @@ def main(argv: Sequence[str] | None = None) -> int:
_log("no daemons selected; nothing to do") _log("no daemons selected; nothing to do")
return 0 return 0
sup = _Supervisor(specs) sup = _DaemonManager(specs)
sup.start_all() sup.start_all()
signal.signal(signal.SIGTERM, lambda *_: sup.request_shutdown("SIGTERM")) # type: ignore signal.signal(signal.SIGTERM, lambda *_: sup.request_shutdown("SIGTERM")) # type: ignore
+20 -20
View File
@@ -20,7 +20,7 @@ from unittest.mock import patch
from bot_bottle.gateway.bootstrap import ( from bot_bottle.gateway.bootstrap import (
_DaemonSpec, _DaemonSpec,
_Supervisor, _DaemonManager,
_argv_for_daemon, _argv_for_daemon,
_env_for_daemon, _env_for_daemon,
_selected_daemons, _selected_daemons,
@@ -169,7 +169,7 @@ class TestDaemonArgv(unittest.TestCase):
class TestSupervisor(unittest.TestCase): class TestSupervisor(unittest.TestCase):
"""End-to-end: drive `_Supervisor` directly with fake commands. """End-to-end: drive `_DaemonManager` directly with fake commands.
We don't go through `main()` because main installs signal We don't go through `main()` because main installs signal
handlers process-wide, which collides with the test runner.""" handlers process-wide, which collides with the test runner."""
@@ -177,7 +177,7 @@ class TestSupervisor(unittest.TestCase):
warnings.simplefilter("error", ResourceWarning) warnings.simplefilter("error", ResourceWarning)
self.addCleanup(warnings.resetwarnings) self.addCleanup(warnings.resetwarnings)
def _drive(self, sup: _Supervisor, max_wait_s: float = 6.0) -> int: def _drive(self, sup: _DaemonManager, max_wait_s: float = 6.0) -> int:
deadline = time.monotonic() + max_wait_s deadline = time.monotonic() + max_wait_s
while not sup.tick(): while not sup.tick():
if time.monotonic() > deadline: if time.monotonic() > deadline:
@@ -193,7 +193,7 @@ class TestSupervisor(unittest.TestCase):
_DaemonSpec("a", ("/bin/sh", "-c", ":")), _DaemonSpec("a", ("/bin/sh", "-c", ":")),
_DaemonSpec("b", ("/bin/sh", "-c", ":")), _DaemonSpec("b", ("/bin/sh", "-c", ":")),
] ]
sup = _Supervisor(specs) sup = _DaemonManager(specs)
sup.start_all() sup.start_all()
time.sleep(0.1) time.sleep(0.1)
sup.request_shutdown(reason="test") sup.request_shutdown(reason="test")
@@ -209,7 +209,7 @@ class TestSupervisor(unittest.TestCase):
_DaemonSpec("crasher", ("/bin/sh", "-c", "exit 1")), _DaemonSpec("crasher", ("/bin/sh", "-c", "exit 1")),
_DaemonSpec("longrun", (SLEEP, "30")), _DaemonSpec("longrun", (SLEEP, "30")),
] ]
sup = _Supervisor(specs) sup = _DaemonManager(specs)
sup.start_all() sup.start_all()
original_pid = sup.procs[0][1].pid original_pid = sup.procs[0][1].pid
@@ -235,7 +235,7 @@ class TestSupervisor(unittest.TestCase):
def test_single_daemon_crash_is_restarted_before_tick_completes(self): def test_single_daemon_crash_is_restarted_before_tick_completes(self):
specs = [_DaemonSpec("crasher", ("/bin/sh", "-c", "exit 1"))] specs = [_DaemonSpec("crasher", ("/bin/sh", "-c", "exit 1"))]
sup = _Supervisor(specs) sup = _DaemonManager(specs)
sup.start_all() sup.start_all()
original_pid = sup.procs[0][1].pid original_pid = sup.procs[0][1].pid
time.sleep(0.1) time.sleep(0.1)
@@ -259,7 +259,7 @@ class TestSupervisor(unittest.TestCase):
_DaemonSpec("crasher", ("/bin/sh", "-c", "exit 1")), _DaemonSpec("crasher", ("/bin/sh", "-c", "exit 1")),
_DaemonSpec("longrun", (SLEEP, "30")), _DaemonSpec("longrun", (SLEEP, "30")),
] ]
sup = _Supervisor(specs) sup = _DaemonManager(specs)
sup.start_all() sup.start_all()
time.sleep(0.3) # let crasher die time.sleep(0.3) # let crasher die
sup.request_shutdown(reason="test") sup.request_shutdown(reason="test")
@@ -271,7 +271,7 @@ class TestSupervisor(unittest.TestCase):
_DaemonSpec("a", ("/bin/sh", "-c", "exit 0")), _DaemonSpec("a", ("/bin/sh", "-c", "exit 0")),
_DaemonSpec("b", ("/bin/sh", "-c", "exit 2")), _DaemonSpec("b", ("/bin/sh", "-c", "exit 2")),
] ]
sup = _Supervisor(specs) sup = _DaemonManager(specs)
sup.start_all() sup.start_all()
original_pids = [p.pid for _, p in sup.procs] original_pids = [p.pid for _, p in sup.procs]
time.sleep(0.1) time.sleep(0.1)
@@ -309,7 +309,7 @@ class TestSupervisor(unittest.TestCase):
_DaemonSpec("egress", sighup_marker), _DaemonSpec("egress", sighup_marker),
_DaemonSpec("other", (SLEEP, "30")), _DaemonSpec("other", (SLEEP, "30")),
] ]
sup = _Supervisor(specs) sup = _DaemonManager(specs)
sup.start_all() sup.start_all()
time.sleep(0.3) # let Python install the handler time.sleep(0.3) # let Python install the handler
@@ -331,7 +331,7 @@ class TestSupervisor(unittest.TestCase):
def test_forward_signal_unknown_daemon_no_op(self): def test_forward_signal_unknown_daemon_no_op(self):
specs = [_DaemonSpec("a", (SLEEP, "30"))] specs = [_DaemonSpec("a", (SLEEP, "30"))]
sup = _Supervisor(specs) sup = _DaemonManager(specs)
sup.start_all() sup.start_all()
delivered = sup.forward_signal(signal.SIGHUP, "ghost") delivered = sup.forward_signal(signal.SIGHUP, "ghost")
self.assertFalse(delivered) self.assertFalse(delivered)
@@ -345,7 +345,7 @@ class TestSupervisor(unittest.TestCase):
_DaemonSpec("git-gate", (SLEEP, "30")), _DaemonSpec("git-gate", (SLEEP, "30")),
_DaemonSpec("supervise", (SLEEP, "30")), _DaemonSpec("supervise", (SLEEP, "30")),
] ]
sup = _Supervisor(specs) sup = _DaemonManager(specs)
sup.start_all() sup.start_all()
time.sleep(0.1) time.sleep(0.1)
old_git_gate_pid = sup.procs[0][1].pid old_git_gate_pid = sup.procs[0][1].pid
@@ -370,7 +370,7 @@ class TestSupervisor(unittest.TestCase):
_DaemonSpec("git-gate", (SLEEP, "30")), _DaemonSpec("git-gate", (SLEEP, "30")),
_DaemonSpec("supervise", (SLEEP, "30")), _DaemonSpec("supervise", (SLEEP, "30")),
] ]
sup = _Supervisor(specs) sup = _DaemonManager(specs)
sup.start_all() sup.start_all()
time.sleep(0.1) time.sleep(0.1)
old_git_gate_pid = sup.procs[0][1].pid old_git_gate_pid = sup.procs[0][1].pid
@@ -392,7 +392,7 @@ class TestSupervisor(unittest.TestCase):
def test_repeated_restart_requests_coalesce(self): def test_repeated_restart_requests_coalesce(self):
specs = [_DaemonSpec("git-gate", (SLEEP, "30"))] specs = [_DaemonSpec("git-gate", (SLEEP, "30"))]
sup = _Supervisor(specs) sup = _DaemonManager(specs)
sup.start_all() sup.start_all()
time.sleep(0.1) time.sleep(0.1)
@@ -415,7 +415,7 @@ class TestSupervisor(unittest.TestCase):
def test_request_restart_unknown_daemon_no_op(self): def test_request_restart_unknown_daemon_no_op(self):
specs = [_DaemonSpec("a", (SLEEP, "30"))] specs = [_DaemonSpec("a", (SLEEP, "30"))]
sup = _Supervisor(specs) sup = _DaemonManager(specs)
sup.start_all() sup.start_all()
ok = sup.request_restart("ghost") ok = sup.request_restart("ghost")
self.assertFalse(ok) self.assertFalse(ok)
@@ -425,7 +425,7 @@ class TestSupervisor(unittest.TestCase):
def test_restart_unknown_daemon_no_op(self): def test_restart_unknown_daemon_no_op(self):
specs = [_DaemonSpec("a", (SLEEP, "30"))] specs = [_DaemonSpec("a", (SLEEP, "30"))]
sup = _Supervisor(specs) sup = _DaemonManager(specs)
sup.start_all() sup.start_all()
ok = sup.restart_daemon("ghost") ok = sup.restart_daemon("ghost")
self.assertFalse(ok) self.assertFalse(ok)
@@ -434,7 +434,7 @@ class TestSupervisor(unittest.TestCase):
def test_restart_during_shutdown_is_no_op(self): def test_restart_during_shutdown_is_no_op(self):
specs = [_DaemonSpec("git-gate", (SLEEP, "30"))] specs = [_DaemonSpec("git-gate", (SLEEP, "30"))]
sup = _Supervisor(specs) sup = _DaemonManager(specs)
sup.start_all() sup.start_all()
sup.request_shutdown(reason="test") sup.request_shutdown(reason="test")
ok = sup.restart_daemon("git-gate") ok = sup.restart_daemon("git-gate")
@@ -444,7 +444,7 @@ class TestSupervisor(unittest.TestCase):
def test_pending_restart_dropped_during_shutdown(self): def test_pending_restart_dropped_during_shutdown(self):
specs = [_DaemonSpec("git-gate", (SLEEP, "30"))] specs = [_DaemonSpec("git-gate", (SLEEP, "30"))]
sup = _Supervisor(specs) sup = _DaemonManager(specs)
sup.start_all() sup.start_all()
time.sleep(0.1) time.sleep(0.1)
old_pid = sup.procs[0][1].pid old_pid = sup.procs[0][1].pid
@@ -464,7 +464,7 @@ class TestSupervisor(unittest.TestCase):
_DaemonSpec("a", (SLEEP, "60")), _DaemonSpec("a", (SLEEP, "60")),
_DaemonSpec("b", (SLEEP, "60")), _DaemonSpec("b", (SLEEP, "60")),
] ]
sup = _Supervisor(specs) sup = _DaemonManager(specs)
sup.start_all() sup.start_all()
time.sleep(0.2) # let them actually start time.sleep(0.2) # let them actually start
sup.request_shutdown(reason="test") sup.request_shutdown(reason="test")
@@ -484,7 +484,7 @@ class TestSupervisor(unittest.TestCase):
"trap '' TERM; sleep 30", "trap '' TERM; sleep 30",
) )
specs = [_DaemonSpec("stubborn", ignore_term)] specs = [_DaemonSpec("stubborn", ignore_term)]
sup = _Supervisor(specs) sup = _DaemonManager(specs)
sup.start_all() sup.start_all()
time.sleep(0.3) # let `trap` register time.sleep(0.3) # let `trap` register
sup.request_shutdown(reason="test") sup.request_shutdown(reason="test")
@@ -498,7 +498,7 @@ class TestSupervisor(unittest.TestCase):
def test_idempotent_shutdown_requests(self): def test_idempotent_shutdown_requests(self):
specs = [_DaemonSpec("a", (SLEEP, "60"))] specs = [_DaemonSpec("a", (SLEEP, "60"))]
sup = _Supervisor(specs) sup = _DaemonManager(specs)
sup.start_all() sup.start_all()
time.sleep(0.1) time.sleep(0.1)
first_at = None first_at = None