fix(web-app-zammad): gate init on the search precheck in swarm too

`docker stack deploy` ignores `depends_on`, so in swarm `init` started
even when the `precheck` service exited 1. The stack then looked exactly
as it did before #982: `init` hung, and `stack_ready.sh` reported "not
converged" until all 600 retries of the convergence handler ran out.
The single failed `precheck` task never turned fatal, because
`has_fatal_task` needs three errors.

`init` now runs `search_allocation_precheck.sh` in front of
`zammad-init` as well. In compose the `precheck` service still stops
`compose up` before `init` starts. In swarm, `init` keeps
`restart: on-failure`, so a refusing Elasticsearch makes its tasks fail
again and again. After three errors past `swarm_stack_fatal_grace`
(180 s), `has_fatal_task` marks the service stuck and the deploy stops
with the precheck output in the task report.

Reported by CodeRabbit on #982.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5.5 committed 2026-10-18 12:33:53 +02:00
1 parent fcf1cca129
commit 68680e863b
3 files changed
+5 -3

No files matched your search

+1 -1
View File
@@ -96,7 +96,7 @@ Solid `1:1` edges are fixed relationships; dashed `0..1` edges are conditional (
- **Mail-to-ticket:** When `web-app-stalwart` is present, the `helpdesk` mailbox is auto-provisioned and Zammad polls it to create tickets from incoming mail.
- **Server-name alias:** `zammad.helpdesk.{{ DOMAIN_PRIMARY }}` is a true vhost alias of `helpdesk.{{ DOMAIN_PRIMARY }}` (not a 301 redirect).
- **Bundled Elasticsearch:** Search engine ships with the role until a central `svc-db-elasticsearch` exists.
- **Search allocation precheck:** the one-shot `precheck` service runs [search_allocation_precheck.sh](files/shell/search_allocation_precheck.sh) and `init` starts only after it completed successfully. It creates a one-shard probe index and exits 0 once Elasticsearch allocates it; otherwise it exits 1 with the answer of `_cluster/allocation/explain`, which names the disk watermark when the data disk is too full, and `compose up` stops on it.
- **Search allocation precheck:** [search_allocation_precheck.sh](files/shell/search_allocation_precheck.sh) creates a one-shard probe index and fails with the answer of `_cluster/allocation/explain`, which names the disk watermark when the data disk is too full, unless Elasticsearch allocates it. The one-shot `precheck` service runs it and `init` depends on that service, so `compose up` stops on a refusal. `init` runs it again in front of `zammad-init`; in swarm, where `depends_on` does not gate `init`, the failing `init` tasks turn the stack fatal.
- **Search index per Elasticsearch major:** The index lives in a directory named after the Elasticsearch major inside the `zammad_search` volume. A new major starts on an empty directory and `zammad-init` rebuilds the index from the database on the same deploy.
- **Wizard bypass:** First deploy seeds `auto_wizard.json` so no manual setup UI step is required.
+3 -1
View File
@@ -24,7 +24,9 @@ search_allocation_precheck:
mode: "0555"
mounts:
- service: precheck
target: /usr/local/bin/search_allocation_precheck.sh
target: &usr_local_bin_search_allocation_precheck_sh_target /usr/local/bin/search_allocation_precheck.sh
- service: init
target: *usr_local_bin_search_allocation_precheck_sh_target
auto_wizard:
type: config
source: "{{ [lookup('container', 'web-app-zammad', 'directories.volumes'), 'auto_wizard.json'] | path_join }}"
@@ -18,7 +18,7 @@
{{ lookup('container_image', application_id, 'zammad') }}
{{ lookup('compose_only', 'container_name', ZAMMAD_INIT_CONTAINER) }}
{% include 'roles/sys-svc-container/templates/base.yml.j2' %}
command: ["zammad-init"]
command: ["{{ ZAMMAD_SEARCH_PRECHECK_TARGET }}", "{{ ZAMMAD_SEARCH_READY_SECONDS }}", "{{ ZAMMAD_SEARCH_POLL_SECONDS }}", "{{ ZAMMAD_SEARCH_ALLOCATION_TIMEOUT_SECONDS }}", "/opt/zammad/bin/docker-entrypoint", "zammad-init"]
{{ lookup('container_volumes', service_name) | indent(4) }}
{{ lookup('container_depends_on', application_id, extra={
ZAMMAD_PRECHECK_SERVICE: {'condition': 'service_completed_successfully'},