fix(gateway): don't accept systemd's not-found default for TimeoutStopUSec - #2
Merged
henryberliand-design merged 2 commits intoJul 31, 2026
Conversation
added 2 commits
July 27, 2026 18:41
…pUSec `systemctl show <unit>` never errors for a unit that isn't loaded under the manager you queried -- it returns rc=0 plus the compiled-in template defaults (LoadState=not-found, TimeoutStopUSec=1min 30s). Gateways installed as system-managed units (confirmed live in production with real TimeoutStopSec overrides) had their --user query "succeed" with this bogus default and never reached the system manager holding the real value, producing false-positive timeout-misalignment warnings. Now also fetch LoadState and only trust a TimeoutStopUSec whose unit is actually loaded under the manager that answered.
Unblocks contributor-check on PR #2 — the only failing gate; all 27 substantive checks pass.
henryberliand-design
deleted the
fix/systemd-timing-alignment-not-found-default
branch
July 31, 2026 01:48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
systemctl show <unit>never errors for a unit that isn't loaded under the manager you queried— it returns rc=0 plus the compiled-in template defaults (
LoadState=not-found,TimeoutStopUSec=1min 30s).check_systemd_timing_alignment()ingateway/shutdown_forensics.pyqueried--userfirst and trusted whateverTimeoutStopUSecitgot back without checking
LoadState. Gateways installed as system-managed units (confirmedlive in production, with a real
TimeoutStopSec=240override) had their--userquery "succeed"with the bogus 90s template default and never reached the system manager holding the real value —
producing false-positive timeout-misalignment warnings.
Fix: also fetch
LoadStatealongsideTimeoutStopUSec, and only trust aTimeoutStopUSecreading whose unit is actually
loadedunder the manager that answered. Anot-foundLoadStateis rejected and the check falls through to the next manager (or returns
Noneif genuinelyunmanaged under both).
Related Issue
No tracked issue; found via live forensics on
hermes-apiserver-henry.service.Type of Change
Changes Made
gateway/shutdown_forensics.py:check_systemd_timing_alignment()now fetchesLoadStateand rejects a
TimeoutStopUSecreading whenLoadState != loaded.tests/gateway/test_shutdown_forensics.py: addedTestCheckSystemdTimingAlignmentManagerSelectionwith 3 regression tests:test_uses_real_system_override_not_user_managers_not_found_default— system-managed unitwith a real 240s override is read correctly instead of accepting
--user's bogus 90s default.test_genuinely_unmanaged_unit_is_not_falsely_flagged_as_mismatched— false-positivecontrol: a unit genuinely unmanaged under either manager (
LoadState=not-foundfrom both)returns
None, not a manufactured mismatch. Proves the fix doesn't just relocate the bug.test_unit_genuinely_loaded_under_user_manager_is_accepted_directly— control for thealready-working path.
How to Test
pip install -e .thenpytest tests/gateway/test_shutdown_forensics.py -v— 33 passed(verified fresh on this branch, Python 3.11, 2026-07-28).
gateway/shutdown_forensics.pyagainst the new tests only — 2 of the 3 new tests fail on pre-fix code
(
test_uses_real_system_override_...asserts90.0 == 240.0; the false-positive controlasserts a manufactured mismatch dict
is Noneand fails), confirming the tests actuallydiscriminate the bug rather than being decorative.
systemctl show hermes-apiserver-henry.service --property=TimeoutStopUSecunder--systemreturns the real 240s override; the same unit queried--userreturns the bogus90s template default with
LoadState=not-found.Checklist
Code
fix(gateway):)pytest tests/gateway/test_shutdown_forensics.py -qand all tests passDocumentation & Housekeeping
Screenshots / Logs
See "How to Test" above for the pre-fix vs post-fix pytest evidence.