Files
computer-playbook/roles/sys-front-tls/tasks/01_http.yml
kevinveenbirkenbachandClaude Opus 5 403a35ed95 perf(front-tls): reload the proxy for a redirect config, do not redeploy it
Writing the per-domain HTTP->HTTPS redirect notified restart-openresty, which
runs container service update --force and waits for a swarm rolling update. It
fired once per domain. Measured across both passes of a green Nextcloud round:
the forced redeploy ran 47 times at a mean of 40s, and 34 of those
notifications came from this task; the remaining 11 came from the genuine
fallback in sys-stk-front-proxy. The role accounted for 1178s of a 9694s sync
pass and 1043s of the async pass, so roughly 2.2ks of an 18.8ks job against a
20.4ks budget.

The redeploy is not needed here. plugins/lookup/nginx.py resolves
files.domain to conf.d/servers/<protocol>/<domain>.conf, which sits inside the
conf.d DIRECTORY bind, and handlers/reload.yml states the rule for exactly this
case: a directory keeps its inode across an atomic file write, so the running
container already sees the new file and SIGHUP is enough. Only nginx.conf is
bound as a file whose inode the task pins at create time, and nothing here
writes it.

The choice was never made deliberately: a46348b6cf only renamed
"restart openresty" to "restart-openresty" in this file, carrying the topic
forward unchanged.

Correctness does not rest on the reload being sufficient. sys-stk-front-proxy
probes each domain after the reload and notifies restart-openresty when it is
not served, a guard that demonstrably fires today. If SIGHUP falls short the
redeploy still happens; the worst case is no saving rather than a broken vhost.

Expected saving is 1.5 to 1.75ks per job, about 8% of the distro budget. That
makes the comfortable jobs comfortable and leaves the heaviest Nextcloud
variants marginal; it does not on its own end the budget kills.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-09 12:56:47 +02:00

15 lines
471 B
YAML

---
- name: 📂 Include dependency 'sys-ctl-mtn-cert-renew'
include_role:
name: sys-ctl-mtn-cert-renew
when:
- run_once_sys_ctl_mtn_cert_renew is not defined
- lookup('tls', application_id, 'mode') == 'letsencrypt'
- name: 📁 Create HTTP->HTTPS handler per domain
stack_host_template:
src: "http.conf.j2"
dest: "{{ lookup('nginx', 'files.domain', domain, protocol='http') }}"
notify: reload-openresty
when: HTTPS_REDIRECT_ENABLED | bool