From a40a2070cf0ebe0958d6281e0d784f1dfa16169a Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 23 Sep 2026 18:20:05 +0200 Subject: [PATCH] fix(svc-ai-searxng): bootstrap the compose host before the first notify bb78ab3fb8 moved the handler loader in front of the settings render so the play stopped dying on "handler 'compose-up' was not found". Registering them was necessary and not sufficient: the notification now survives, and the next task kills the play a different way. render_replicated_templates.yml hangs notify: compose-up on the render (_render_one_template.yml:23, default from role_templates_expanded.py:17). 00_core.yml then enters utils/network/routine.yml, whose step 1 pulls in sys-svc-container, and that role ends on an unconditional meta: flush_handlers at 00_core.yml:52. Job 107238119066 of run 35875571687 shows the whole chain: NOTIFIED HANDLER ... Validate Docker Compose configuration at log line 13787, META: triggered running handlers at 13801, and the handler at 13923 with rc 127, "compose: command not found". /usr/bin/compose is installed by sys-svc-compose/tasks/00_core.yml:30, which is step 3 of that same routine and is never reached, because a failed handler aborts the play (ok=228 failed=1). A guarded bootstrap ahead of the render absorbs that flush against an empty queue and installs the wrapper first, the shape 252b3e58b2 applies in sys-svc-rdbms and 7f1025e4a7 in svc-db-qdrant. Routine step 1 then falls through on run_once_sys_svc_container, and step 3 renders compose.yml and flushes under searxng's own application_id. The when: guard is load-bearing: without it 01_reset.yml tears down DIR_COMPOSITIONS again under MODE_RESET. litellm carries the same shape and survives only because it loads sys-svc-rdbms first, which bootstraps compose as a side effect; searxng is a leaf with no database and is therefore the first compose consumer in its own CI row. The existing bootstrap case in test_handler_registration_order.py finds the first notify through task.get("notify"), a literal key in the same file, so it cannot see a role that notifies two include levels down. The new case anchors on the render include itself and compares indices instead. The sweeping case checks topic ownership, not order, which is why searxng was green here while it failed in CI. Same class, pre-existing, not fixed here: svc-ai-agent-broker renders at :39 and enters the routine at :61, latent because it depends on litellm and is never the first compose consumer. 252b3e58b2 names web-app-magento, web-app-seaweedfs and svc-runner. Co-Authored-By: Claude Opus 5 (1M context) --- roles/svc-ai-searxng/tasks/00_core.yml | 6 ++++ .../test_handler_registration_order.py | 28 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/roles/svc-ai-searxng/tasks/00_core.yml b/roles/svc-ai-searxng/tasks/00_core.yml index 9a0c33e3d4..3812b3c8d9 100644 --- a/roles/svc-ai-searxng/tasks/00_core.yml +++ b/roles/svc-ai-searxng/tasks/00_core.yml @@ -5,6 +5,12 @@ vars: handler_role_name: "sys-svc-compose" +- name: "🥾 For '{{ application_id }}': bootstrap the compose host once" + ansible.builtin.include_role: + name: sys-svc-compose + tasks_from: 00_core.yml + when: run_once_sys_svc_compose is not defined + - name: "📄 Render the search engine settings (local + swarm peers)" ansible.builtin.include_tasks: file: "{{ lookup('path_absolute', 'roles/sys-svc-compose/tasks/utils/render_replicated_templates.yml') }}" diff --git a/tests/unit/python/roles/sys-stk-backend/test_handler_registration_order.py b/tests/unit/python/roles/sys-stk-backend/test_handler_registration_order.py index 2d3b278a69..45753356e6 100644 --- a/tests/unit/python/roles/sys-stk-backend/test_handler_registration_order.py +++ b/tests/unit/python/roles/sys-stk-backend/test_handler_registration_order.py @@ -16,7 +16,9 @@ BLUESKY_STAGING = tuple( PROJECT_ROOT / "roles/web-app-bluesky/tasks" / name for name in ("01_social_app.yml", "02_login_broker.yml", "03_pds.yml") ) +SEARXNG_CORE = PROJECT_ROOT / "roles/svc-ai-searxng/tasks/00_core.yml" COMPOSE_OWNER = "sys-svc-compose" +RENDER_REPLICATED = "render_replicated_templates.yml" _NOTIFY = re.compile(r"^\s*notify:\s*(?:\[\s*)?['\"]?(compose-[\w-]+)", re.MULTILINE) @@ -150,6 +152,32 @@ class TestHandlerRegistrationOrder(unittest.TestCase): "run_once_sys_svc_compose is not defined", str(tasks[bootstrap].get("when")) ) + def test_searxng_bootstraps_the_compose_host_before_it_renders(self) -> None: + tasks = load_yaml_str(read_text(str(SEARXNG_CORE))) + bootstrap = next( + index + for index, task in enumerate(tasks) + if _role_include(task).get("name") == COMPOSE_OWNER + and _role_include(task).get("tasks_from") == "00_core.yml" + ) + render = next( + index + for index, task in enumerate(tasks) + if RENDER_REPLICATED + in str((task.get("ansible.builtin.include_tasks") or {}).get("file", "")) + ) + self.assertLess( + bootstrap, + render, + "the render notifies compose-up, and the next task pulls in " + "sys-svc-container, whose unconditional flush would run the " + "handlers before sys-svc-compose installs the compose wrapper", + ) + self.assertIn( + "run_once_sys_svc_compose is not defined", + str(tasks[bootstrap].get("when")), + ) + def test_the_owner_still_holds_every_compose_topic_that_is_notified(self) -> None: owner = "" for path, content in iter_project_files_with_content(