diff --git a/charts/matrix-stack/configs/synapse/partial-haproxy.cfg.tpl b/charts/matrix-stack/configs/synapse/partial-haproxy.cfg.tpl index afa1ae88..858cfe77 100644 --- a/charts/matrix-stack/configs/synapse/partial-haproxy.cfg.tpl +++ b/charts/matrix-stack/configs/synapse/partial-haproxy.cfg.tpl @@ -1,6 +1,6 @@ {{- /* Copyright 2024-2025 New Vector Ltd -Copyright 2025 Element Creations Ltd +Copyright 2025-2026 Element Creations Ltd SPDX-License-Identifier: AGPL-3.0-only */ -}} @@ -237,7 +237,7 @@ backend synapse-{{ $workerType }} timeout queue 5s {{- end }} -{{- $maxInstances := ternary 20 1 (hasKey $workerDetails "replicas") }} +{{- $maxInstances := ternary 1 20 (eq "single" (include "element-io.synapse.process.scalingType" (dict "root" $root "context" $workerType))) }} {{- $workerTypeName := include "element-io.synapse.process.workerTypeName" (dict "root" $root "context" $workerType) }} # Use DNS SRV service discovery on the headless service server-template {{ $workerTypeName }} {{ $maxInstances }} _synapse-http._tcp.{{ $root.Release.Name }}-synapse-{{ $workerTypeName }}.{{ $root.Release.Namespace }}.svc.{{ $root.Values.clusterDomain }} resolvers kubedns init-addr none check diff --git a/charts/matrix-stack/configs/synapse/synapse-04-homeserver-overrides.yaml.tpl b/charts/matrix-stack/configs/synapse/synapse-04-homeserver-overrides.yaml.tpl index f32ff4f9..4dfc8587 100644 --- a/charts/matrix-stack/configs/synapse/synapse-04-homeserver-overrides.yaml.tpl +++ b/charts/matrix-stack/configs/synapse/synapse-04-homeserver-overrides.yaml.tpl @@ -193,7 +193,7 @@ instance_map: {{- range $workerType, $workerDetails := $enabledWorkers }} {{- if include "element-io.synapse.process.hasReplication" (dict "root" $root "context" $workerType) }} {{- $workerTypeName := include "element-io.synapse.process.workerTypeName" (dict "root" $root "context" $workerType) }} -{{- range $index := untilStep 0 ($workerDetails.replicas | int | default 1) 1 }} +{{- range $index := untilStep 0 ($workerDetails.replicas | int) 1 }} {{ $root.Release.Name }}-synapse-{{ $workerTypeName }}-{{ $index }}: host: {{ $root.Release.Name }}-synapse-{{ $workerTypeName }}-{{ $index }}.{{ $root.Release.Name }}-synapse-{{ $workerTypeName }}.{{ $root.Release.Namespace }}.svc.{{ $root.Values.clusterDomain }} port: 9093 @@ -232,7 +232,7 @@ stream_writers: {{- if eq $stream_writer "quarantined_media_changes" }} - main {{- end }} -{{- range $index := untilStep 0 ($workerDetails.replicas | int | default 1) 1 }} +{{- range $index := untilStep 0 ($workerDetails.replicas | int) 1 }} - {{ $root.Release.Name }}-synapse-{{ $workerTypeName }}-{{ $index }} {{- end }} {{- end }} diff --git a/charts/matrix-stack/templates/synapse/_synapse_details.tpl b/charts/matrix-stack/templates/synapse/_synapse_details.tpl index 55747d3f..c16b3d37 100644 --- a/charts/matrix-stack/templates/synapse/_synapse_details.tpl +++ b/charts/matrix-stack/templates/synapse/_synapse_details.tpl @@ -24,6 +24,31 @@ hasReplication {{- end -}} {{- end }} + +{{- define "element-io.synapse.process.scalingType" -}} +{{- $root := .root -}} +{{- with required "element-io.synapse.process.scalingType missing context" .context -}} +{{- $singleWorkers := list + "account-data" + "appservice" + "background" + "encryption" + "media-repository" + "presence-writer" + "push-rules" + "sso-login" + "typing-persister" + "user-dir" +-}} +{{- if has . $singleWorkers -}} +single +{{- else -}} +statically_scalable +{{- end }} +{{- end }} +{{- end }} + + {{- define "element-io.synapse.process.canFallbackToMain" -}} {{- $root := .root -}} {{- with required "element-io.synapse.process.canFallbackToMain missing context" .context -}}