Skip to content

Commit bfe6922

Browse files
authored
optionaly-disable-pgbouncer-for-stream-writers (#24)
* optionaly-disable-pgbouncer-for-stream-writers * fix worker list
1 parent 55c6a33 commit bfe6922

5 files changed

Lines changed: 42 additions & 26 deletions

File tree

charts/synapse/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
apiVersion: v2
33
name: synapse
44
description: matrix synapse kubernetes deployment
5-
version: 2.0.9
5+
version: 2.1.0
66
appVersion: 1.149.1

charts/synapse/templates/synapse-secret.yaml

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
1-
{{- $workers := merge (deepCopy .Values.synapse.autoscalingWorkers) (deepCopy .Values.synapse.deployScalingWorkers) (deepCopy .Values.synapse.singletonWorkers) -}}
1+
{{- $workers := merge (deepCopy .Values.synapse.autoscalingWorkers) (deepCopy .Values.synapse.deployScalingWorkers) (deepCopy .Values.synapse.singletonWorkers) }}
2+
{{- $mediaWorkers := list "media_repository" "media_repository_background_jobs" }}
3+
{{- $fedOnlyWorkers := list "federation_reader" "federation_sender" }}
4+
{{- $clientFedWorkers := list "master" "room" }}
5+
{{- $noHttpWorkers := list "background_worker" "pusher" }}
6+
{{- $streamWriters := list "master" "typing" "to_device" "account_data" "presence" "push_rules" "receipts" "device_lists" "thread_subscriptions" "quarantined_media" "event_persister" }}
7+
{{- $replicationWorkers := list "master" "typing" "to_device" "account_data" "presence" "push_rules" "receipts" "device_lists" "thread_subscriptions" "quarantined_media" "event_persister" "federation_sender" }}
8+
{{- $clientOnlyWorkers := list "typing" "to_device" "account_data" "presence" "push_rules" "receipts" "device_lists" "thread_subscriptions" "quarantined_media" "event_persister" "sync" "client_reader" "user_dir" }}
29

3-
{{- $registration_shared_secret := .Values.registration_shared_secret -}}
4-
{{- $form_secret := .Values.form_secret -}}
5-
{{- $macaroon_secret_key := .Values.macaroon_secret_key -}}
6-
{{- $media_storage_providers := .Values.media_storage_providers -}}
7-
{{- $turn_uris := .Values.turn_uris -}}
8-
{{- $password_providers := .Values.password_providers -}}
9-
{{- $oidc_providers := .Values.oidc_providers -}}
10-
{{- $signing_key := .Values.signing_key -}}
10+
{{- $registration_shared_secret := .Values.registration_shared_secret }}
11+
{{- $form_secret := .Values.form_secret }}
12+
{{- $macaroon_secret_key := .Values.macaroon_secret_key }}
13+
{{- $media_storage_providers := .Values.media_storage_providers }}
14+
{{- $turn_uris := .Values.turn_uris }}
15+
{{- $password_providers := .Values.password_providers }}
16+
{{- $oidc_providers := .Values.oidc_providers }}
17+
{{- $signing_key := .Values.signing_key }}
1118
{{- $federation_domain_whitelist := .Values.federation_domain_whitelist }}
1219
{{- $federation_metrics_domains := .Values.federation_metrics_domains }}
1320
{{- $idp_metadata := .Values.idp_metadata | default "" }}
1421
{{- $password_enabled := .Values.password_enabled }}
15-
{{- $rc_message := .Values.rc_message -}}
22+
{{- $rc_message := .Values.rc_message }}
1623

1724
{{- range $worker, $options := $workers }}
1825
{{ $name := $worker | replace "_" "-"}}
@@ -35,7 +42,7 @@ stringData:
3542
---
3643
server_name: {{ $.Values.synapse.serverName }}
3744
{{- if ne $worker "master" }}
38-
{{- if has $worker (list "media_repository" "media_repository_background_jobs") }}
45+
{{- if has $worker $mediaWorkers }}
3946
worker_app: synapse.app.media_repository
4047
{{- else }}
4148
worker_app: synapse.app.generic_worker
@@ -66,7 +73,11 @@ stringData:
6673
cp_max: {{ $.Values.synapse.postgres.cp_max }}
6774
cp_min: {{ $.Values.synapse.postgres.cp_min }}
6875
database: {{ $.Values.synapse.postgres.dbname }}
76+
{{- if and $.Values.synapse.disablePgBouncerForStreamWriters (has $worker $streamWriters) }}
77+
host: {{ $.Values.synapse.postgres.host }}
78+
{{- else }}
6979
host: synapse-pgbouncer
80+
{{- end }}
7081
password: {{ $.Values.synapse.postgres.password }}
7182
user: {{ $.Values.synapse.postgres.user }}
7283
name: psycopg2
@@ -98,30 +109,30 @@ stringData:
98109
resources:
99110
- names: [metrics]
100111
compress: false
101-
{{- if not (has $worker (list "background_worker" "pusher")) }}
112+
{{- if not (has $worker $noHttpWorkers) }}
102113
- port: 8008
103114
tls: false
104115
type: http
105116
x_forwarded: true
106117
bind_addresses: ['0.0.0.0']
107118
resources:
108-
{{- if has $worker (list "master" "room") }}
119+
{{- if has $worker $clientFedWorkers }}
109120
- names: [client, federation]
110121
compress: true
111122
{{- end }}
112-
{{- if has $worker (list "federation_reader" "federation_sender") }}
123+
{{- if has $worker $fedOnlyWorkers }}
113124
- names: [federation]
114125
compress: true
115126
{{- end }}
116-
{{- if has $worker (list "typing" "to_device" "account_data" "presence" "push_rules" "receipts" "device_lists" "thread_subscriptions" "quarantined_media" "event_persister" "sync" "client_reader" "user_dir") }}
127+
{{- if has $worker $clientOnlyWorkers }}
117128
- names: [client]
118129
compress: true
119130
{{- end }}
120-
{{- if has $worker (list "media_repository" "media_repository_background_jobs") }}
131+
{{- if has $worker $mediaWorkers }}
121132
- names: [media]
122133
compress: false
123134
{{- end }}
124-
{{- if has $worker (list "master" "typing" "to_device" "account_data" "presence" "push_rules" "receipts" "device_lists" "thread_subscriptions" "quarantined_media" "event_persister" "federation_sender") }}
135+
{{- if has $worker $replicationWorkers }}
125136
- port: 9093
126137
tls: false
127138
type: http
@@ -223,7 +234,7 @@ stringData:
223234
run_background_tasks_on: synapse-background-worker-0
224235
log_config: /data/log.config
225236
macaroon_secret_key: "{{ $macaroon_secret_key }}"
226-
{{- if has $worker (list "media_repository" "media_repository_background_jobs") }}
237+
{{- if has $worker $mediaWorkers }}
227238
enable_media_repo: true
228239
media_storage_providers: {{ toYaml $media_storage_providers | nindent 6 }}
229240
{{- else }}
@@ -233,11 +244,11 @@ stringData:
233244
media_store_path: /tmp/media_store
234245
enable_local_media_storage: true
235246
metrics_flags: ~
236-
oidc_providers: {{ $oidc_providers | toYaml | nindent 6 }}
247+
oidc_providers: {{ toYaml $oidc_providers | nindent 6 }}
237248
old_signing_keys: ~
238249
password_config:
239250
enabled: {{ $password_enabled }}
240-
password_providers: {{- $password_providers | toYaml | nindent 6 }}
251+
password_providers: {{ toYaml $password_providers | nindent 6 }}
241252
pid_file: /tmp/homeserver.pid
242253
push: ~
243254
start_pushers: False

charts/synapse/templates/synapse-workers-pdb.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{- if .Values.synapse.deployScalingWorkersPdb.enabled }}
2-
{{/* deployScalingWorkers: replicas >= 1, minAvailable:1 allows rolling updates */}}
2+
{{/* deployScalingWorkers: replicas>1 → minAvailable:1; replicas=1 → maxUnavailable:1 allows node drain */}}
33
{{- range $worker, $options := .Values.synapse.deployScalingWorkers }}
44
{{ $name := $worker | replace "_" "-" }}
55
---
@@ -8,11 +8,15 @@ kind: PodDisruptionBudget
88
metadata:
99
name: synapse-{{ $name }}
1010
spec:
11+
{{- if gt ($options.replicas | int) 1 }}
1112
{{- if and $.Values.synapse.deployScalingWorkersPdb.minAvailable (not (hasKey $.Values.synapse.deployScalingWorkersPdb "maxUnavailable")) }}
1213
minAvailable: {{ $.Values.synapse.deployScalingWorkersPdb.minAvailable }}
1314
{{- else if $.Values.synapse.deployScalingWorkersPdb.maxUnavailable }}
1415
maxUnavailable: {{ $.Values.synapse.deployScalingWorkersPdb.maxUnavailable }}
1516
{{- end }}
17+
{{- else }}
18+
maxUnavailable: 1
19+
{{- end }}
1620
selector:
1721
matchLabels:
1822
{{- include "synapse-workers.selectorLabels" $name | nindent 6 }}

charts/synapse/templates/well-known-configmap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ data:
2222
"m.homeserver": {
2323
"base_url": "https://{{ .Values.synapse.serverName }}"
2424
},
25-
{{- if .Values.experimentalFeatures.msc2965.enabled }}
25+
{{- if or .Values.experimentalFeatures.msc2965.enabled .Values.matrixAuthentication.enabled }}
2626
"org.matrix.msc2965.authentication": {
2727
"issuer": "https://{{ .Values.matrixAuthentication.ingress.host }}/",
2828
"account": "https://{{ .Values.matrixAuthentication.ingress.host }}/account"

charts/synapse/values.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ synapse:
7878
# also this ghcr contains synapse:v1.146.0-e2e-optimized with e2e_room_key query patches
7979
tag: "v1.149.1"
8080
pullPolicy: IfNotPresent
81-
autoscaling:
82-
enabled: true
81+
disablePgBouncerForStreamWriters: false
8382
nodeSelector: {}
8483
tolerations: []
8584
affinity: {}
@@ -394,6 +393,8 @@ experimentalFeatures:
394393
msc3967:
395394
enabled: true
396395
# msc2965 will be enabled with msc3861
396+
msc2965:
397+
enabled: true
397398
msc3861:
398399
# TODO: enabled by matrixAuthentication.enabled, deprecated section
399400
issuer: NOT-CONFIGURED
@@ -443,6 +444,7 @@ ingress:
443444
# source: room.py:1472 client_patterns("/rooms/.*/typing/...", v1=True) -> (api/v1|r0|v3|unstable)
444445
typing:
445446
#- "/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/typing"
447+
# this is hack to make this regexp longer, because ImplementationSpecific chose longest if both match
446448
- "/_matrix/client/(api/v1|r0|v3|unstable)/rooms/(?:%21|!)[A-Za-z0-9._=\\-]+(?::|%3[Aa])[A-Za-z0-9.\\-]+/typing"
447449
# https://matrix-org.github.io/synapse/latest/workers.html#the-to_device-stream
448450
# routes to to_device stream writer singleton worker
@@ -625,7 +627,6 @@ admin:
625627
cloud.google.com/neg: '{"ingress":false}'
626628

627629
envoyProxy:
628-
enabled: true
629630
admin:
630631
port: 9901
631632
metrics: true

0 commit comments

Comments
 (0)