Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit e9cbddc

Browse files
authored
Modernize configure_workers_and_start.py bootstrapping script for Dockerfile-workers. (#14294)
1 parent 0cf48f2 commit e9cbddc

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

changelog.d/14294.docker

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove references to legacy worker types in the multi-worker Dockerfile.

docker/configure_workers_and_start.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# * SYNAPSE_SERVER_NAME: The desired server_name of the homeserver.
2121
# * SYNAPSE_REPORT_STATS: Whether to report stats.
2222
# * SYNAPSE_WORKER_TYPES: A comma separated list of worker names as specified in WORKER_CONFIG
23-
# below. Leave empty for no workers, or set to '*' for all possible workers.
23+
# below. Leave empty for no workers.
2424
# * SYNAPSE_AS_REGISTRATION_DIR: If specified, a directory in which .yaml and .yml files
2525
# will be treated as Application Service registration files.
2626
# * SYNAPSE_TLS_CERT: Path to a TLS certificate in PEM format.
@@ -58,10 +58,10 @@
5858
# have to attach by instance_map to the master process and have client endpoints.
5959
WORKERS_CONFIG: Dict[str, Dict[str, Any]] = {
6060
"pusher": {
61-
"app": "synapse.app.pusher",
61+
"app": "synapse.app.generic_worker",
6262
"listener_resources": [],
6363
"endpoint_patterns": [],
64-
"shared_extra_conf": {"start_pushers": False},
64+
"shared_extra_conf": {},
6565
"worker_extra_conf": "",
6666
},
6767
"user_dir": {
@@ -84,7 +84,11 @@
8484
"^/_synapse/admin/v1/media/.*$",
8585
"^/_synapse/admin/v1/quarantine_media/.*$",
8686
],
87-
"shared_extra_conf": {"enable_media_repo": False},
87+
# The first configured media worker will run the media background jobs
88+
"shared_extra_conf": {
89+
"enable_media_repo": False,
90+
"media_instance_running_background_jobs": "media_repository1",
91+
},
8892
"worker_extra_conf": "enable_media_repo: true",
8993
},
9094
"appservice": {
@@ -95,10 +99,10 @@
9599
"worker_extra_conf": "",
96100
},
97101
"federation_sender": {
98-
"app": "synapse.app.federation_sender",
102+
"app": "synapse.app.generic_worker",
99103
"listener_resources": [],
100104
"endpoint_patterns": [],
101-
"shared_extra_conf": {"send_federation": False},
105+
"shared_extra_conf": {},
102106
"worker_extra_conf": "",
103107
},
104108
"synchrotron": {
@@ -205,7 +209,7 @@
205209
"worker_extra_conf": "",
206210
},
207211
"frontend_proxy": {
208-
"app": "synapse.app.frontend_proxy",
212+
"app": "synapse.app.generic_worker",
209213
"listener_resources": ["client", "replication"],
210214
"endpoint_patterns": ["^/_matrix/client/(api/v1|r0|v3|unstable)/keys/upload"],
211215
"shared_extra_conf": {},
@@ -326,7 +330,7 @@ def add_worker_roles_to_shared_config(
326330
worker_port: int,
327331
) -> None:
328332
"""Given a dictionary representing a config file shared across all workers,
329-
append sharded worker information to it for the current worker_type instance.
333+
append appropriate worker information to it for the current worker_type instance.
330334
331335
Args:
332336
shared_config: The config dict that all worker instances share (after being converted to YAML)
@@ -359,7 +363,7 @@ def add_worker_roles_to_shared_config(
359363

360364
elif worker_type in ["account_data", "presence", "receipts", "to_device", "typing"]:
361365
# Update the list of stream writers
362-
# It's convienent that the name of the worker type is the same as the event stream
366+
# It's convenient that the name of the worker type is the same as the stream to write
363367
shared_config.setdefault("stream_writers", {}).setdefault(
364368
worker_type, []
365369
).append(worker_name)
@@ -371,10 +375,6 @@ def add_worker_roles_to_shared_config(
371375
"port": worker_port,
372376
}
373377

374-
elif worker_type == "media_repository":
375-
# The first configured media worker will run the media background jobs
376-
shared_config.setdefault("media_instance_running_background_jobs", worker_name)
377-
378378

379379
def generate_base_homeserver_config() -> None:
380380
"""Starts Synapse and generates a basic homeserver config, which will later be
@@ -483,8 +483,7 @@ def generate_worker_files(
483483
if worker_config:
484484
worker_config = worker_config.copy()
485485
else:
486-
log(worker_type + " is an unknown worker type! It will be ignored")
487-
continue
486+
error(worker_type + " is an unknown worker type! Please fix!")
488487

489488
new_worker_count = worker_type_counter.setdefault(worker_type, 0) + 1
490489
worker_type_counter[worker_type] = new_worker_count

0 commit comments

Comments
 (0)