Files
computer-playbook/roles/sys-stk-backend/tasks/main.yml
kevinveenbirkenbachandClaude Opus 5 252b3e58b2 fix(compose): bootstrap before notify, render last
Two branch-only commits each armed a defect in the compose-up handler
topic, and both failed in run 33785198875.

63f7f962bf registered the topic owner at the top of sys-svc-rdbms'
dedicated.yml so the notify two tasks below stopped aborting with
ERROR_ON_MISSING_HANDLER. The notification then survived to the
unconditional meta: flush_handlers at sys-svc-container/tasks/00_core.yml:53,
reached from sys-svc-compose's own 00_core before that role installs
BIN_COMPOSE, and long before 02_stack_host_prep installs BIN_CA_INJECT.
Matrix#1 died there on ca-inject with rc 2 after seven retries. That play
carries exactly one compose notification (job 100756596907, log line
11046), so closing this window is sufficient, not merely necessary.
dedicated.yml now enters 00_core.yml under the role's run-once flag
before it notifies, so the flush drains an empty queue and the flag then
makes main.yml skip the body on the real entry. The registration itself
stays ungated: gating it would skip the owner from the second app on.

95186163aa hoisted the sys-svc-compose include to sys-stk-backend
position 1. The consumer therefore rendered and notified compose-up
before sys-svc-objstore lazily loaded the provider app role, whose own
unconditional flush consumed the notification and ran the single
registered handler in the provider's chdir. mastodon and peertube never
got a stack, in compose and in swarm alike; the victim's own guard task
appears zero times in all four logs. Restoring the include below rdbms,
objstore and engine puts the notify after every foreign crossing. Two
pre-hoist runs in exactly that order are green on record.

The test keeps its cases and gains one. It selects the render include by
the absence of tasks_from instead of by first occurrence, so an early
registration-only include stays legal while a hoisted render still fails.
The new case pins the bootstrap: entry point, position before the first
notify, and the run-once guard whose removal would let 01_reset.yml tear
down DIR_COMPOSITIONS once per dedicated-DB app.

Same class, pre-existing, not fixed here: svc-db-qdrant notifies and
flushes three tasks before its first compose entry; web-app-magento pairs
a dedicated database with a shared object store; web-app-seaweedfs still
flushes a topic it does not own; svc-runner enters 00_core.yml unguarded.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-04 01:16:38 +02:00

78 lines
2.7 KiB
YAML

---
# run_once_sys_stk_backend: disabled
- name: "🔍 Resolve backend context for '{{ application_id }}'"
ansible.builtin.set_fact:
_sys_stk_backend_database_consumer_id: >-
{{ database_consumer_id | default(application_id) }}
_sys_stk_backend_database_enabled: >-
{{ lookup('database', application_id, 'enabled') | bool }}
changed_when: false
- name: "🐛 DEBUG | SYS-STK-BACKEND | Application context"
ansible.builtin.debug:
msg:
- "application_id={{ application_id }}"
- "database_consumer_id={{ _sys_stk_backend_database_consumer_id }}"
- "database_enabled={{ _sys_stk_backend_database_enabled }}"
- "sso_proxy_enabled={{ lookup('sso', application_id, 'is_proxy_gated') }}"
when: MODE_DEBUG | bool
- name: "🧩 For '{{ application_id }}': Load central RDBMS"
include_role:
name: sys-svc-rdbms
public: false
vars:
database_consumer_id: "{{ _sys_stk_backend_database_consumer_id }}"
when: _sys_stk_backend_database_enabled | bool
- name: "🧩 '{{ application_id }}': load per-consumer central object store"
include_role:
name: sys-svc-objstore
public: false
vars:
objstore_consumer_id: "{{ application_id }}"
when:
- lookup('objstore', application_id, 'enabled') | bool
- lookup('objstore', application_id, 'shared') | bool
- application_id != lookup('objstore', application_id, 'id')
- name: "🧩 For '{{ application_id }}': Load central engines (per-consumer provisioning)"
include_role:
name: sys-svc-engine
public: false
vars:
engine_consumer_id: "{{ application_id }}"
- name: "🧩 For '{{ application_id }}': Load sys-svc-compose"
include_role:
name: sys-svc-compose
vars:
compose_handlers_flush: false
database_consumer_id: "{{ _sys_stk_backend_database_consumer_id }}"
- block:
- name: "🔧 set sso_proxy_application_id (needed due to lazy-loading issue)"
set_fact:
sso_proxy_application_id: "{{ application_id }}"
- name: "📄 render web-app-keycloak SSO-proxy sidecar config"
include_tasks: "{{ lookup('path_absolute', 'roles/web-app-keycloak/tasks/sso_proxy.yml') }}"
when: lookup('sso', application_id, 'is_proxy_gated') | bool
- name: "📂 For '{{ application_id }}': re-own the compose handler topics before the flush"
ansible.builtin.include_role:
name: sys-svc-compose
tasks_from: none.yml
handlers_from: main
- name: "🚿 flush compose and SSO proxy"
meta: flush_handlers
when: compose_handlers_flush | bool
- name: "🔑 For '{{ application_id }}': realign a dedicated postgres"
include_tasks:
file: "{{ lookup('path_absolute', 'roles/sys-svc-rdbms/tasks/utils/realign_dedicated_db.yml') }}"
apply:
delegate_to: "{{ STACK_HOST }}"
run_once: true