Skip to content
This repository was archived by the owner on Aug 24, 2026. It is now read-only.

Commit 393437e

Browse files
committed
Allow live edit of homeserver config file
This is achieved by adding an initContainer that copies the homeserver.yaml from the read-only configMap to the writable PV. Fix #36 Assisted-by: claude-4-sonnet Signed-off-by: Matthias Goerens <mgoerens@redhat.com>
1 parent 7b771c4 commit 393437e

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

internal/controller/synapse/synapse/synapse_controller_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,15 +456,15 @@ var _ = Describe("Integration tests for the Synapse controller", Ordered, Label(
456456
By("Checking that a Synapse Deployment exists and is correctly configured")
457457
checkResourcePresence(createdDeployment, synapseLookupKey, expectedOwnerReference)
458458

459-
By("Checking that initContainers contains the required environment variables")
459+
By("Checking that initContainer for generating config file contains the required environment variables")
460460
envVars := []corev1.EnvVar{{
461461
Name: "SYNAPSE_SERVER_NAME",
462462
Value: ServerName,
463463
}, {
464464
Name: "SYNAPSE_REPORT_STATS",
465465
Value: utils.BoolToYesNo(ReportStats),
466466
}}
467-
Expect(createdDeployment.Spec.Template.Spec.InitContainers[0].Env).Should(ContainElements(envVars))
467+
Expect(createdDeployment.Spec.Template.Spec.InitContainers[1].Env).Should(ContainElements(envVars))
468468
})
469469

470470
It("Should create a Synapse Service", func() {
@@ -557,15 +557,15 @@ var _ = Describe("Integration tests for the Synapse controller", Ordered, Label(
557557
By("Checking that a Synapse Deployment exists and is correctly configured")
558558
checkResourcePresence(createdDeployment, synapseLookupKey, expectedOwnerReference)
559559

560-
By("Checking that initContainers contains the required environment variables")
560+
By("Checking that initContainer for generating config file contains the required environment variables")
561561
envVars := []corev1.EnvVar{{
562562
Name: "SYNAPSE_SERVER_NAME",
563563
Value: ServerName,
564564
}, {
565565
Name: "SYNAPSE_REPORT_STATS",
566566
Value: utils.BoolToYesNo(ReportStats),
567567
}}
568-
Expect(createdDeployment.Spec.Template.Spec.InitContainers[0].Env).Should(ContainElements(envVars))
568+
Expect(createdDeployment.Spec.Template.Spec.InitContainers[1].Env).Should(ContainElements(envVars))
569569
})
570570

571571
It("Should create a Synapse Service", func() {

internal/templates/synapse_deployment.yaml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,31 @@ spec:
2121
serviceAccountName: {{ .Values.Name }}
2222
{{- end }}
2323
initContainers:
24+
# Copy homeserver.yaml from read-only ConfigMap to writable PV
25+
# This allows manual editing of the configuration
26+
- image: registry.access.redhat.com/ubi8/ubi-minimal:8.10
27+
name: "copy-homeserver-config"
28+
args:
29+
- if [ ! -f /data/homeserver.yaml ]; then cp /data-homeserver/homeserver.yaml /data/homeserver.yaml; fi
30+
command:
31+
- bin/sh
32+
- -c
33+
volumeMounts:
34+
- name: homeserver
35+
mountPath: /data-homeserver
36+
- name: data-pv
37+
mountPath: /data
2438
- image: "matrixdotorg/synapse:v1.133.0"
2539
name: "synapse-generate"
2640
args: [ "generate" ]
2741
env:
2842
- name: SYNAPSE_CONFIG_PATH
29-
value: /data-homeserver/homeserver.yaml
43+
value: /data/homeserver.yaml
3044
- name: SYNAPSE_SERVER_NAME
3145
value: {{ .Values.Status.HomeserverConfiguration.ServerName }}
3246
- name: SYNAPSE_REPORT_STATS
3347
value: {{ if .Values.Status.HomeserverConfiguration.ReportStats }}"yes"{{ else }}"no"{{ end }}
3448
volumeMounts:
35-
- name: homeserver
36-
mountPath: /data-homeserver
3749
- name: data-pv
3850
mountPath: /data
3951
{{ if .Values.Status.Bridges.MautrixSignal.Enabled -}}
@@ -53,7 +65,7 @@ spec:
5365
name: "synapse"
5466
env:
5567
- name: SYNAPSE_CONFIG_PATH
56-
value: /data-homeserver/homeserver.yaml
68+
value: /data/homeserver.yaml
5769
volumeMounts:
5870
- name: homeserver
5971
mountPath: /data-homeserver

0 commit comments

Comments
 (0)