llm-inference-multimodel: fix Phase 2 unexpectedly restarting both services

Phase 2 (systemd tag) notified per-service restart handlers and then
called meta: flush_handlers itself, so any run where either unit's
template content changed (including first apply) restarted BOTH
live services immediately in Phase 2 -- before Phase 3 firewall
scoping or Phase 4 smoke tests ran. This contradicted the phase's
documented purpose (units land on disk only, nothing starts/restarts
until Phase 4).

Fix: Phase 2 only reloads the systemd daemon and registers each
template task's changed result. Phase 4 (verify.yml) now decides
start vs restart per-service based on that recorded change, so
restarts remain independent per instance and never fire before
Phase 4.
This commit is contained in:
Hermes Agent service account
2026-08-05 16:21:50 -05:00
parent c3755aa29e
commit 628dae06a8
3 changed files with 45 additions and 31 deletions

View File

@@ -1,9 +1,21 @@
---
# ------------------------------------------------------------------------------
# FILE: roles/llm-inference-multimodel/handlers/main.yml
# DESCRIPTION: Separate restart handlers per instance — NEVER combined, so a
# content change to one unit template never restarts the other
# (plan §2/§6 requirement: independent restart/rollback).
# DESCRIPTION: Only a daemon-reload handler lives here now (harmless, no
# process impact). Per-service restart/start decisions are made
# explicitly in tasks/verify.yml (Phase 4), keyed off the
# per-unit `changed` result registered in tasks/systemd.yml
# (Phase 2) — NEVER combined, so a content change to one unit
# template still never restarts the other (plan §2/§6
# requirement: independent restart/rollback).
#
# BUGFIX: this file used to also define "restart
# llama-server-aux" / "restart llama-server-toolcall" handlers,
# notified from Phase 2's template tasks and fired there via
# `meta: flush_handlers` — causing both live services to
# restart during Phase 2, before Phase 3/4 had run. See
# tasks/systemd.yml for the full writeup. Restart logic moved
# to tasks/verify.yml so it only ever fires in Phase 4.
# ------------------------------------------------------------------------------
- name: Reload systemd
@@ -11,17 +23,3 @@
daemon_reload: true
become: true
listen: "reload systemd"
- name: Restart llama-server-aux
ansible.builtin.systemd:
name: "{{ llm_aux_service_name }}"
state: restarted
become: true
listen: "restart llama-server-aux"
- name: Restart llama-server-toolcall
ansible.builtin.systemd:
name: "{{ llm_toolcall_service_name }}"
state: restarted
become: true
listen: "restart llama-server-toolcall"