-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow Synapse worker list to be generated dynamically
This leads to much easier management and potential safety features (validation). In the future, we could try to avoid port conflicts as well, but it didn't seem worth the effort to do it now. Our port ranges seem large enough. This can also pave the way for a "presets" feature (similar to `matrix_nginx_proxy_ssl_presets`) which makes it even easier for people to configure worker counts.
- Loading branch information
1 parent
43059bb
commit 85a05f3
Showing
4 changed files
with
147 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# Below is a huge hack for dynamically building a list of workers and finally assigning it to `matrix_synapse_workers_enabled_list`. | ||
# | ||
# set_fact within a loop does not work reliably in Ansible (it only executes on the first iteration for some reason), | ||
# so we're forced to do something much uglier. | ||
|
||
- name: Build generic workers | ||
set_fact: | ||
worker: | ||
type: 'generic_worker' | ||
port: "{{ matrix_synapse_workers_generic_workers_port_range_start + item }}" | ||
metrics_port: "{{ matrix_synapse_workers_generic_workers_metrics_range_start + item }}" | ||
register: "matrix_synapse_workers_list_results_generic_workers" | ||
loop: "{{ range(0, matrix_synapse_workers_generic_workers_count)|list }}" | ||
|
||
- name: Build federation sender workers | ||
set_fact: | ||
worker: | ||
type: 'federation_sender' | ||
port: 0 | ||
metrics_port: "{{ matrix_synapse_workers_federation_sender_workers_metrics_range_start + item }}" | ||
register: "matrix_synapse_workers_list_results_federation_sender_workers" | ||
loop: "{{ range(0, matrix_synapse_workers_federation_sender_workers_count)|list }}" | ||
|
||
# This type of worker can only have a count of 1, at most | ||
- name: Build pusher workers | ||
set_fact: | ||
worker: | ||
type: 'pusher' | ||
port: 0 | ||
metrics_port: "{{ matrix_synapse_workers_pusher_workers_metrics_range_start + item }}" | ||
register: "matrix_synapse_workers_list_results_pusher_workers" | ||
loop: "{{ range(0, matrix_synapse_workers_pusher_workers_count)|list }}" | ||
|
||
# This type of worker can only have a count of 1, at most | ||
- name: Build appservice workers | ||
set_fact: | ||
worker: | ||
type: 'appservice' | ||
port: 0 | ||
metrics_port: "{{ matrix_synapse_workers_appservice_workers_metrics_range_start + item }}" | ||
register: "matrix_synapse_workers_list_results_appservice_workers" | ||
loop: "{{ range(0, matrix_synapse_workers_appservice_workers_count)|list }}" | ||
|
||
- name: Build media_repository workers | ||
set_fact: | ||
worker: | ||
type: 'media_repository' | ||
port: "{{ matrix_synapse_workers_media_repository_workers_port_range_start + item }}" | ||
metrics_port: "{{ matrix_synapse_workers_media_repository_workers_metrics_range_start + item }}" | ||
register: "matrix_synapse_workers_list_results_media_repository_workers" | ||
loop: "{{ range(0, matrix_synapse_workers_media_repository_workers_count)|list }}" | ||
|
||
- name: Build frontend_proxy workers | ||
set_fact: | ||
worker: | ||
type: 'frontend_proxy' | ||
port: "{{ matrix_synapse_workers_frontend_proxy_workers_port_range_start + item }}" | ||
metrics_port: "{{ matrix_synapse_workers_frontend_proxy_workers_metrics_range_start + item }}" | ||
register: "matrix_synapse_workers_list_results_frontend_proxy_workers" | ||
loop: "{{ range(0, matrix_synapse_workers_frontend_proxy_workers_count)|list }}" | ||
|
||
- set_fact: | ||
matrix_synapse_dynamic_workers_list: "{{ matrix_synapse_dynamic_workers_list|default([]) + [item.ansible_facts.worker] }}" | ||
with_items: | | ||
{{ | ||
matrix_synapse_workers_list_results_generic_workers.results | ||
+ | ||
matrix_synapse_workers_list_results_federation_sender_workers.results | ||
+ | ||
matrix_synapse_workers_list_results_pusher_workers.results | ||
+ | ||
matrix_synapse_workers_list_results_appservice_workers.results | ||
+ | ||
matrix_synapse_workers_list_results_media_repository_workers.results | ||
+ | ||
matrix_synapse_workers_list_results_frontend_proxy_workers.results | ||
}} | ||
- set_fact: | ||
matrix_synapse_workers_enabled_list: "{{ matrix_synapse_dynamic_workers_list }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters