From 53c2003cc55e17ae3d46e57e43f88032a7f315b8 Mon Sep 17 00:00:00 2001 From: Nicolas Bonneval Date: Mon, 26 Jul 2021 18:29:17 +0200 Subject: [PATCH] matrix-synapse: Add support for extra postgresql args Allows passing extra arguments to the pqlib library upon connection, for instance to set keepalive settings, as documented in: https://github.com/matrix-org/synapse/blob/develop/docs/postgres.md#synapse-config --- charts/matrix-synapse/Chart.yaml | 2 +- charts/matrix-synapse/templates/_helpers.tpl | 19 +++++++++++++ charts/matrix-synapse/templates/secrets.yaml | 2 ++ charts/matrix-synapse/values.yaml | 30 ++++++++++++++++++++ 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/charts/matrix-synapse/Chart.yaml b/charts/matrix-synapse/Chart.yaml index 2a3836c..68d3e12 100644 --- a/charts/matrix-synapse/Chart.yaml +++ b/charts/matrix-synapse/Chart.yaml @@ -6,7 +6,7 @@ icon: https://matrix.org/images/matrix-logo.svg appVersion: 1.38.1 type: application -version: 2.1.4 +version: 2.1.5 maintainers: - name: Alexander Olofsson email: ace@haxalot.com diff --git a/charts/matrix-synapse/templates/_helpers.tpl b/charts/matrix-synapse/templates/_helpers.tpl index aa70880..de6e027 100644 --- a/charts/matrix-synapse/templates/_helpers.tpl +++ b/charts/matrix-synapse/templates/_helpers.tpl @@ -197,6 +197,25 @@ Set postgresql sslmode {{- end -}} {{- end -}} + +{{/* +Set postgresql extra args +Refer to https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS +for a list of options that can be passed. +*/}} +{{- define "matrix-synapse.postgresql.extraArgs" -}} +{{- if .Values.postgresql.enabled -}} +{{- with .Values.postgresql.extraArgs }} + {{- . | toYaml }} +{{- end }} +{{- else -}} +{{- with .Values.externalPostgresql.extraArgs }} + {{- . | toYaml }} +{{- end }} +{{- end -}} +{{- end -}} + + {{/* Set redis host */}} diff --git a/charts/matrix-synapse/templates/secrets.yaml b/charts/matrix-synapse/templates/secrets.yaml index 02f3aea..3cdb3ed 100644 --- a/charts/matrix-synapse/templates/secrets.yaml +++ b/charts/matrix-synapse/templates/secrets.yaml @@ -36,6 +36,7 @@ stringData: {{- $postgresPort := include "matrix-synapse.postgresql.port" . }} {{- $postgresPass := include "matrix-synapse.postgresql.password" . }} {{- $postgresSSLMode := include "matrix-synapse.postgresql.sslmode" . }} +{{- $postgresExtraArgs := include "matrix-synapse.postgresql.extraArgs" . }} ## Database configuration ## @@ -54,6 +55,7 @@ stringData: sslmode: {{ $postgresSSLMode | quote }} cp_min: 5 cp_max: 10 + {{- $postgresExtraArgs | nindent 8 }} {{- $redisHost := include "matrix-synapse.redis.host" . }} {{- $redisPort := include "matrix-synapse.redis.port" . }} diff --git a/charts/matrix-synapse/values.yaml b/charts/matrix-synapse/values.yaml index 4e0b181..a32c63b 100644 --- a/charts/matrix-synapse/values.yaml +++ b/charts/matrix-synapse/values.yaml @@ -597,6 +597,21 @@ postgresql: # storageClass: "-" size: 16Gi + ## Extra arguments for the database connection + ## ref: https://github.com/matrix-org/synapse/blob/develop/docs/postgres.md#synapse-config + ## + extraArgs: {} + # # seconds of inactivity after which TCP should send a keepalive message to the server + # keepalives_idle: 10 + # + # # the number of seconds after which a TCP keepalive message that is not + # # acknowledged by the server should be retransmitted + # keepalives_interval: 10 + # + # # the number of TCP keepalives that can be lost before the client's connection + # # to the server is considered dead + # keepalives_count: 3 + ## An externally configured Postgres server to use for Synapse's database, note ## that the database needs to have both COLLATE and CTYPE set to "C". ## @@ -608,6 +623,21 @@ externalPostgresql: database: synapse # sslmode: prefer + ## Extra arguments for the database connection + ## ref: https://github.com/matrix-org/synapse/blob/develop/docs/postgres.md#synapse-config + ## + extraArgs: {} + # # seconds of inactivity after which TCP should send a keepalive message to the server + # keepalives_idle: 10 + # + # # the number of seconds after which a TCP keepalive message that is not + # # acknowledged by the server should be retransmitted + # keepalives_interval: 10 + # + # # the number of TCP keepalives that can be lost before the client's connection + # # to the server is considered dead + # keepalives_count: 3 + ## This configuration is for the internal Redis that's deployed for use with ## workers/sharding, for an external Redis server you want to set enabled to ## false and configure the externalRedis block.