Skip to content

Commit

Permalink
Upgrade Synapse (v1.66.0 -> 1.67.0) and remove frontend_proxy workers
Browse files Browse the repository at this point in the history
`frontend_proxy` workers have been superseded by `generic_worker` workers.
Related to matrix-org/synapse#13645
  • Loading branch information
spantaleev committed Sep 13, 2022
1 parent 11f2cda commit f122066
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 80 deletions.
1 change: 0 additions & 1 deletion group_vars/matrix_servers
Original file line number Diff line number Diff line change
Expand Up @@ -1762,7 +1762,6 @@ matrix_nginx_proxy_synapse_generic_worker_client_server_locations: "{{ matrix_sy
matrix_nginx_proxy_synapse_generic_worker_federation_locations: "{{ matrix_synapse_workers_generic_worker_federation_endpoints }}"
matrix_nginx_proxy_synapse_media_repository_locations: "{{matrix_synapse_workers_media_repository_endpoints|default([]) }}"
matrix_nginx_proxy_synapse_user_dir_locations: "{{ matrix_synapse_workers_user_dir_endpoints|default([]) }}"
matrix_nginx_proxy_synapse_frontend_proxy_locations: "{{ matrix_synapse_workers_frontend_proxy_endpoints|default([]) }}"

matrix_nginx_proxy_systemd_wanted_services_list: |
{{
Expand Down
1 change: 0 additions & 1 deletion roles/matrix-nginx-proxy/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,6 @@ matrix_nginx_proxy_synapse_generic_worker_client_server_locations: []
matrix_nginx_proxy_synapse_generic_worker_federation_locations: []
matrix_nginx_proxy_synapse_media_repository_locations: []
matrix_nginx_proxy_synapse_user_dir_locations: []
matrix_nginx_proxy_synapse_frontend_proxy_locations: []

# synapse content caching
matrix_nginx_proxy_synapse_cache_enabled: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
{% set generic_workers = matrix_nginx_proxy_synapse_workers_list | selectattr('type', 'equalto', 'generic_worker') | list %}
{% set media_repository_workers = matrix_nginx_proxy_synapse_workers_list | selectattr('type', 'equalto', 'media_repository') | list %}
{% set user_dir_workers = matrix_nginx_proxy_synapse_workers_list | selectattr('type', 'equalto', 'user_dir') | list %}
{% set frontend_proxy_workers = matrix_nginx_proxy_synapse_workers_list | selectattr('type', 'equalto', 'frontend_proxy') | list %}
{% if matrix_nginx_proxy_synapse_workers_enabled %}
{% if matrix_nginx_proxy_synapse_cache_enabled %}
proxy_cache_path {{ matrix_nginx_proxy_synapse_cache_path }} levels=1:2 keys_zone={{ matrix_nginx_proxy_synapse_cache_keys_zone_name }}:{{ matrix_nginx_proxy_synapse_cache_keys_zone_size }} inactive={{ matrix_nginx_proxy_synapse_cache_inactive_time }} max_size={{ matrix_nginx_proxy_synapse_cache_max_size_mb }}m;
Expand All @@ -26,18 +25,6 @@
}
{% endif %}

{% if frontend_proxy_workers %}
upstream frontend_proxy_upstream {
{% for worker in frontend_proxy_workers %}
{% if matrix_nginx_proxy_enabled %}
server "matrix-synapse-worker-{{ worker.type }}-{{ worker.instanceId }}:{{ worker.port }}";
{% else %}
server "127.0.0.1:{{ worker.port }}";
{% endif %}
{% endfor %}
}
{% endif %}

{% if media_repository_workers %}
upstream media_repository_upstream {
{% for worker in media_repository_workers %}
Expand Down Expand Up @@ -120,23 +107,6 @@ server {
}
{% endfor %}
{% endif %}

{% if frontend_proxy_workers %}
# https://github.com/matrix-org/synapse/blob/master/docs/workers.md#synapseappfrontend_proxy
{% for location in matrix_nginx_proxy_synapse_frontend_proxy_locations %}
location ~ {{ location }} {
proxy_pass http://frontend_proxy_upstream$request_uri;
proxy_set_header Host $host;
}
{% endfor %}
{% if matrix_nginx_proxy_synapse_presence_disabled %}
# FIXME: keep in sync with synapse workers documentation manually
location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/presence/[^/]+/status {
proxy_pass http://frontend_proxy_upstream$request_uri;
proxy_set_header Host $host;
}
{% endif %}
{% endif %}
{# Workers redirects END #}
{% endif %}

Expand Down
8 changes: 1 addition & 7 deletions roles/matrix-synapse/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ matrix_synapse_container_image_self_build_repo: "https://github.com/matrix-org/s

matrix_synapse_docker_image: "{{ matrix_synapse_docker_image_name_prefix }}matrixdotorg/synapse:{{ matrix_synapse_docker_image_tag }}"
matrix_synapse_docker_image_name_prefix: "{{ 'localhost/' if matrix_synapse_container_image_self_build else matrix_container_global_registry_prefix }}"
matrix_synapse_version: v1.66.0
matrix_synapse_version: v1.67.0
matrix_synapse_docker_image_tag: "{{ matrix_synapse_version }}"
matrix_synapse_docker_image_force_pull: "{{ matrix_synapse_docker_image.endswith(':latest') }}"

Expand Down Expand Up @@ -398,7 +398,6 @@ matrix_synapse_workers_presets:
federation_sender_workers_count: 1
media_repository_workers_count: 0
user_dir_workers_count: 0
frontend_proxy_workers_count: 0
one-of-each:
generic_workers_count: 1
pusher_workers_count: 1
Expand All @@ -410,7 +409,6 @@ matrix_synapse_workers_presets:
# user_dir workers are deprecated since Synapse v1.59. This will be removed.
# See: https://github.com/matrix-org/synapse/blob/v1.59.0/docs/upgrade.md#deprecation-of-the-synapseappappservice-and-synapseappuser_dir-worker-application-types
user_dir_workers_count: 0
frontend_proxy_workers_count: 1

# Controls whether the matrix-synapse container exposes the various worker ports
# (see `port` and `metrics_port` in `matrix_synapse_workers_enabled_list`) outside of the container.
Expand Down Expand Up @@ -452,10 +450,6 @@ matrix_synapse_workers_user_dir_workers_count: 0
matrix_synapse_workers_user_dir_workers_port_range_start: 18661
matrix_synapse_workers_user_dir_workers_metrics_range_start: 19661

matrix_synapse_workers_frontend_proxy_workers_count: "{{ matrix_synapse_workers_presets[matrix_synapse_workers_preset]['frontend_proxy_workers_count'] }}"
matrix_synapse_workers_frontend_proxy_workers_port_range_start: 18771
matrix_synapse_workers_frontend_proxy_workers_metrics_range_start: 19771

# Default list of workers to spawn.
#
# Unless you populate this manually, this list is dynamically generated
Expand Down
12 changes: 0 additions & 12 deletions roles/matrix-synapse/tasks/synapse/workers/init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,6 @@
register: "matrix_synapse_workers_list_results_media_repository_workers"
loop: "{{ range(0, matrix_synapse_workers_media_repository_workers_count | int) | list }}"

- name: Build frontend_proxy workers
ansible.builtin.set_fact:
worker:
type: 'frontend_proxy'
instanceId: "{{ matrix_synapse_workers_frontend_proxy_workers_port_range_start + item }}"
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 | int) | list }}"

- ansible.builtin.set_fact:
matrix_synapse_dynamic_workers_list: "{{ matrix_synapse_dynamic_workers_list | default([]) + [item.ansible_facts.worker] }}"
with_items: |
Expand All @@ -79,8 +69,6 @@
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
}}
- ansible.builtin.set_fact:
Expand Down
3 changes: 3 additions & 0 deletions roles/matrix-synapse/tasks/validate_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
- {'old': 'matrix_synapse_version_arm64', 'new': '<superseded by matrix_synapse_version - see https://github.com/matrix-org/synapse/pull/11810>'}
- {'old': 'matrix_synapse_enable_group_creation', 'new': '<removed in Synapse v1.61.0 - use the new Spaces feature instead>'}
- {'old': 'matrix_synapse_account_threepid_delegates_email', 'new': '<removed in Synapse v1.66.0 - make sure to configure email settings for Synapse - see https://matrix-org.github.io/synapse/v1.66/upgrade.html#delegation-of-email-validation-no-longer-supported>'}
- {'old': 'matrix_synapse_workers_frontend_proxy_workers_count', 'new': '<removed in favor of generic workers - see https://github.com/matrix-org/synapse/pull/13645>'}
- {'old': 'matrix_synapse_workers_frontend_proxy_workers_port_range_start', 'new': '<removed in favor of generic workers - see https://github.com/matrix-org/synapse/pull/13645>'}
- {'old': 'matrix_synapse_workers_frontend_proxy_workers_metrics_range_start', 'new': '<removed in favor of generic workers - see https://github.com/matrix-org/synapse/pull/13645>'}

- name: (Deprecation) Catch and report renamed settings in matrix_synapse_configuration_extension_yaml
ansible.builtin.fail:
Expand Down
4 changes: 2 additions & 2 deletions roles/matrix-synapse/templates/synapse/worker.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ worker_replication_http_port: {{ matrix_synapse_replication_http_port }}

{% set http_resources = [] %}

{% if matrix_synapse_worker_details.type in ['generic_worker', 'frontend_proxy', 'user_dir'] %}
{% if matrix_synapse_worker_details.type in ['generic_worker', 'user_dir'] %}
{% set http_resources = http_resources + ['client'] %}
{% endif %}
{% if matrix_synapse_worker_details.type in ['generic_worker'] %}
Expand All @@ -38,7 +38,7 @@ worker_listeners:
{% endif %}
{% endif %}

{% if matrix_synapse_worker_details.type == 'frontend_proxy' %}
{% if matrix_synapse_worker_details.type == 'generic_worker' %}
worker_main_http_uri: http://matrix-synapse:{{ matrix_synapse_container_client_api_port }}
{% endif %}

Expand Down
29 changes: 2 additions & 27 deletions roles/matrix-synapse/vars/workers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ matrix_synapse_workers_generic_worker_endpoints:
- ^/_matrix/client/(api/v1|r0|v3|unstable)/search$

# Encryption requests
# Note that ^/_matrix/client/(r0|v3|unstable)/keys/upload/ requires `worker_main_http_uri`
- ^/_matrix/client/(r0|v3|unstable)/keys/query$
- ^/_matrix/client/(r0|v3|unstable)/keys/changes$
- ^/_matrix/client/(r0|v3|unstable)/keys/claim$
- ^/_matrix/client/(r0|v3|unstable)/room_keys/
- ^/_matrix/client/(r0|v3|unstable)/keys/upload/

# Registration/login requests
- ^/_matrix/client/(api/v1|r0|v3|unstable)/login$
Expand Down Expand Up @@ -172,7 +174,6 @@ matrix_synapse_workers_generic_worker_endpoints:

# Additionally, the writing of specific streams (such as events) can be moved off
# of the main process to a particular worker.
# (This is only supported with Redis-based replication.)

# To enable this, the worker must have a HTTP replication listener configured,
# have a `worker_name` and be listed in the `instance_map` config. The same worker
Expand Down Expand Up @@ -432,35 +433,9 @@ matrix_synapse_workers_user_dir_endpoints:
# If `update_user_directory` is set to `false`, and this worker is not running,
# the above endpoint may give outdated results.

matrix_synapse_workers_frontend_proxy_endpoints:
# Proxies some frequently-requested client endpoints to add caching and remove
# load from the main synapse. It can handle REST endpoints matching the following
# regular expressions:

- ^/_matrix/client/(r0|v3|unstable)/keys/upload

# If `use_presence` is False in the homeserver config, it can also handle REST
# endpoints matching the following regular expressions:

# FIXME: ADDITIONAL CONDITIONS REQUIRED: to be enabled manually
# ^/_matrix/client/(api/v1|r0|v3|unstable)/presence/[^/]+/status

# This "stub" presence handler will pass through `GET` request but make the
# `PUT` effectively a no-op.

# It will proxy any requests it cannot handle to the main synapse instance. It
# must therefore be configured with the location of the main instance, via
# the `worker_main_http_uri` setting in the `frontend_proxy` worker configuration
# file. For example:

# ```yaml
# worker_main_http_uri: http://127.0.0.1:8008
# ```

matrix_synapse_workers_avail_list:
- appservice
- federation_sender
- frontend_proxy
- generic_worker
- media_repository
- pusher
Expand Down

0 comments on commit f122066

Please sign in to comment.