mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-12-03 08:17:52 +00:00
fix(sys-stk-backend): rebind handlers before flush
Ansible resolves a notification to the last handler block registered
under that name and templates application_id in that block's context.
Since 95186163aa sys-svc-compose is loaded first, so the provider roles
included after it (svc-db-postgres via sys-svc-rdbms, objstore, engine)
leave their own copy as the last one, and the trailing flush deployed
the dedicated postgres instead of the app. Run 33751742070: six jobs
waited on a keycloak or mattermost container that was never created.
A dynamic include_role directly before the flush makes the app's copy
the last registration again. import_role would not do: it expands when
main.yml is parsed, before the providers run. The first include stays,
so the missing-handler error stays fixed.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
61f786813a
commit
ced8e10a0e
2 files changed
+29
-2
No files matched your search
@@ -14,11 +14,19 @@ COMPOSE_OWNER = "sys-svc-compose"
|
||||
_NOTIFY = re.compile(r"^\s*notify:\s*(?:\[\s*)?['\"]?(compose-[\w-]+)", re.MULTILINE)
|
||||
|
||||
|
||||
def _role_include(task: dict) -> dict:
|
||||
for key in ("include_role", "import_role"):
|
||||
include = task.get(key) or task.get(f"ansible.builtin.{key}")
|
||||
if isinstance(include, dict):
|
||||
return include
|
||||
return {}
|
||||
|
||||
|
||||
def _included_roles(tasks: list) -> list[str]:
|
||||
names = []
|
||||
for task in tasks:
|
||||
include = task.get("include_role") or task.get("import_role") or {}
|
||||
if isinstance(include, dict) and include.get("name"):
|
||||
include = _role_include(task)
|
||||
if include.get("name"):
|
||||
names.append(include["name"])
|
||||
return names
|
||||
|
||||
@@ -29,6 +37,19 @@ class TestHandlerRegistrationOrder(unittest.TestCase):
|
||||
self.assertIn(COMPOSE_OWNER, order)
|
||||
self.assertEqual(order[0], COMPOSE_OWNER)
|
||||
|
||||
def test_the_owner_is_reloaded_directly_before_the_flush(self) -> None:
|
||||
tasks = load_yaml_str(read_text(str(BACKEND)))
|
||||
flush = next(
|
||||
index
|
||||
for index, task in enumerate(tasks)
|
||||
if task.get("meta") == "flush_handlers"
|
||||
or task.get("ansible.builtin.meta") == "flush_handlers"
|
||||
)
|
||||
previous = tasks[flush - 1]
|
||||
loader = _role_include(previous)
|
||||
self.assertEqual(loader.get("name"), COMPOSE_OWNER)
|
||||
self.assertEqual(loader.get("handlers_from"), "main")
|
||||
|
||||
def test_the_owner_still_holds_every_compose_topic_that_is_notified(self) -> None:
|
||||
owner = ""
|
||||
for path, content in iter_project_files_with_content(
|
||||
|
||||
Reference in new issue
Block a user