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(