Skip to content

Commit bfc0928

Browse files
Merge pull request #569 from element-hq/gaelg/matrix-rtc-metrics
matrix-rtc: fix services monitors
2 parents 0315310 + ca62c63 commit bfc0928

12 files changed

Lines changed: 834 additions & 710 deletions

charts/matrix-stack/ci/fragments/matrix-rtc-pytest-extras.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
matrixRTC:
66
replicas: 2
7+
annotations:
8+
has-no-service-monitor: "true"
79
ingress:
810
host: mrtc.{{ $.Values.serverName }}
911
tlsSecret: "{{ $.Release.Name }}-matrix-rtc-tls"

charts/matrix-stack/ci/pytest-matrix-rtc-standalone-values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ initSecrets:
1616
matrixAuthenticationService:
1717
enabled: false
1818
matrixRTC:
19+
annotations:
20+
has-no-service-monitor: "true"
1921
extraEnv:
2022
- name: LIVEKIT_INSECURE_SKIP_VERIFY_TLS
2123
value: YES_I_KNOW_WHAT_I_AM_DOING

charts/matrix-stack/ci/pytest-matrix-rtc-synapse-wellknown-values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ initSecrets:
2828
matrixAuthenticationService:
2929
enabled: false
3030
matrixRTC:
31+
annotations:
32+
has-no-service-monitor: "true"
3133
extraEnv:
3234
- name: LIVEKIT_INSECURE_SKIP_VERIFY_TLS
3335
value: YES_I_KNOW_WHAT_I_AM_DOING

charts/matrix-stack/templates/matrix-rtc/authorisation_service_monitor.yaml

Lines changed: 0 additions & 30 deletions
This file was deleted.

charts/matrix-stack/templates/matrix-rtc/sfu_service.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{- /*
2-
Copyright 2024 New Vector Ltd
2+
Copyright 2024-2025 New Vector Ltd
33

44
SPDX-License-Identifier: AGPL-3.0-only
55
*/ -}}
@@ -21,6 +21,9 @@ spec:
2121
- name: http
2222
port: 7880
2323
targetPort: http
24+
- name: metrics
25+
port: 6789
26+
targetPort: metrics
2427
selector:
2528
app.kubernetes.io/instance: "{{ $.Release.Name }}-matrix-rtc-sfu"
2629
{{- end -}}

charts/matrix-stack/templates/matrix-rtc/sfu_service_monitor.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{- /*
2-
Copyright 2024 New Vector Ltd
2+
Copyright 2024-2025 New Vector Ltd
33

44
SPDX-License-Identifier: AGPL-3.0-only
55
*/ -}}
@@ -20,7 +20,7 @@ metadata:
2020
spec:
2121
endpoints:
2222
- interval: 30s
23-
port: http
23+
port: metrics
2424
selector:
2525
matchLabels:
2626
app.kubernetes.io/part-of: matrix-stack

newsfragments/569.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
matrix-rtc: Fix service monitors deployed.

poetry.lock

Lines changed: 686 additions & 672 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ types-pytz = "^2025.2.0.20250516"
3737
mypy = "^1.16.1"
3838
types-pyyaml = "^6.0.12.20250516"
3939
semver = "^3.0.4"
40+
prometheus-client = "^0.22.1"
4041

4142
[build-system]
4243
requires = ["poetry-core"]

tests/integration/lib/helpers.py

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@
66
import time
77

88
import pyhelm3
9+
from lightkube import AsyncClient
10+
from lightkube.models.core_v1 import (
11+
Capabilities,
12+
Container,
13+
PodSpec,
14+
SeccompProfile,
15+
SecurityContext,
16+
)
917
from lightkube.models.meta_v1 import ObjectMeta
10-
from lightkube.resources.core_v1 import ConfigMap, Endpoints, Namespace, Secret
18+
from lightkube.resources.core_v1 import ConfigMap, Endpoints, Namespace, Pod, Secret
1119

1220
from ..artifacts import CertKey, generate_cert
1321
from .utils import merge
@@ -98,3 +106,63 @@ async def get_deployment_marker(kube_client, generated_data, marker: str):
98106
name=f"{generated_data.release_name}-markers",
99107
)
100108
return configmap.data.get(marker)
109+
110+
111+
async def run_pod_with_args(kube_client: AsyncClient, namespace, image_name, pod_name, args):
112+
pod = Pod(
113+
metadata=ObjectMeta(name=pod_name + "-" + str(int(time.time() * 1000)), namespace=namespace),
114+
spec=PodSpec(
115+
restartPolicy="Never",
116+
containers=[
117+
Container(
118+
name="cmd",
119+
image=image_name,
120+
args=args,
121+
securityContext=SecurityContext(
122+
seccompProfile=SeccompProfile(type="RuntimeDefault"),
123+
capabilities=Capabilities(drop=["ALL"]),
124+
readOnlyRootFilesystem=True,
125+
allowPrivilegeEscalation=False,
126+
runAsNonRoot=True,
127+
runAsUser=3000,
128+
runAsGroup=3000,
129+
),
130+
)
131+
],
132+
),
133+
)
134+
assert pod.metadata
135+
assert pod.metadata.name
136+
assert pod.metadata.namespace
137+
try:
138+
await kube_client.create(pod)
139+
start_time = time.time()
140+
now = time.time()
141+
completed = False
142+
while start_time + 30 > now and not completed:
143+
found_pod = await kube_client.get(Pod, name=pod.metadata.name, namespace=pod.metadata.namespace)
144+
if (
145+
found_pod.status
146+
and found_pod.status.containerStatuses
147+
and found_pod.status.containerStatuses[0].lastState
148+
and found_pod.status.containerStatuses[0].lastState.terminated
149+
and found_pod.status.containerStatuses[0].lastState.terminated.reason == "Completed"
150+
):
151+
completed = True
152+
else:
153+
now = time.time()
154+
await asyncio.sleep(1)
155+
else:
156+
if start_time + 30 > now:
157+
raise RuntimeError(
158+
f"Pod {pod.metadata.name} did not start in time "
159+
f"(failed after {time.time() - now} seconds), "
160+
f"pod status: {found_pod.status}"
161+
)
162+
163+
log_lines = ""
164+
async for log_line in kube_client.log(pod.metadata.name, namespace=pod.metadata.namespace, container="cmd"):
165+
log_lines += log_line
166+
return log_lines
167+
finally:
168+
await kube_client.delete(Pod, name=pod.metadata.name, namespace=namespace)

0 commit comments

Comments
 (0)