From 69df322f406a75b98b6926e3745f648325f54e73 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Sun, 15 Mar 2026 00:22:32 +0200 Subject: [PATCH] matrix-synapse: split client_reader routes into grouped regexes The client_reader route bucket had collapsed into one long alternation, which made small worker-audit edits hard to review. Any endpoint change rewrote the whole regex and obscured whether we were changing routing policy or just maintaining the route list. Refactor the variable into grouped regex entries with comments instead. This keeps the current specialized-worker policy intact: nginx still renders the client_reader locations in the same block, and the routes still target the same upstream bucket. The goal here is to make future doc/code audits, additions, and removals mechanical and reviewable. This also matches MDAD's current worker model, where generic workers are not mixed with the specialized room/sync/client/federation reader routing buckets, so there is no need to derive this from the generic worker map. Refs: - https://github.com/element-hq/synapse/blob/b99a58719b274fcbb327fd8d7649185792bfd12c/docs/workers.md#historical-apps - https://github.com/element-hq/synapse/blob/b99a58719b274fcbb327fd8d7649185792bfd12c/docs/workers.md#synapseappgeneric_worker --- roles/custom/matrix-synapse/vars/main.yml | 26 ++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/roles/custom/matrix-synapse/vars/main.yml b/roles/custom/matrix-synapse/vars/main.yml index 96e29f8e7..1a9416404 100644 --- a/roles/custom/matrix-synapse/vars/main.yml +++ b/roles/custom/matrix-synapse/vars/main.yml @@ -31,7 +31,31 @@ matrix_synapse_workers_sync_worker_client_server_endpoints: # Client reader workers handle generic client-server endpoints that don't contain a roomid or sync matrix_synapse_workers_client_reader_client_server_endpoints: - - ^/_matrix/client/(api/v1|r0|v3|unstable)/(room_keys/|keys/(query|changes|claim|room_keys/)|login|register(/available|/m.login.registration_token/validity|)|password_policy|profile|rooms/.*/(joined_members|context/.*|members|state|hierarchy|relations/|event/|aliases|timestamp_to_event|redact|send|state/|(join|invite|leave|ban|unban|kick))|createRoom|publicRooms|account/(3pid|whoami|deactivate)|versions|voip/turnServer|joined_rooms|search|user/.*/filter(/|$)|directory/room/.*|capabilities)|^/_matrix/client/unstable/org.matrix.msc4143/rtc/transports$ + # Keep these as grouped regex entries instead of a single huge alternation. + # This preserves the existing specialized-routing policy while making future audits + # and endpoint-specific edits reviewable. + + # Encryption and room-key APIs + - ^/_matrix/client/(api/v1|r0|v3|unstable)/room_keys/ + - ^/_matrix/client/(api/v1|r0|v3|unstable)/keys/(query|changes|claim|room_keys/) + + # Login, registration, account, and profile APIs + - ^/_matrix/client/(api/v1|r0|v3|unstable)/login + - ^/_matrix/client/(api/v1|r0|v3|unstable)/register(/available|/m.login.registration_token/validity|)? + - ^/_matrix/client/(api/v1|r0|v3|unstable)/password_policy + - ^/_matrix/client/(api/v1|r0|v3|unstable)/profile + - ^/_matrix/client/(api/v1|r0|v3|unstable)/account/(3pid|whoami|deactivate) + + # Room-scoped client APIs handled by client readers in the specialized-worker model + - ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/(joined_members|context/.*|members|state|hierarchy|relations/|event/|aliases|timestamp_to_event|redact|send|state/|(join|invite|leave|ban|unban|kick)) + + # Generic client discovery and lookup APIs + - ^/_matrix/client/(api/v1|r0|v3|unstable)/(createRoom|publicRooms|versions|voip/turnServer|joined_rooms|search|directory/room/.*|capabilities) + - ^/_matrix/client/(api/v1|r0|v3|unstable)/user/.*/filter(/|$) + + # MatrixRTC transport discovery: + # Ref: https://github.com/element-hq/synapse/blob/b99a58719b274fcbb327fd8d7649185792bfd12c/synapse/rest/client/matrixrtc.py#L30-L52 + - ^/_matrix/client/unstable/org.matrix.msc4143/rtc/transports$ # Federation reader workers handle generic federation endpoints that don't contain a roomid matrix_synapse_workers_federation_reader_federation_endpoints: