Skip to content

The agent that grows with you

fix(update): tighten gateway-side unit gates to exact/hyphenated shape

Teknium19631b529269
diff --git a/hermes_cli/update_cmd.py b/hermes_cli/update_cmd.py
index bfc56a1ef95..7813722860f 100644
--- a/hermes_cli/update_cmd.py
+++ b/hermes_cli/update_cmd.py
@@ -3897,7 +3897,8 @@ def _for_each_systemd_gateway_unit(
# unrelated ``hermes-server.service`` — require the exact base unit
# or the hyphenated profile family instead (review on #83595).
if not (
- unit.startswith("hermes-gateway")
+ unit == "hermes-gateway.service"
+ or unit.startswith("hermes-gateway-")
or unit == "hermes-serve.service"
or unit.startswith("hermes-serve-")
):
@@ -3916,8 +3917,14 @@ def _service_unit_supports_graceful_sigusr1_restart(svc_name: str) -> bool:
SIGUSR1 would just invoke the default terminate action and burn the full
drain budget waiting for an exit that was never graceful — go straight to
the blunt ``systemctl restart`` path for those instead.
+
+ Uses the same strict exact/hyphenated shape as the unit-name gate in
+ ``_for_each_systemd_gateway_unit`` so a hypothetical near-prefix unit
+ (``hermes-gateway-helper`` is fine — profile units are
+ ``hermes-gateway-<profile>`` — but ``hermes-gatewayd``-style names are
+ not) can't be sent a SIGUSR1 it doesn't handle.
"""
- return svc_name.startswith("hermes-gateway")
+ return svc_name == "hermes-gateway" or svc_name.startswith("hermes-gateway-")
def _warn_incomplete_gateway_fleet_restart(failed_units: list) -> None:
diff --git a/tests/hermes_cli/test_update_fleet_restart_timeout.py b/tests/hermes_cli/test_update_fleet_restart_timeout.py
index 67866be8105..020f8c1ea87 100644
--- a/tests/hermes_cli/test_update_fleet_restart_timeout.py
+++ b/tests/hermes_cli/test_update_fleet_restart_timeout.py
@@ -126,6 +126,20 @@ class TestFleetRestartTimeoutIsolation:
assert seen == []
+ def test_hermes_gateway_near_prefix_is_rejected(self):
+ # Same strict shape on the gateway side: profile units are
+ # ``hermes-gateway-<profile>``, so a hypothetical
+ # ``hermes-gatewayd.service`` must not enter the restart path.
+ seen: list[str] = []
+
+ _for_each_systemd_gateway_unit(
+ _list_units_stdout(["hermes-gatewayd", "hermes-gateway-coder"]),
+ process_unit=seen.append,
+ on_unit_timeout=lambda *_: pytest.fail("unexpected timeout"),
+ )
+
+ assert seen == ["hermes-gateway-coder"]
+
class TestGracefulSigusr1Eligibility:
def test_gateway_units_are_eligible(self):