Skip to content

The agent that grows with you

fix(update): restart hermes-dashboard* systemd units during fleet update

Yuan Li3e4fb34778f9
diff --git a/hermes_cli/update_abort_recovery.py b/hermes_cli/update_abort_recovery.py
index 11ade025551..0950e3e917c 100644
--- a/hermes_cli/update_abort_recovery.py
+++ b/hermes_cli/update_abort_recovery.py
@@ -15,7 +15,7 @@ logger = logging.getLogger(__name__)
def _serve_unit_recovery_available() -> bool:
- """Can a fresh process restart ``hermes-serve*`` units on this host?"""
+ """Can a fresh process restart ``hermes-serve*``/``hermes-dashboard*`` units on this host?"""
return sys.platform == "linux" and bool(shutil.which("systemctl"))
diff --git a/hermes_cli/update_cmd_fleet.py b/hermes_cli/update_cmd_fleet.py
index 31e9b778697..be7047b6a57 100644
--- a/hermes_cli/update_cmd_fleet.py
+++ b/hermes_cli/update_cmd_fleet.py
@@ -36,7 +36,10 @@ _FRESH_RESTART_SUPERVISORS = frozenset({"systemd", "launchd", "service", "s6"})
_FLEET_PROBE_SETTLE_TIMEOUT_SECONDS = 120.0
_SYSTEMD_SCOPES = (("user", ["systemctl", "--user"]), ("system", ["systemctl"]))
-_LIST_GATEWAY_UNITS = ["list-units", "hermes-gateway*", "hermes-serve*", "--plain", "--no-legend", "--no-pager"]
+_LIST_GATEWAY_UNITS = [
+ "list-units", "hermes-gateway*", "hermes-serve*", "hermes-dashboard*",
+ "--plain", "--no-legend", "--no-pager",
+]
def _write_gateway_update_exit_code(ok: bool) -> None:
@@ -797,6 +800,11 @@ def _is_hermes_gateway_unit(unit: str) -> bool:
or unit.startswith("hermes-gateway-")
or unit == "hermes-serve.service"
or unit.startswith("hermes-serve-")
+ # #125297: ``hermes-dashboard*`` units are systemd-supervised dashboard backends — the
+ # same fleet this pass restarts. Leaving them out meant a successful update reported
+ # the dashboard ``deferred`` (still on pre-update code) while nothing ever restarted it.
+ or unit == "hermes-dashboard.service"
+ or unit.startswith("hermes-dashboard-")
)
diff --git a/hermes_cli/update_restart_recovery.py b/hermes_cli/update_restart_recovery.py
index 6fd9c3d7d89..0f357351cf4 100644
--- a/hermes_cli/update_restart_recovery.py
+++ b/hermes_cli/update_restart_recovery.py
@@ -63,8 +63,8 @@ _VERIFY_TIMEOUT = 15
from hermes_constants import PROFILE_ID_RE as _PROFILE_ID_RE
_SUPERVISOR_RE = re.compile(r"^[a-z0-9][a-z0-9_-]{0,31}$")
-_UNIT_RE = re.compile(r"^hermes-serve(-[a-z0-9][a-z0-9_-]{0,63})?\.service$")
-_SERVE_UNIT_PATTERN = "hermes-serve*"
+_UNIT_RE = re.compile(r"^hermes-(serve|dashboard)(-[a-z0-9][a-z0-9_-]{0,63})?\.service$")
+_SERVE_UNIT_PATTERNS = ("hermes-serve*", "hermes-dashboard*")
_SCOPE_LABELS = ("user", "system")
_UNIT_RESTART_TIMEOUT = 60
_UNIT_SETTLE_ATTEMPTS = 10
@@ -271,21 +271,22 @@ def _systemctl_scopes() -> list[tuple[str, list[str]]]:
def _listed_serve_units(scope: list[str], *, run: Callable[..., Any]) -> list[str]:
- """Serve units systemd knows about in one scope, validated by name."""
- result = _run_quiet(
- run,
- scope + ["list-units", _SERVE_UNIT_PATTERN, "--plain", "--no-legend", "--no-pager"],
- timeout=_VERIFY_TIMEOUT,
- )
- if result is None:
- return []
- # The glob is a systemd pattern, not a name gate (`hermes-serve*` also matches
- # `hermes-server.service`): require the exact base unit or the profile family.
+ """Serve/dashboard units systemd knows about in one scope, validated by name."""
units: list[str] = []
- for line in (getattr(result, "stdout", "") or "").splitlines():
- parts = line.split()
- if parts and _UNIT_RE.fullmatch(parts[0]) and parts[0] not in units:
- units.append(parts[0])
+ for pattern in _SERVE_UNIT_PATTERNS:
+ result = _run_quiet(
+ run,
+ scope + ["list-units", pattern, "--plain", "--no-legend", "--no-pager"],
+ timeout=_VERIFY_TIMEOUT,
+ )
+ if result is None:
+ continue
+ # The glob is a systemd pattern, not a name gate (`hermes-serve*` also matches
+ # `hermes-server.service`): require the exact base unit or the profile family.
+ for line in (getattr(result, "stdout", "") or "").splitlines():
+ parts = line.split()
+ if parts and _UNIT_RE.fullmatch(parts[0]) and parts[0] not in units:
+ units.append(parts[0])
return units
@@ -351,7 +352,7 @@ def _normalized_skips(skip_units: Iterable[Any]) -> tuple[set[tuple[str, str]],
def restart_serve_units(
*, skip_units: Iterable[Any] = (), run: Callable[..., Any] = subprocess.run, sleep: Callable[[float], Any] = time.sleep
) -> dict[str, list[str]]:
- """Restart every active ``hermes-serve*`` systemd unit from this process.
+ """Restart every active ``hermes-serve*``/``hermes-dashboard*`` systemd unit from this process.
Units are enumerated from systemd, never from the update inventory, so a manually launched or
Desktop-owned ``hermes serve`` (no unit) structurally cannot be touched here.