diff options
author | reivilibre <oliverw@matrix.org> | 2022-05-10 11:08:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-10 11:08:45 +0100 |
commit | 699192fc1a1055a4bec2345bc80f120f28470c73 (patch) | |
tree | 60c884b99b94732c70871f30522a942ebfdd7750 /synapse | |
parent | Changelog typo (diff) | |
download | synapse-699192fc1a1055a4bec2345bc80f120f28470c73.tar.xz |
Add the `update_user_directory_from_worker` configuration option (superseding `update_user_directory`) to allow a generic worker to be designated as the worker to update the user directory. (#12654)
Co-authored-by: Shay <hillerys@element.io>
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/app/admin_cmd.py | 2 | ||||
-rw-r--r-- | synapse/app/generic_worker.py | 16 | ||||
-rw-r--r-- | synapse/config/server.py | 4 | ||||
-rw-r--r-- | synapse/config/workers.py | 7 | ||||
-rw-r--r-- | synapse/handlers/user_directory.py | 2 |
5 files changed, 9 insertions, 22 deletions
diff --git a/synapse/app/admin_cmd.py b/synapse/app/admin_cmd.py index 2b0d92cbae..2a4c2e59cd 100644 --- a/synapse/app/admin_cmd.py +++ b/synapse/app/admin_cmd.py @@ -210,7 +210,7 @@ def start(config_options: List[str]) -> None: config.logging.no_redirect_stdio = True # Explicitly disable background processes - config.server.update_user_directory = False + config.worker.should_update_user_directory = False config.worker.run_background_tasks = False config.worker.start_pushers = False config.worker.pusher_shard_config.instances = [] diff --git a/synapse/app/generic_worker.py b/synapse/app/generic_worker.py index 07dddc0b13..2a9480a5c1 100644 --- a/synapse/app/generic_worker.py +++ b/synapse/app/generic_worker.py @@ -441,22 +441,6 @@ def start(config_options: List[str]) -> None: "synapse.app.user_dir", ) - if config.worker.worker_app == "synapse.app.user_dir": - if config.server.update_user_directory: - sys.stderr.write( - "\nThe update_user_directory must be disabled in the main synapse process" - "\nbefore they can be run in a separate worker." - "\nPlease add ``update_user_directory: false`` to the main config" - "\n" - ) - sys.exit(1) - - # Force the pushers to start since they will be disabled in the main config - config.server.update_user_directory = True - else: - # For other worker types we force this to off. - config.server.update_user_directory = False - synapse.events.USE_FROZEN_DICTS = config.server.use_frozen_dicts synapse.util.caches.TRACK_MEMORY_USAGE = config.caches.track_memory_usage diff --git a/synapse/config/server.py b/synapse/config/server.py index 1e709c7cf5..005a3ee48c 100644 --- a/synapse/config/server.py +++ b/synapse/config/server.py @@ -319,10 +319,6 @@ class ServerConfig(Config): self.presence_router_config, ) = load_module(presence_router_config, ("presence", "presence_router")) - # Whether to update the user directory or not. This should be set to - # false only if we are updating the user directory in a worker - self.update_user_directory = config.get("update_user_directory", True) - # whether to enable the media repository endpoints. This should be set # to false if the media repository is running as a separate endpoint; # doing so ensures that we will not run cache cleanup jobs on the diff --git a/synapse/config/workers.py b/synapse/config/workers.py index a9dbcc6d3d..e1569b3c14 100644 --- a/synapse/config/workers.py +++ b/synapse/config/workers.py @@ -311,6 +311,13 @@ class WorkerConfig(Config): new_option_name="notify_appservices_from_worker", ) + self.should_update_user_directory = self._should_this_worker_perform_duty( + config, + legacy_master_option_name="update_user_directory", + legacy_worker_app_name="synapse.app.user_dir", + new_option_name="update_user_directory_from_worker", + ) + def _should_this_worker_perform_duty( self, config: Dict[str, Any], diff --git a/synapse/handlers/user_directory.py b/synapse/handlers/user_directory.py index 048fd4bb82..74f7fdfe6c 100644 --- a/synapse/handlers/user_directory.py +++ b/synapse/handlers/user_directory.py @@ -60,7 +60,7 @@ class UserDirectoryHandler(StateDeltasHandler): self.clock = hs.get_clock() self.notifier = hs.get_notifier() self.is_mine_id = hs.is_mine_id - self.update_user_directory = hs.config.server.update_user_directory + self.update_user_directory = hs.config.worker.should_update_user_directory self.search_all_users = hs.config.userdirectory.user_directory_search_all_users self.spam_checker = hs.get_spam_checker() # The current position in the current_state_delta stream |