feat(gateway): support custom systemd unit names - #76461
Conversation
teknium1
left a comment
There was a problem hiding this comment.
Thanks for covering the lifecycle, update, and system-service paths for a real current-main gap: hermes_cli/gateway.py:1798-1815 still supports only profile-derived systemd names.
Problems
hermes_cli/gateway.py:1039-1043accepts an existing custom unit using only its unit name and Hermes ExecStart marker. It does not compare persistedHERMES_HOME. Therefore two profiles configured with the same custom name are treated as the same owner:systemd_install()proceeds through that check athermes_cli/gateway.py:3639-3646, while profile cleanup can stop and unlink the same unit athermes_cli/profiles.py:1719-1734.
Suggested changes
- Include the expected persisted
HERMES_HOMEin custom-unit ownership validation, and reject cross-profile collisions across install, refresh, uninstall, and cleanup. - Add a two-profile same-custom-name regression test proving the original unit remains intact.
Automated hermes-sweeper review.
| return ( | ||
| unit_path.name == f"{persisted}.service" | ||
| and persisted == expected_name | ||
| and _systemd_unit_invokes_hermes_gateway(unit_text) |
There was a problem hiding this comment.
This ownership predicate validates only the unit name and Hermes-looking ExecStart. It must also require the persisted HERMES_HOME to match the profile being operated on; otherwise two profiles configured with the same custom name each pass this check, and the later install/refresh can overwrite the first profile’s service.
|
Closing this PR because the arbitrary The actual requirement is to prevent collisions when isolated Hermes roots use the same profile name while keeping their systemd units inside the Hermes-owned namespace. The review also exposed an ownership gap: different I’m going back to a smaller design where Hermes composes the unit name from a validated instance scope and profile, preserves the This PR will remain closed rather than being expanded in place. |
What does this PR do?
Adds a generic
gateway.systemd_unit_nameconfiguration option for Linux deployments that need a stable gateway systemd unit name instead of the default profile-derived name.The configured name accepts an optional
.servicesuffix, is normalized to a base name, and is validated before it can be used in a unit path or lifecycle command. The resolved name is persisted in generated user and system units so install, status, restart, update, uninstall, profile cleanup, PID discovery, and child-triggered lifecycle operations all address the same unit. Existing systemd hardening and non-Linux behavior remain unchanged.Related Issue
Type of Change
Changes Made
gateway.systemd_unit_nameconfig key inhermes_cli/config_defaults.pyand unit-name resolution inhermes_cli/gateway.py.website/docs/user-guide/messaging/index.mdandcli-config.yaml.example.How to Test
Run the affected gateway and systemd tests:
Expected: all selected tests pass.
Run lint and the cross-platform guard:
Run the full test suite:
Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests pass23,827 passed, 17 failed. A clean run at that target commit completed with23,763 passed, 17 failed, with the same failures in the same 9 unrelated test files.7f4d15515, the branch run completed with23,993 passed, 17 failed. Clean currentmainreproduced 16 failures in the same 8 unrelated files. The one additional failure was in untouchedtests/test_tui_gateway_server.py; its focused rerun passed all 501 tests.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 — N/A; no architecture or workflow changesScreenshots / Logs
N/A — no UI changes.