Derive Synapse post-start delay from Traefik's providersThrottleDuration

After Synapse's systemd health check passes, Traefik still needs
providers.providersThrottleDuration to register routes. Derive the
post-start delay from this setting (+1s for healthcheck polling gap)
instead of using a hardcoded value. Defaults to 0 when no Traefik
reverse proxy is used.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Slavi Pantaleev
2026-02-12 00:54:46 +02:00
parent 9569633164
commit a77a8753d9
2 changed files with 13 additions and 6 deletions

View File

@@ -4465,6 +4465,12 @@ matrix_synapse_password_config_enabled: "{{ not matrix_synapse_matrix_authentica
matrix_synapse_register_user_script_matrix_authentication_service_path: "{{ matrix_authentication_service_bin_path }}/register-user"
# After Synapse's systemd health check passes, the reverse proxy still needs time to
# discover the container and register its routes. We derive this delay from Traefik's
# providers.providersThrottleDuration setting (+1s grace for our healthcheck polling interval),
# so it stays in sync automatically.
matrix_synapse_systemd_service_post_start_delay_seconds: "{{ (traefik_config_providers_providersThrottleDuration_seconds | int + 1) if matrix_playbook_reverse_proxy_type in ['playbook-managed-traefik', 'other-traefik-container'] else 0 }}"
######################################################################
#
# /matrix-synapse

View File

@@ -335,7 +335,8 @@ matrix_synapse_container_labels_additional_labels: ''
# (see matrix_synapse_systemd_healthcheck_enabled) detect readiness faster at startup.
#
# For non-Traefik setups, we use the default healthcheck interval (15s) to decrease overhead.
matrix_synapse_container_health_interval: "{{ '5s' if matrix_synapse_container_labels_traefik_enabled else '15s' }}"
matrix_synapse_container_health_interval_seconds: "{{ 5 if matrix_synapse_container_labels_traefik_enabled else 15 }}"
matrix_synapse_container_health_interval: "{{ matrix_synapse_container_health_interval_seconds }}s"
# A list of extra arguments to pass to the container
# Also see `matrix_synapse_container_arguments`
@@ -397,13 +398,13 @@ matrix_synapse_systemd_healthcheck_command: >-
# Controls how long to sleep for after the systemd health check passes.
# Even after Synapse is healthy, the reverse proxy (e.g. Traefik) needs time to discover
# the container and register its routes. Traefik's `providers.providersThrottleDuration`
# (default: 2s; see https://doc.traefik.io/traefik/providers/overview/#providersthrottleduration)
# adds a delay before applying new configuration from Docker events, meaning routes
# typically become available ~2-3 seconds after a container starts.
# the container and register its routes. Traefik waits `providers.providersThrottleDuration`
# (see https://doc.traefik.io/traefik/v3.3/providers/overview/#providersprovidersthrottleduration)
# before applying new configuration from Docker events.
# Without this delay, services depending on Synapse may encounter 404 errors
# when connecting through the reverse proxy.
matrix_synapse_systemd_service_post_start_delay_seconds: 10
# This value is meant to be wired to the Traefik throttle duration by the playbook's group vars.
matrix_synapse_systemd_service_post_start_delay_seconds: 0
matrix_synapse_in_container_python_packages_path: "/usr/local/lib/python3.13/site-packages"