Skip to content

Commit 0ae5375

Browse files
chore(MSC3911): Complement (#139)
Lot of things going on here: 1. Enable the new `media_repo_instances` list for media workers 2. Add the new test package directory in Complement 3. Turn on `msc3911_enabled` 4. Make sure to route to workers when that mode is enabled There is an additional temporary commit to be removed before merging. It exists to override the branch name of Complement to pull for testing. Once this is merged it should automatically allow the Synapse branch of `msc3911` to target `msc3911` branch on the Complement repo. Other branches/PRs should pull from the `main` branch, unless there exists a branch of exactly the same name on both repos. E.g. if my PR has the branch name `jason/cool-fixes` it will search for that exact same branch name on Complement before falling back to `main`
2 parents d713ba0 + f65fb91 commit 0ae5375

File tree

5 files changed

+26
-6
lines changed

5 files changed

+26
-6
lines changed

.ci/scripts/checkout_complement.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ for BRANCH_NAME in "$GITHUB_HEAD_REF" "$GITHUB_BASE_REF" "${GITHUB_REF#refs/head
2121
continue
2222
fi
2323

24-
(wget -O - "https://github.com/matrix-org/complement/archive/$BRANCH_NAME.tar.gz" | tar -xz --strip-components=1 -C complement) && break
24+
(wget -O - "https://github.com/famedly/complement/archive/$BRANCH_NAME.tar.gz" | tar -xz --strip-components=1 -C complement) && break
2525
done

.github/workflows/famedly-tests.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- uses: Swatinem/rust-cache@68b3cb7503c78e67dae8373749990a220eb65352
2626
- uses: matrix-org/setup-python-poetry@v2
2727
with:
28-
python-version: "3.x"
28+
python-version: "3.13"
2929
poetry-version: "2.1.1"
3030
extras: "all"
3131
- run: poetry run scripts-dev/generate_sample_config.sh --check
@@ -49,7 +49,7 @@ jobs:
4949
- uses: actions/checkout@v4
5050
- uses: actions/setup-python@v5
5151
with:
52-
python-version: "3.x"
52+
python-version: "3.13"
5353
- run: .ci/scripts/check_lockfile.py
5454

5555
lint:
@@ -63,6 +63,7 @@ jobs:
6363
uses: matrix-org/setup-python-poetry@v2
6464
with:
6565
poetry-version: "2.1.1"
66+
python-version: "3.13"
6667
install-project: "false"
6768

6869
- name: Run ruff check
@@ -91,6 +92,7 @@ jobs:
9192
# https://github.com/matrix-org/synapse/pull/15376#issuecomment-1498983775
9293
# To make CI green, err towards caution and install the project.
9394
install-project: "true"
95+
python-version: "3.13"
9496
poetry-version: "2.1.1"
9597

9698
# Cribbed from
@@ -124,6 +126,7 @@ jobs:
124126
- uses: matrix-org/setup-python-poetry@v2
125127
with:
126128
poetry-version: "2.1.1"
129+
python-version: "3.13"
127130
extras: "all"
128131
- run: poetry run scripts-dev/check_pydantic_models.py
129132

@@ -161,7 +164,7 @@ jobs:
161164
- uses: actions/checkout@v4
162165
- uses: actions/setup-python@v5
163166
with:
164-
python-version: "3.x"
167+
python-version: "3.13"
165168
- run: "pip install rstcheck"
166169
- run: "rstcheck --report-level=WARNING README.rst"
167170

docker/complement/conf/workers-shared-extra.yaml.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ experimental_features:
129129
msc3984_appservice_key_query: true
130130
# Invite filtering
131131
msc4155_enabled: true
132+
# Media Attachment
133+
msc3911_enabled: true
132134

133135
server_notices:
134136
system_mxid_localpart: _server

docker/configure_workers_and_start.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,15 @@
117117
},
118118
"media_repository": {
119119
"app": "synapse.app.generic_worker",
120-
"listener_resources": ["media", "client"],
120+
"listener_resources": ["media", "client", "replication"],
121121
"endpoint_patterns": [
122122
"^/_matrix/media/",
123123
"^/_synapse/admin/v1/purge_media_cache$",
124124
"^/_synapse/admin/v1/room/.*/media.*$",
125125
"^/_synapse/admin/v1/user/.*/media.*$",
126126
"^/_synapse/admin/v1/media/.*$",
127127
"^/_synapse/admin/v1/quarantine_media/.*$",
128-
"^/_matrix/client/v1/media/.*$",
128+
"^/_matrix/client/(v1|unstable/.*)/media/.*$",
129129
"^/_matrix/federation/v1/media/.*$",
130130
],
131131
# The first configured media worker will run the media background jobs
@@ -448,6 +448,9 @@ def add_worker_roles_to_shared_config(
448448
if "federation_sender" in worker_types_set:
449449
shared_config.setdefault("federation_sender_instances", []).append(worker_name)
450450

451+
if "media_repository" in worker_types_set:
452+
shared_config.setdefault("media_repo_instances", []).append(worker_name)
453+
451454
# Update the list of stream writers. It's convenient that the name of the worker
452455
# type is the same as the stream to write. Iterate over the whole list in case there
453456
# is more than one.
@@ -468,6 +471,17 @@ def add_worker_roles_to_shared_config(
468471
"host": "localhost",
469472
"port": worker_port,
470473
}
474+
if worker == "media_repository":
475+
# Just like for stream_writers, media workers now need to be on the instance_map
476+
if os.environ.get("SYNAPSE_USE_UNIX_SOCKET", False):
477+
instance_map[worker_name] = {
478+
"path": f"/run/worker.{worker_port}",
479+
}
480+
else:
481+
instance_map[worker_name] = {
482+
"host": "localhost",
483+
"port": worker_port,
484+
}
471485

472486

473487
def merge_worker_template_configs(

scripts-dev/complement.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ test_packages=(
230230
./tests/msc3967
231231
./tests/msc4140
232232
./tests/msc4155
233+
./tests/msc3911
233234
)
234235

235236
# Enable dirty runs, so tests will reuse the same container where possible.

0 commit comments

Comments
 (0)