Skip to content

Minor fixes #248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/matrix-stack/templates/ess-library/_pods.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ tolerations:

{{- define "element-io.ess-library.pods.topologySpreadConstraints" -}}
{{- $root := .root -}}
{{- with required "element-io.ess-libary.pods.topologySpreadConstraints missing context" .context -}}
{{- with required "element-io.ess-library.pods.topologySpreadConstraints missing context" .context -}}
{{- $labelSelector := (dict "matchLabels" (dict "app.kubernetes.io/instance" (printf "%s-%s" $root.Release.Name .instanceSuffix))) }}
{{- $matchLabelKeys := .deployment | ternary (list "pod-template-hash") list }}
{{- $defaultConstraintSettings := dict "labelSelector" $labelSelector "matchLabelKeys" $matchLabelKeys "whenUnsatisfiable" "DoNotSchedule" }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
{{- define "element-io.ess-library.serviceAccountName" -}}
{{- $root := .root -}}
{{- with required "element-io.ess-library.serviceAccountName missing context" .context -}}
{{ default (printf "%s-%s" $root.Release.Name (required "element-io.ess-library.serviceAccount missing context.key" .key)) .serviceAccount.name }}
{{ default (printf "%s-%s" $root.Release.Name (required "element-io.ess-library.serviceAccountName missing context.key" .key)) .serviceAccount.name }}
{{- end }}
{{- end }}

Expand Down
4 changes: 2 additions & 2 deletions charts/matrix-stack/templates/postgres/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ true

{{- define "element-io.postgres.anyEssPasswordHasValue" }}
{{- $root := .root -}}
{{- with required "element-io.postgres.configSecrets missing context" .context -}}
{{- with required "element-io.postgres.anyEssPasswordHasValue missing context" .context -}}
{{- range .essPasswords -}}
{{- if .value -}}
true
Expand Down Expand Up @@ -65,7 +65,7 @@ true

{{- define "element-io.postgres.memoryLimitsMB" -}}
{{- $root := .root -}}
{{- with required "element-io.postgres.configSecrets missing context" .context -}}
{{- with required "element-io.postgres.memoryLimitsMB missing context" .context -}}
{{- $value := .resources.limits.memory }}
{{- if $value | hasSuffix "Mi" }}
{{- printf "%d" (trimSuffix "Mi" $value) | int64 -}}
Expand Down
3 changes: 2 additions & 1 deletion charts/matrix-stack/templates/synapse/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ app.kubernetes.io/version: {{ .image.tag }}
{{- define "element-io.synapse.matrixToolsEnv" }}
{{- $root := .root -}}
{{- with required "element-io.synapse.matrixToolsEnv missing context" .context -}}
{{- $isHook := required "element-io.synapse.matrixToolsEnv requires context.isHook" .isHook }}
- name: SYNAPSE_POSTGRES_PASSWORD
value: >-
{{
Expand All @@ -155,7 +156,7 @@ app.kubernetes.io/version: {{ .image.tag }}
"essPassword" "synapse"
"initSecretKey" "POSTGRES_SYNAPSE_PASSWORD"
"secretProperty" .postgres.password
"defaultSecretName" (printf "%s-synapse" $root.Release.Name)
"defaultSecretName" (printf "%s-synapse%s" $root.Release.Name ($isHook | ternary "-hook" ""))
"defaultSecretKey" "POSTGRES_PASSWORD"
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial

{{- define "element-io.synapse.configmap-name" }}
{{- $root := .root }}
{{- with required "element-io.synapse.configmap-data requires context" .context }}
{{- $isHook := required "element-io.synapse.configmap-data requires context.isHook" .isHook }}
{{- with required "element-io.synapse.configmap-name requires context" .context }}
{{- $isHook := required "element-io.synapse.configmap-name requires context.isHook" .isHook }}
{{- if $isHook }}
{{- $root.Release.Name }}-synapse-hook
{{- else }}
Expand Down
4 changes: 2 additions & 2 deletions charts/matrix-stack/templates/synapse/_synapse_details.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ responsibleForMedia

{{- define "element-io.synapse.process.workerPaths" -}}
{{- $root := .root -}}
{{- with required "element-io.synapse.workerPaths missing context" .context -}}
{{- with required "element-io.synapse.process.workerPaths missing context" .context -}}
{{ $workerPaths := list }}

{{- if eq .workerType "client-reader" }}
Expand Down Expand Up @@ -333,7 +333,7 @@ responsibleForMedia
{{- end }}

{{- if eq .workerType "push-rules" }}
{{ $workerPaths = append $workerPaths (list
{{ $workerPaths = concat $workerPaths (list
"^/_matrix/client/(api/v1|r0|v3|unstable)/pushrules/"
"^/_matrix/client/unstable/org.matrix.msc4140/delayed_events"
) }}
Expand Down
20 changes: 10 additions & 10 deletions charts/matrix-stack/templates/synapse/_synapse_pod.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ We have an init container to render & merge the config for several reasons:
{{- end }}
{{- with .containersSecurityContext }}
securityContext:
{{- toYaml . | nindent 10 }}
{{- toYaml . | nindent 8 }}
{{- end }}
command:
- "/matrix-tools"
Expand All @@ -85,11 +85,11 @@ We have an init container to render & merge the config for several reasons:
- /config-templates/05-{{ $processType }}.yaml
{{- end }}
env:
{{- include "element-io.synapse.matrixToolsEnv" (dict "root" $root "context" .) | nindent 10 }}
{{- include "element-io.synapse.env" (dict "root" $root "context" .) | nindent 10 }}
{{- include "element-io.synapse.matrixToolsEnv" (dict "root" $root "context" .) | nindent 8 }}
{{- include "element-io.synapse.env" (dict "root" $root "context" .) | nindent 8 }}
{{- with .resources }}
resources:
{{- toYaml . | nindent 10 }}
{{- toYaml . | nindent 8 }}
{{- end }}
volumeMounts:
- mountPath: /config-templates
Expand All @@ -116,7 +116,7 @@ We have an init container to render & merge the config for several reasons:
{{- end }}
{{- with .containersSecurityContext }}
securityContext:
{{- toYaml . | nindent 10 }}
{{- toYaml . | nindent 8 }}
{{- end }}
command:
- "/matrix-tools"
Expand All @@ -125,7 +125,7 @@ We have an init container to render & merge the config for several reasons:
- {{ include "element-io.ess-library.postgres-host-port" (dict "root" $root "context" (dict "postgres" .postgres)) | quote }}
{{- with .resources }}
resources:
{{- toYaml . | nindent 10 }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
containers:
Expand All @@ -141,7 +141,7 @@ We have an init container to render & merge the config for several reasons:
{{- end }}
{{- with .containersSecurityContext }}
securityContext:
{{- toYaml . | nindent 10 }}
{{- toYaml . | nindent 8 }}
{{- end }}
command:
- "python3"
Expand All @@ -150,8 +150,8 @@ We have an init container to render & merge the config for several reasons:
- "-c"
- /conf/homeserver.yaml
env:
{{- include "element-io.synapse.pythonEnv" (dict "root" $root "context" .) | nindent 10 }}
{{- include "element-io.synapse.env" (dict "root" $root "context" .) | nindent 10 }}
{{- include "element-io.synapse.pythonEnv" (dict "root" $root "context" .) | nindent 8 }}
{{- include "element-io.synapse.env" (dict "root" $root "context" .) | nindent 8 }}
{{- if not $isHook }}
ports:
{{- if (include "element-io.synapse.process.hasHttp" (dict "root" $root "context" $processType)) }}
Expand Down Expand Up @@ -196,7 +196,7 @@ We have an init container to render & merge the config for several reasons:
{{- end }}
{{- with .resources }}
resources:
{{- toYaml . | nindent 10 }}
{{- toYaml . | nindent 8 }}
{{- end }}
volumeMounts:
{{- range $secret := include "element-io.synapse.configSecrets" (dict "root" $root "context" .) | fromJsonArray }}
Expand Down
1 change: 1 addition & 0 deletions newsfragments/248.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix Secret name in the config check job for the Postgres password when provided in the Helm values file.
4 changes: 3 additions & 1 deletion tests/manifests/test_configs_and_mounts_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ def get_keys_from_container_using_rendered_config(template, templates, other_sec
configmap = get_configmap(templates, current_volume["configMap"]["name"])
_, keys = get_mounts_part(configmap, volume_mount)
mounted_keys += keys
assert len(mounted_keys) > 0
assert len(mounted_keys) > 0, (
f"No secret or config map is mounted in the template {template['kind']}/{template['metadata']['name']}"
)
return mounted_keys


Expand Down
4 changes: 3 additions & 1 deletion tests/manifests/test_volumes_mounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ async def test_volumes_mounts_exists(templates, other_secrets):
assert volume["secret"]["secretName"] in secrets_names
if "configMap" in volume:
assert volume["configMap"]["name"] in configmaps_names
for container in template["spec"]["template"]["spec"].get("containers", []) + template["spec"].get(
for container in template["spec"]["template"]["spec"].get("containers", []) + template["spec"]["template"][
"spec"
].get(
"initContainers",
[],
):
Expand Down
Loading