Skip to content

Commit 7f027ef

Browse files
committed
Move the 503 -> 429 mapping into Synapse's frontend rather than HAProxy defaults
1 parent 8b2950a commit 7f027ef

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

charts/matrix-stack/configs/haproxy/haproxy.cfg.tpl

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{- /*
2-
Copyright 2024 New Vector Ltd
2+
Copyright 2024-2025 New Vector Ltd
33
44
SPDX-License-Identifier: AGPL-3.0-only
55
*/ -}}
@@ -66,16 +66,6 @@ defaults
6666
compression algo gzip
6767
compression type text/plain text/html text/xml application/json text/css
6868

69-
# if we hit the maxconn on a server, and the queue timeout expires, we want
70-
# to avoid returning 503, since that will cause cloudflare to mark us down.
71-
#
72-
# https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#1.3.1 says:
73-
#
74-
# 503 when no server was available to handle the request, or in response to
75-
# monitoring requests which match the "monitor fail" condition
76-
#
77-
errorfile 503 /usr/local/etc/haproxy/429.http
78-
7969
# Use a consistent hashing scheme so that worker with balancing going down doesn't cause
8070
# the traffic for all others to be shuffled around.
8171
hash-type consistent sdbm

charts/matrix-stack/configs/haproxy/429.http.tpl renamed to charts/matrix-stack/configs/synapse/429.http.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{- /*
2-
Copyright 2024 New Vector Ltd
2+
Copyright 2024-2025 New Vector Ltd
33
44
SPDX-License-Identifier: AGPL-3.0-only
55
*/ -}}

charts/matrix-stack/configs/synapse/partial-haproxy.cfg.tpl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ frontend synapse-http-in
2525
# same as http log, with %Th (handshake time)
2626
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"
2727

28+
# if we hit the maxconn on a server, and the queue timeout expires, we want
29+
# to avoid returning 503, since that will cause cloudflare to mark us down.
30+
#
31+
# https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#1.3.1 says:
32+
#
33+
# 503 when no server was available to handle the request, or in response to
34+
# monitoring requests which match the "monitor fail" condition
35+
#
36+
errorfile 503 /synapse/429.http
37+
2838
capture request header Host len 32
2939
capture request header Referer len 200
3040
capture request header User-Agent len 200

charts/matrix-stack/templates/haproxy/_helpers.tpl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ app.kubernetes.io/version: {{ include "element-io.ess-library.labels.makeSafe" .
2020
{{- with required "element-io.haproxy.configmap-data missing context" .context -}}
2121
haproxy.cfg: |
2222
{{- tpl ($root.Files.Get "configs/haproxy/haproxy.cfg.tpl") (dict "root" $root "context" .) | nindent 2 }}
23-
429.http: |
24-
{{- (tpl ($root.Files.Get "configs/haproxy/429.http.tpl") dict) | nindent 2 }}
2523
{{- end -}}
2624
{{- end -}}
2725

charts/matrix-stack/templates/synapse/_helpers.tpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ redis.conf: |
223223

224224
{{- define "element-io.synapse-haproxy.configmap-data" -}}
225225
{{- $root := .root -}}
226+
429.http: |
227+
{{- (tpl ($root.Files.Get "configs/haproxy/429.http.tpl") dict) | nindent 2 }}
226228
path_map_file: |
227229
{{- (tpl ($root.Files.Get "configs/synapse/path_map_file.tpl") (dict "root" $root)) | nindent 2 }}
228230
path_map_file_get: |

0 commit comments

Comments
 (0)