fix(gateway): skip systemd timing check for non-loaded units - #36766
fix(gateway): skip systemd timing check for non-loaded units#36766liuhao1024 wants to merge 1 commit into
Conversation
Fixes NousResearch#36755 When the gateway runs as a system-level unit but the user manager is reachable (e.g., with XDG_RUNTIME_DIR set for rootless podman), `systemctl --user show` returns rc=0 and emits compiled-in defaults (TimeoutStopUSec=1min 30s) for nonexistent units. This produces a false-positive 'stale unit' warning even when the system unit has the correct TimeoutStopSec. Add LoadState to the systemctl query and skip iterations where LoadState != loaded. Also update the warning message to reference the correct CLI command (hermes gateway install --replace, not hermes gateway service install --replace).
mxnstrexgl
left a comment
There was a problem hiding this comment.
🤖 Automated PR Review
Security Scan
- ✓ No hardcoded secrets, injection sinks, unsafe deserialization, or dependency red flags found by this automated scan.
Code Quality
- ✓ No blocking code-quality issues found by this automated scan.
- ℹ️ No test file changes detected; verify existing coverage exercises this behavior.
Summary
Status: APPROVE — security findings: 0, quality suggestions: 0.
Automated review; raw diff content intentionally omitted.
|
Verified this fix in production on v0.18.0 (Ubuntu 24.04, systemd 255): a root system unit installed by One rebase note: the |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for isolating the systemd manager-selection failure. The LoadState gate addresses the current-main path in gateway/shutdown_forensics.py:367-389, which otherwise accepts the first user-manager timeout before consulting the system manager.
Problems
gateway/run.py:3994restoreshermes gateway install --replace. Current main intentionally useshermes gateway install --forceatgateway/run.py:6739; commitc9df4bc094fbrecords that the old service/install--replacecommand does not exist.- No regression test accompanies the gate. The existing alignment coverage at
tests/gateway/test_shutdown_forensics.py:237-250covers only early-return paths, not aLoadState=not-founduser response followed by a loaded system response.
Suggested changes
- Salvage only the
gateway/shutdown_forensics.pybehavior and retain current main's--forcewarning text. - Add a mocked two-manager regression test proving the loaded system unit is selected after the non-loaded user unit is skipped.
Automated hermes-sweeper review.
| "Stale systemd unit detected: %s has TimeoutStopSec=%.0fs but " | ||
| "drain_timeout=%.0fs (expected >=%.0fs). systemd may SIGKILL the " | ||
| "gateway mid-drain. Run `hermes gateway service install --replace` " | ||
| "gateway mid-drain. Run `hermes gateway install --replace` " |
There was a problem hiding this comment.
--replace is stale here: commit c9df4bc094fb intentionally changed this remediation to hermes gateway install --force because the former command no longer exists. Please omit this hunk during salvage and retain current main's wording.
What does this PR do?
Fixes false-positive 'stale systemd unit' warning when the gateway runs as a system-level unit but the user manager is reachable. The warning would appear even when the system unit has the correct TimeoutStopSec because
systemctl --user showreturns compiled-in defaults (90s) for nonexistent units.Related Issue
Fixes #36755
Type of Change
Changes Made
gateway/shutdown_forensics.py: Add LoadState to systemctl query and skip iterations where LoadState != loadedgateway/run.py: Update warning message to reference correct CLI commandHow to Test
Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests pass (1 pre-existing flaky test failure unrelated to this change)Documentation & 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/ACode Intelligence
gateway/shutdown_forensics.py:check_systemd_timing_alignment()(callers:gateway/run.py:check_systemd_timing_alignment())