diff options
author | Jason Little <realtyem@gmail.com> | 2023-03-09 04:54:03 -0600 |
---|---|---|
committer | Jason Little <realtyem@gmail.com> | 2023-03-09 04:54:03 -0600 |
commit | 97a0af000e655b5127d33986811f2cf0cfd1b0da (patch) | |
tree | 0122d376d70a8072d1aadbb0386ebecb24968479 | |
parent | Try and apply review comments about sanitizing names. (diff) | |
download | synapse-97a0af000e655b5127d33986811f2cf0cfd1b0da.tar.xz |
Move final creation of a worker name to after the final check of why it can't exist.
-rwxr-xr-x | docker/configure_workers_and_start.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/docker/configure_workers_and_start.py b/docker/configure_workers_and_start.py index 4993615ff1..296d152e5f 100755 --- a/docker/configure_workers_and_start.py +++ b/docker/configure_workers_and_start.py @@ -714,14 +714,6 @@ def parse_worker_types( # worker_base_name and # worker_types_set which is a Set of what worker_types are requested - # This counter is used for naming workers with an incrementing number. Use the - # worker_base_name for the index - worker_type_counter[worker_base_name] += 1 - - # Name workers by their type or requested name concatenated with an - # incrementing number. e.g. federation_reader1 or event_creator+event_persister1 - worker_name = worker_base_name + str(worker_type_counter[worker_base_name]) - # Now that the worker name is settled, check this worker_base_name isn't used # for a different worker_type. Make sure the worker types being checked are # deterministic. @@ -740,7 +732,7 @@ def parse_worker_types( else: error( - f"Can not use worker_name: '{worker_name}' for worker_type(s): " + f"Can not use worker_name: '{worker_base_name}' for worker_type(s): " f"'{deterministic_worker_type_string}'. It is already in use by " f"worker_type(s): '{check_worker_type}'" ) @@ -757,6 +749,14 @@ def parse_worker_types( # Not in shard counter, must not have seen it yet, add it. worker_type_shard_counter[worker_type] += 1 + # This counter is used for naming workers with an incrementing number. Use the + # worker_base_name for the index + worker_type_counter[worker_base_name] += 1 + + # Name workers by their type or requested name concatenated with an + # incrementing number. e.g. federation_reader1 or event_creator+event_persister1 + worker_name = worker_base_name + str(worker_type_counter[worker_base_name]) + # The worker has survived the gauntlet of why it can't exist. Add it to the pile dict_to_return.setdefault(worker_name, {}).setdefault( "worker_base_name", worker_base_name |