fix(gateway): stop stale systemd timeout mismatch loop - #41525
Conversation
|
✅ Verified — stale systemd timeout mismatch now prevents SIGKILL mid-drain Reviewed the diff for the gateway startup refusal logic and
The fix correctly converts a warning into a hard gate, preventing systemd's |
|
Thanks for this — your diagnosis was spot-on and matched what we found. We took a different fix direction in #54066: rather than make systemd's The "refuse to start + auto-stop the misaligned unit" behavior here is a meaningful design change with real downside risk (a detection false-positive turns a cosmetic warning into a hard outage), so we opted not to take it. Closing in favor of #54066, which resolves the crash loop at the root. Appreciate the thorough write-up and tests. |
What does this PR do?
When the gateway detects a stale systemd unit whose
TimeoutStopSecis shorter than the configured drain timeout headroom, it now fails startup loudly instead of only logging a warning. The startup error uses the real repair command for the installed unit scope, writesstartup_failedruntime status, and best-effort stops the current unit so a misconfigured service does not immediately re-enter the same crash loop.Related Issue
Fixes #31981
Type of Change
Changes Made
gateway/run.py: turn a stale systemd drain-timeout mismatch into a startup-blocking error, print the remediation message to stderr, persiststartup_failed, and best-effort stop the misaligned unit.gateway/shutdown_forensics.py: return the detected systemd scope plus the correct repair command, and add a helper to stop the current systemd unit without shelling through unsafe string interpolation.tests/gateway/test_runner_startup_failures.py: cover the new startup refusal path and verify the unit-stop attempt plus runtime-status update.tests/gateway/test_shutdown_forensics.py: cover scope-aware repair command generation and the new unit-stop helper.How to Test
pytest tests/gateway/test_shutdown_forensics.py tests/gateway/test_runner_startup_failures.py tests/gateway/test_restart_drain.py tests/gateway/test_runner_fatal_adapter.py -q.python scripts/check-windows-footguns.py gateway/run.py gateway/shutdown_forensics.py tests/gateway/test_runner_startup_failures.py tests/gateway/test_shutdown_forensics.py.ruff check gateway/run.py gateway/shutdown_forensics.py tests/gateway/test_runner_startup_failures.py tests/gateway/test_shutdown_forensics.pyandgit diff --check./opt/homebrew/bin/timeout -k 30 480 sh -c 'pytest tests/ -q -x --timeout=60 "$@"' sh.tests/hermes_cli/test_dashboard_auth_401_reauth.pywithModuleNotFoundError: No module named 'fastapi'in this environment.What platforms tested on
Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
fastapiis unavailable in this environment:tests/hermes_cli/test_dashboard_auth_401_reauth.py->ModuleNotFoundError: No module named 'fastapi'.