Move the 503 -> 429 mapping into Synapse's frontend rather than HAProxy defaults

This commit is contained in:
Ben Banfield-Zanin committed 2025-08-01 15:18:53 +01:00
1 parent 8b2950a9b8
commit 7f027ef0ec
5 files changed
+14 -14

No files matched your search

@@ -1,5 +1,5 @@
{{- /*
Copyright 2024 New Vector Ltd
Copyright 2024-2025 New Vector Ltd
SPDX-License-Identifier: AGPL-3.0-only
*/ -}}
@@ -66,16 +66,6 @@ defaults
compression algo gzip
compression type text/plain text/html text/xml application/json text/css
# if we hit the maxconn on a server, and the queue timeout expires, we want
# to avoid returning 503, since that will cause cloudflare to mark us down.
#
# https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#1.3.1 says:
#
# 503 when no server was available to handle the request, or in response to
# monitoring requests which match the "monitor fail" condition
#
errorfile 503 /usr/local/etc/haproxy/429.http
# Use a consistent hashing scheme so that worker with balancing going down doesn't cause
# the traffic for all others to be shuffled around.
hash-type consistent sdbm
@@ -1,5 +1,5 @@
{{- /*
Copyright 2024 New Vector Ltd
Copyright 2024-2025 New Vector Ltd
SPDX-License-Identifier: AGPL-3.0-only
*/ -}}
@@ -25,6 +25,16 @@ frontend synapse-http-in
# same as http log, with %Th (handshake time)
log-format "%ci:%cp [%tr] %ft %b/%s %Th/%TR/%Tw/%Tc/%Tr/%Ta %ST %B %CC %CS %tsc %ac/%fc/%bc/%sc/%rc %sq/%bq %hr %hs %{+Q}r"
# if we hit the maxconn on a server, and the queue timeout expires, we want
# to avoid returning 503, since that will cause cloudflare to mark us down.
#
# https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#1.3.1 says:
#
# 503 when no server was available to handle the request, or in response to
# monitoring requests which match the "monitor fail" condition
#
errorfile 503 /synapse/429.http
capture request header Host len 32
capture request header Referer len 200
capture request header User-Agent len 200
@@ -20,8 +20,6 @@ app.kubernetes.io/version: {{ include "element-io.ess-library.labels.makeSafe" .
{{- with required "element-io.haproxy.configmap-data missing context" .context -}}
haproxy.cfg: |
{{- tpl ($root.Files.Get "configs/haproxy/haproxy.cfg.tpl") (dict "root" $root "context" .) | nindent 2 }}
429.http: |
{{- (tpl ($root.Files.Get "configs/haproxy/429.http.tpl") dict) | nindent 2 }}
{{- end -}}
{{- end -}}
@@ -223,6 +223,8 @@ redis.conf: |
{{- define "element-io.synapse-haproxy.configmap-data" -}}
{{- $root := .root -}}
429.http: |
{{- (tpl ($root.Files.Get "configs/haproxy/429.http.tpl") dict) | nindent 2 }}
path_map_file: |
{{- (tpl ($root.Files.Get "configs/synapse/path_map_file.tpl") (dict "root" $root)) | nindent 2 }}
path_map_file_get: |