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

Modernize configure_workers_and_start.py bootstrapping script for Dockerfile-workers. #14294

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8a28ba9
Add templating and comments for missing stream writers to configure_w…
realtyem Oct 16, 2022
52628ef
Add warning comment about non-functional stream writers.
realtyem Oct 16, 2022
2f7fedb
Add stream_writer map and instance_map handling to add_sharding_to_sh…
realtyem Oct 16, 2022
adb34bc
Remove unnecessary gating for running add_sharding_to_shared_config().
realtyem Oct 16, 2022
92a1345
Changelog
realtyem Oct 16, 2022
0c073d6
Rename add_sharding_to_shared_config to process_sharding_and_stream_w…
realtyem Oct 20, 2022
7a50f00
Merge branch 'develop' into declare-all-worker-types
realtyem Oct 21, 2022
3a03ce7
Removed outdated comment
realtyem Oct 21, 2022
d68887c
Merge branch 'develop' into declare-all-worker-types
realtyem Oct 25, 2022
9393fb7
Change all worker declarations except 'media_repository' to be 'synap…
realtyem Oct 25, 2022
ca1956d
Remove 'start_pushers' and 'send_federation' from script, as they are…
realtyem Oct 25, 2022
ce01c10
Remove comment that hasn't been true since Apr 14th, 2021.
realtyem Oct 25, 2022
6079b66
Rename function to summarize better it's function.
realtyem Oct 26, 2022
7207151
Changelog
realtyem Oct 26, 2022
d23d992
Fix rename derp.
realtyem Oct 26, 2022
8759d17
Update some comments.
realtyem Oct 26, 2022
eced528
Adjust changelog and extension.
realtyem Oct 26, 2022
7b7a928
Make media_repository shared_extra_conf consistent with other types, …
realtyem Oct 26, 2022
268674f
Need to fix linting after all.
realtyem Oct 26, 2022
31e77b0
Merge branch 'develop' into modernize-config-script-for-workers
realtyem Nov 4, 2022
7da1e19
Rename function to reivilibre's suggestion(This be a no-op when the p…
realtyem Nov 4, 2022
e113f84
Merge branch 'develop' into modernize-config-script-for-workers
realtyem Nov 8, 2022
99a206c
Because resolving conflicts on github doesn't preserve executable per…
realtyem Nov 8, 2022
aa045a6
Almost forgot to make this a show-stopper.
realtyem Nov 9, 2022
d3c24e6
Merge branch 'develop' into modernize-config-script-for-workers
realtyem Nov 9, 2022
661ad10
Remove unreachable 'continue'
realtyem Nov 9, 2022
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
1 change: 1 addition & 0 deletions changelog.d/14294.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove references to legacy worker types in the multi-worker Dockerfile.
29 changes: 14 additions & 15 deletions docker/configure_workers_and_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# * SYNAPSE_SERVER_NAME: The desired server_name of the homeserver.
# * SYNAPSE_REPORT_STATS: Whether to report stats.
# * SYNAPSE_WORKER_TYPES: A comma separated list of worker names as specified in WORKER_CONFIG
# below. Leave empty for no workers, or set to '*' for all possible workers.
# below. Leave empty for no workers.
# * SYNAPSE_AS_REGISTRATION_DIR: If specified, a directory in which .yaml and .yml files
# will be treated as Application Service registration files.
# * SYNAPSE_TLS_CERT: Path to a TLS certificate in PEM format.
Expand Down Expand Up @@ -58,10 +58,10 @@
# have to attach by instance_map to the master process and have client endpoints.
WORKERS_CONFIG: Dict[str, Dict[str, Any]] = {
"pusher": {
"app": "synapse.app.pusher",
"app": "synapse.app.generic_worker",
"listener_resources": [],
"endpoint_patterns": [],
"shared_extra_conf": {"start_pushers": False},
"shared_extra_conf": {},
"worker_extra_conf": "",
},
"user_dir": {
Expand All @@ -84,7 +84,11 @@
"^/_synapse/admin/v1/media/.*$",
"^/_synapse/admin/v1/quarantine_media/.*$",
],
"shared_extra_conf": {"enable_media_repo": False},
# The first configured media worker will run the media background jobs
"shared_extra_conf": {
"enable_media_repo": False,
"media_instance_running_background_jobs": "media_repository1",
},
"worker_extra_conf": "enable_media_repo: true",
},
"appservice": {
Expand All @@ -95,10 +99,10 @@
"worker_extra_conf": "",
},
"federation_sender": {
"app": "synapse.app.federation_sender",
"app": "synapse.app.generic_worker",
"listener_resources": [],
"endpoint_patterns": [],
"shared_extra_conf": {"send_federation": False},
"shared_extra_conf": {},
"worker_extra_conf": "",
},
"synchrotron": {
Expand Down Expand Up @@ -205,7 +209,7 @@
"worker_extra_conf": "",
},
"frontend_proxy": {
"app": "synapse.app.frontend_proxy",
"app": "synapse.app.generic_worker",
"listener_resources": ["client", "replication"],
"endpoint_patterns": ["^/_matrix/client/(api/v1|r0|v3|unstable)/keys/upload"],
"shared_extra_conf": {},
Expand Down Expand Up @@ -326,7 +330,7 @@ def add_worker_roles_to_shared_config(
worker_port: int,
) -> None:
"""Given a dictionary representing a config file shared across all workers,
append sharded worker information to it for the current worker_type instance.
append appropriate worker information to it for the current worker_type instance.

Args:
shared_config: The config dict that all worker instances share (after being converted to YAML)
Expand Down Expand Up @@ -359,7 +363,7 @@ def add_worker_roles_to_shared_config(

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

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


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

new_worker_count = worker_type_counter.setdefault(worker_type, 0) + 1
worker_type_counter[worker_type] = new_worker_count
Expand Down