From 0670c47e4f81f8abac99b37afb67ac11f1fbf444 Mon Sep 17 00:00:00 2001 From: Ben Banfield-Zanin Date: Fri, 1 Aug 2025 12:37:38 +0100 Subject: [PATCH] Split account-data and receipts workers --- .../synapse-all-workers-running.yaml | 4 +- .../ci/synapse-worker-example-values.yaml | 4 +- .../configs/synapse/path_map_file_get.tpl | 2 +- charts/matrix-stack/source/synapse.json | 7 +- charts/matrix-stack/source/synapse.yaml.j2 | 3 +- .../templates/synapse/_synapse_details.tpl | 30 +- charts/matrix-stack/values.schema.json | 278 +++++++++++++++++- charts/matrix-stack/values.yaml | 66 ++++- newsfragments/640.changed.md | 4 + tests/manifests/__init__.py | 3 +- 10 files changed, 378 insertions(+), 23 deletions(-) create mode 100644 newsfragments/640.changed.md diff --git a/charts/matrix-stack/ci/fragments/synapse-all-workers-running.yaml b/charts/matrix-stack/ci/fragments/synapse-all-workers-running.yaml index c30d3bc1b..0150e753c 100644 --- a/charts/matrix-stack/ci/fragments/synapse-all-workers-running.yaml +++ b/charts/matrix-stack/ci/fragments/synapse-all-workers-running.yaml @@ -4,6 +4,8 @@ synapse: workers: + account-data: + enabled: true appservice: enabled: true background: @@ -34,7 +36,7 @@ synapse: pusher: enabled: true replicas: 2 - receipts-account: + receipts: enabled: true sliding-sync: enabled: true diff --git a/charts/matrix-stack/ci/synapse-worker-example-values.yaml b/charts/matrix-stack/ci/synapse-worker-example-values.yaml index 37ca862bf..cc1a80da6 100644 --- a/charts/matrix-stack/ci/synapse-worker-example-values.yaml +++ b/charts/matrix-stack/ci/synapse-worker-example-values.yaml @@ -19,6 +19,8 @@ synapse: ingress: host: synapse.ess.localhost workers: + account-data: + enabled: true appservice: enabled: true background: @@ -49,7 +51,7 @@ synapse: pusher: enabled: true replicas: 2 - receipts-account: + receipts: enabled: true sliding-sync: enabled: true diff --git a/charts/matrix-stack/configs/synapse/path_map_file_get.tpl b/charts/matrix-stack/configs/synapse/path_map_file_get.tpl index 89e4becf4..2e3dd72fc 100644 --- a/charts/matrix-stack/configs/synapse/path_map_file_get.tpl +++ b/charts/matrix-stack/configs/synapse/path_map_file_get.tpl @@ -18,7 +18,7 @@ workers instead if these requests path are under high load. # push-rules ^/\_matrix/client/(api/v1|r0|v3|unstable)/pushrules/ -# receipts-account +# account-data ^/\_matrix/client/(r0|v3|unstable)/._/tags ^/\_matrix/client/(r0|v3|unstable)/._/account\_data diff --git a/charts/matrix-stack/source/synapse.json b/charts/matrix-stack/source/synapse.json index 485bef8c5..b21dc79da 100644 --- a/charts/matrix-stack/source/synapse.json +++ b/charts/matrix-stack/source/synapse.json @@ -184,6 +184,9 @@ "workers": { "type": "object", "properties": { + "account-data": { + "$ref": "file://synapse/single_worker.json" + }, "appservice": { "$ref": "file://synapse/single_worker.json" }, @@ -226,8 +229,8 @@ "pusher": { "$ref": "file://synapse/scalable_worker.json" }, - "receipts-account": { - "$ref": "file://synapse/single_worker.json" + "receipts": { + "$ref": "file://synapse/scalable_worker.json" }, "sliding-sync": { "$ref": "file://synapse/scalable_worker.json" diff --git a/charts/matrix-stack/source/synapse.yaml.j2 b/charts/matrix-stack/source/synapse.yaml.j2 index ea3bba7a4..296c364bb 100644 --- a/charts/matrix-stack/source/synapse.yaml.j2 +++ b/charts/matrix-stack/source/synapse.yaml.j2 @@ -51,6 +51,7 @@ appservices: [] ## event-creator: ## enabled: true workers: +{{- synapse_sub_schema_values.single_worker('account-data') | indent(2) }} {{- synapse_sub_schema_values.single_worker('appservice') | indent(2) }} {{- synapse_sub_schema_values.single_worker('background') | indent(2) }} {{- synapse_sub_schema_values.scalable_worker('client-reader') | indent(2) }} @@ -65,7 +66,7 @@ workers: {{- synapse_sub_schema_values.single_worker('presence-writer') | indent(2) }} {{- synapse_sub_schema_values.single_worker('push-rules') | indent(2) }} {{- synapse_sub_schema_values.scalable_worker('pusher') | indent(2) }} -{{- synapse_sub_schema_values.single_worker('receipts-account') | indent(2) }} +{{- synapse_sub_schema_values.scalable_worker('receipts') | indent(2) }} {{- synapse_sub_schema_values.scalable_worker('sliding-sync') | indent(2) }} {{- synapse_sub_schema_values.single_worker('sso-login') | indent(2) }} {{- synapse_sub_schema_values.scalable_worker('synchrotron') | indent(2) }} diff --git a/charts/matrix-stack/templates/synapse/_synapse_details.tpl b/charts/matrix-stack/templates/synapse/_synapse_details.tpl index 4b4f63f72..f8adc59cd 100644 --- a/charts/matrix-stack/templates/synapse/_synapse_details.tpl +++ b/charts/matrix-stack/templates/synapse/_synapse_details.tpl @@ -8,6 +8,7 @@ SPDX-License-Identifier: AGPL-3.0-only {{- $root := .root -}} {{- with required "element-io.synapse.process.hasHttp missing context" .context -}} {{ $hasHttp := (list "main" + "account-data" "client-reader" "encryption" "event-creator" @@ -17,7 +18,7 @@ SPDX-License-Identifier: AGPL-3.0-only "media-repository" "presence-writer" "push-rules" - "receipts-account" + "receipts" "sliding-sync" "sso-login" "synchrotron" @@ -33,11 +34,12 @@ hasHttp {{- $root := .root -}} {{- with required "element-io.synapse.process.hasReplication missing context" .context -}} {{- $hasReplication := (list "main" + "account-data" "encryption" "event-persister" "push-rules" "presence-writer" - "receipts-account" + "receipts" "typing-persister") }} {{- if has . $hasReplication -}} hasReplication @@ -49,13 +51,14 @@ hasReplication {{- $root := .root -}} {{- with required "element-io.synapse.process.isSingle missing context" .context -}} {{ $isSingle := (list "main" + "account-data" "appservice" "background" "encryption" "media-repository" "presence-writer" "push-rules" - "receipts-account" + "receipts" "sso-login" "typing-persister" "user-dir") }} @@ -92,8 +95,6 @@ initial-sync media-repo {{- else if eq . "presence-writer" -}} presence-write -{{- else if eq . "receipts-account" -}} -receipts-accnt {{- else if eq . "typing-persister" -}} typing {{- else -}} @@ -131,7 +132,9 @@ responsibleForMedia {{- define "element-io.synapse.process.streamWriters" -}} {{- $root := .root -}} {{- with required "element-io.synapse.process.streamWriters missing context" .context -}} -{{- if eq . "encryption" }} +{{- if eq . "account-data" }} +{{ list "account_data" | toJson }} +{{- else if eq . "encryption" }} {{ list "to_device" | toJson }} {{- else if eq . "event-persister" }} {{ list "events" | toJson }} @@ -139,8 +142,8 @@ responsibleForMedia {{ list "presence" | toJson }} {{- else if eq . "push-rules" }} {{ list "push_rules" | toJson }} -{{- else if eq . "receipts-account" }} -{{ list "account_data" "receipts" | toJson }} +{{- else if eq . "receipts" }} +{{ list "receipts" | toJson }} {{- else if eq . "typing-persister" }} {{ list "typing" | toJson }} {{- else -}} @@ -225,6 +228,13 @@ responsibleForMedia {{- with required "element-io.synapse.process.workerPaths missing context" .context -}} {{ $workerPaths := list }} +{{- if eq .workerType "account-data" }} +{{ $workerPaths = concat $workerPaths (list + "^/_matrix/client/(r0|v3|unstable)/.*/tags" + "^/_matrix/client/(r0|v3|unstable)/.*/account_data" +) }} +{{- end }} + {{- if eq .workerType "client-reader" }} {{- /* Client API requests (apart from createRoom which is eventCreator) */}} {{ $workerPaths = concat $workerPaths (list @@ -374,10 +384,8 @@ responsibleForMedia ) }} {{- end }} -{{- if eq .workerType "receipts-account" }} +{{- if eq .workerType "receipts" }} {{ $workerPaths = concat $workerPaths (list - "^/_matrix/client/(r0|v3|unstable)/.*/tags" - "^/_matrix/client/(r0|v3|unstable)/.*/account_data" "^/_matrix/client/(r0|v3|unstable)/rooms/.*/receipt" "^/_matrix/client/(r0|v3|unstable)/rooms/.*/read_markers" ) }} diff --git a/charts/matrix-stack/values.schema.json b/charts/matrix-stack/values.schema.json index 88575e867..07863d5cb 100644 --- a/charts/matrix-stack/values.schema.json +++ b/charts/matrix-stack/values.schema.json @@ -6330,6 +6330,172 @@ "workers": { "type": "object", "properties": { + "account-data": { + "properties": { + "enabled": { + "type": "boolean" + }, + "resources": { + "properties": { + "limits": { + "additionalProperties": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "string" + } + ], + "pattern": "^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$" + }, + "type": "object" + }, + "requests": { + "additionalProperties": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "string" + } + ], + "pattern": "^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$" + }, + "type": "object" + } + }, + "type": "object", + "additionalProperties": false + }, + "livenessProbe": { + "type": "object", + "properties": { + "failureThreshold": { + "type": [ + "integer", + "null" + ], + "minimum": 1 + }, + "initialDelaySeconds": { + "type": [ + "integer", + "null" + ], + "minimum": 0 + }, + "periodSeconds": { + "type": [ + "integer", + "null" + ], + "minimum": 1 + }, + "successThreshold": { + "type": [ + "integer", + "null" + ], + "minimum": 1 + }, + "timeoutSeconds": { + "type": [ + "integer", + "null" + ], + "minimum": 1 + } + }, + "additionalProperties": false + }, + "readinessProbe": { + "type": "object", + "properties": { + "failureThreshold": { + "type": [ + "integer", + "null" + ], + "minimum": 1 + }, + "initialDelaySeconds": { + "type": [ + "integer", + "null" + ], + "minimum": 0 + }, + "periodSeconds": { + "type": [ + "integer", + "null" + ], + "minimum": 1 + }, + "successThreshold": { + "type": [ + "integer", + "null" + ], + "minimum": 1 + }, + "timeoutSeconds": { + "type": [ + "integer", + "null" + ], + "minimum": 1 + } + }, + "additionalProperties": false + }, + "startupProbe": { + "type": "object", + "properties": { + "failureThreshold": { + "type": [ + "integer", + "null" + ], + "minimum": 1 + }, + "initialDelaySeconds": { + "type": [ + "integer", + "null" + ], + "minimum": 0 + }, + "periodSeconds": { + "type": [ + "integer", + "null" + ], + "minimum": 1 + }, + "successThreshold": { + "type": [ + "integer", + "null" + ], + "minimum": 1 + }, + "timeoutSeconds": { + "type": [ + "integer", + "null" + ], + "minimum": 1 + } + }, + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, "appservice": { "properties": { "enabled": { @@ -9534,11 +9700,18 @@ "type": "object", "additionalProperties": false }, - "receipts-account": { + "receipts": { + "required": [ + "replicas" + ], "properties": { "enabled": { "type": "boolean" }, + "replicas": { + "type": "integer", + "minimum": 1 + }, "resources": { "properties": { "limits": { @@ -9573,6 +9746,109 @@ "type": "object", "additionalProperties": false }, + "topologySpreadConstraints": { + "type": "array", + "items": { + "required": [ + "maxSkew", + "topologyKey" + ], + "properties": { + "labelSelector": { + "type": "object", + "properties": { + "matchExpressions": { + "type": "array", + "items": { + "type": "object", + "required": [ + "key", + "operator" + ], + "properties": { + "key": { + "type": "string" + }, + "operator": { + "type": "string", + "enum": [ + "In", + "NotIn", + "Exists", + "DoesNotExist" + ] + }, + "values": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "additionalProperties": false + } + }, + "matchLabels": { + "type": [ + "object", + "null" + ], + "additionalProperties": { + "type": [ + "string", + "null" + ] + } + } + }, + "additionalProperties": false + }, + "matchLabelKeys": { + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + } + }, + "maxSkew": { + "type": "integer", + "minium": 1 + }, + "minDomains": { + "type": "integer", + "minium": 0 + }, + "nodeAffinityPolicy": { + "type": "string", + "enum": [ + "Honor", + "Ignore" + ] + }, + "nodeTaintsPolicy": { + "type": "string", + "enum": [ + "Honor", + "Ignore" + ] + }, + "topologyKey": { + "type": "string" + }, + "whenUnsatisfiable": { + "type": "string", + "enum": [ + "DoNotSchedule", + "ScheduleAnyway" + ] + } + }, + "type": "object", + "additionalProperties": false + } + }, "livenessProbe": { "type": "object", "properties": { diff --git a/charts/matrix-stack/values.yaml b/charts/matrix-stack/values.yaml index 9893d4a75..7453e0be4 100644 --- a/charts/matrix-stack/values.yaml +++ b/charts/matrix-stack/values.yaml @@ -2454,6 +2454,61 @@ synapse: ## event-creator: ## enabled: true workers: + account-data: + ## Set to true to deploy this worker + enabled: false + + ## Resources for this worker. + ## If omitted the global Synapse resources are used + # resources: {} + ## Configuration of the thresholds and frequencies of the livenessProbe + livenessProbe: + ## How many consecutive failures for the probe to be considered failed + failureThreshold: 8 + + ## Number of seconds after the container has started before the probe starts + initialDelaySeconds: 0 + + ## How often (in seconds) to perform the probe + periodSeconds: 6 + + ## How many consecutive successes for the probe to be consider successful after having failed + successThreshold: 1 + + ## Number of seconds after which the probe times out + timeoutSeconds: 2 + ## Configuration of the thresholds and frequencies of the readinessProbe + readinessProbe: + ## How many consecutive failures for the probe to be considered failed + failureThreshold: 8 + + ## Number of seconds after the container has started before the probe starts + initialDelaySeconds: 0 + + ## How often (in seconds) to perform the probe + periodSeconds: 2 + + ## How many consecutive successes for the probe to be consider successful after having failed + successThreshold: 2 + + ## Number of seconds after which the probe times out + timeoutSeconds: 2 + ## Configuration of the thresholds and frequencies of the startupProbe + startupProbe: + ## How many consecutive failures for the probe to be considered failed + failureThreshold: 54 + + ## Number of seconds after the container has started before the probe starts + initialDelaySeconds: 0 + + ## How often (in seconds) to perform the probe + periodSeconds: 2 + + ## How many consecutive successes for the probe to be consider successful after having failed + successThreshold: 1 + + ## Number of seconds after which the probe times out + timeoutSeconds: 1 appservice: ## Set to true to deploy this worker enabled: false @@ -3248,17 +3303,20 @@ synapse: ## Number of seconds after which the probe times out timeoutSeconds: 1 - receipts-account: + receipts: ## Set to true to deploy this worker enabled: false + ## The number of replicas of this worker to run + replicas: 1 + ## Resources for this worker. ## If omitted the global Synapse resources are used # resources: {} ## Configuration of the thresholds and frequencies of the livenessProbe livenessProbe: ## How many consecutive failures for the probe to be considered failed - failureThreshold: 8 + failureThreshold: 3 ## Number of seconds after the container has started before the probe starts initialDelaySeconds: 0 @@ -3274,7 +3332,7 @@ synapse: ## Configuration of the thresholds and frequencies of the readinessProbe readinessProbe: ## How many consecutive failures for the probe to be considered failed - failureThreshold: 8 + failureThreshold: 3 ## Number of seconds after the container has started before the probe starts initialDelaySeconds: 0 @@ -3290,7 +3348,7 @@ synapse: ## Configuration of the thresholds and frequencies of the startupProbe startupProbe: ## How many consecutive failures for the probe to be considered failed - failureThreshold: 54 + failureThreshold: 21 ## Number of seconds after the container has started before the probe starts initialDelaySeconds: 0 diff --git a/newsfragments/640.changed.md b/newsfragments/640.changed.md new file mode 100644 index 000000000..abb015a8f --- /dev/null +++ b/newsfragments/640.changed.md @@ -0,0 +1,4 @@ +Split the `receipts-account` worker type into `account-data` and `receipts` workers. + +If you've configured `synapse.workers.receipts-account` this is no longer valid and your configuration should be updated to +setup `synapse.workers.account-data` and/or `synapse-workers.receipts` as appropriate. diff --git a/tests/manifests/__init__.py b/tests/manifests/__init__.py index 794d66841..435c86489 100644 --- a/tests/manifests/__init__.py +++ b/tests/manifests/__init__.py @@ -373,6 +373,7 @@ def make_synapse_worker_sub_component(worker_name: str, worker_type: str) -> Sub synapse_workers_details = tuple( make_synapse_worker_sub_component(worker_name, worker_type) for worker_name, worker_type in { + "account-data": "single", "appservice": "single", "background": "single", "client-reader": "scalable", @@ -387,7 +388,7 @@ def make_synapse_worker_sub_component(worker_name: str, worker_type: str) -> Sub "presence-writer": "single", "push-rules": "single", "pusher": "scalable", - "receipts-account": "single", + "receipts": "scalable", "sliding-sync": "scalable", "sso-login": "single", "synchrotron": "scalable",