From d1d727c7521d12f9c04019d422a5bfc01490bd30 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Fri, 20 Oct 2023 14:00:16 +0200 Subject: [PATCH] Add quorum queues support for service This change implements and enables by default quorum support for rabbitmq as well as providing default variables to globally tune it's behaviour. In order to ensure upgrade path and ability to switch back to HA queues we change vhost names with removing leading `/`, as enabling quorum requires to remove exchange which is tricky thing to do with running services. Change-Id: I78c71cb33f456cfd8d255446d708a1a957e32440 --- defaults/main.yml | 13 ++++++++++++- templates/trove.conf.j2 | 7 +++++-- vars/main.yml | 11 +++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 3bba31d..a23f854 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -133,7 +133,13 @@ trove_oslomsg_rpc_servers: "{{ oslomsg_rpc_servers | default('127.0.0.1') }}" trove_oslomsg_rpc_port: "{{ oslomsg_rpc_port | default('5672') }}" trove_oslomsg_rpc_use_ssl: "{{ oslomsg_rpc_use_ssl | default(False) }}" trove_oslomsg_rpc_userid: trove -trove_oslomsg_rpc_vhost: /trove +# vhost name depends on value of oslomsg_rabbit_quorum_queues. In case quorum queues +# are not used - vhost name will be prefixed with leading `/`. +trove_oslomsg_rpc_vhost: + - name: /trove + state: "{{ trove_oslomsg_rabbit_quorum_queues | ternary('absent', 'present') }}" + - name: trove + state: "{{ trove_oslomsg_rabbit_quorum_queues | ternary('present', 'absent') }}" trove_oslomsg_rpc_ssl_version: "{{ oslomsg_rpc_ssl_version | default('TLSv1_2') }}" trove_oslomsg_rpc_ssl_ca_file: "{{ oslomsg_rpc_ssl_ca_file | default('') }}" @@ -150,6 +156,11 @@ trove_oslomsg_notify_vhost: "{{ trove_oslomsg_rpc_vhost }}" trove_oslomsg_notify_ssl_version: "{{ oslomsg_notify_ssl_version | default('TLSv1_2') }}" trove_oslomsg_notify_ssl_ca_file: "{{ oslomsg_notify_ssl_ca_file | default('') }}" +## RabbitMQ integration +trove_oslomsg_rabbit_quorum_queues: "{{ oslomsg_rabbit_quorum_queues | default(True) }}" +trove_oslomsg_rabbit_quorum_delivery_limit: "{{ oslomsg_rabbit_quorum_delivery_limit | default(0) }}" +trove_oslomsg_rabbit_quorum_max_memory_bytes: "{{ oslomsg_rabbit_quorum_max_memory_bytes | default(0) }}" + ## Qdrouterd integration # TODO(ansmith): Change structure when more backends will be supported trove_oslomsg_amqp1_enabled: "{{ trove_oslomsg_rpc_transport == 'amqp' }}" diff --git a/templates/trove.conf.j2 b/templates/trove.conf.j2 index 1d9865d..4476d03 100644 --- a/templates/trove.conf.j2 +++ b/templates/trove.conf.j2 @@ -13,7 +13,7 @@ trove_conductor_workers={{ trove_conductor_workers }} taskmanager_manager = trove.taskmanager.manager.Manager -transport_url = {{ trove_oslomsg_rpc_transport }}://{% for host in trove_oslomsg_rpc_servers.split(',') %}{{ trove_oslomsg_rpc_userid }}:{{ trove_oslomsg_rpc_password }}@{{ host }}:{{ trove_oslomsg_rpc_port }}{% if not loop.last %},{% else %}/{{ trove_oslomsg_rpc_vhost }}{% if trove_oslomsg_rpc_use_ssl | bool %}?ssl=1&ssl_version={{ trove_oslomsg_rpc_ssl_version }}&ssl_ca_file={{ trove_oslomsg_rpc_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} +transport_url = {{ trove_oslomsg_rpc_transport }}://{% for host in trove_oslomsg_rpc_servers.split(',') %}{{ trove_oslomsg_rpc_userid }}:{{ trove_oslomsg_rpc_password }}@{{ host }}:{{ trove_oslomsg_rpc_port }}{% if not loop.last %},{% else %}/{{ _trove_oslomsg_rpc_vhost_conf }}{% if trove_oslomsg_rpc_use_ssl | bool %}?ssl=1&ssl_version={{ trove_oslomsg_rpc_ssl_version }}&ssl_ca_file={{ trove_oslomsg_rpc_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} {# There must be a blank line above or the following line will be appended to the previous. #} control_exchange = {{ trove_control_exchange }} @@ -126,6 +126,9 @@ enabled = {{ trove_profiler_enabled }} [oslo_messaging_rabbit] ssl = {{ trove_oslomsg_rpc_use_ssl }} +rabbit_quorum_queue = {{ trove_oslomsg_rabbit_quorum_queues }} +rabbit_quorum_delivery_limit = {{ trove_oslomsg_rabbit_quorum_delivery_limit }} +rabbit_quorum_max_memory_bytes = {{ trove_oslomsg_rabbit_quorum_max_memory_bytes }} [oslo_messaging_notifications] {% set notification_topics = [] %} @@ -137,4 +140,4 @@ ssl = {{ trove_oslomsg_rpc_use_ssl }} {% endif %} topics = {{ notification_topics | join(',') }} driver = {{ (notification_topics | length > 0) | ternary('messagingv2', 'noop') }} -transport_url = {{ trove_oslomsg_notify_transport }}://{% for host in trove_oslomsg_notify_servers.split(',') %}{{ trove_oslomsg_notify_userid }}:{{ trove_oslomsg_notify_password }}@{{ host }}:{{ trove_oslomsg_notify_port }}{% if not loop.last %},{% else %}/{{ trove_oslomsg_notify_vhost }}{% if trove_oslomsg_notify_use_ssl | bool %}?ssl=1&ssl_version={{ trove_oslomsg_notify_ssl_version }}&ssl_ca_file={{ trove_oslomsg_notify_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} +transport_url = {{ trove_oslomsg_notify_transport }}://{% for host in trove_oslomsg_notify_servers.split(',') %}{{ trove_oslomsg_notify_userid }}:{{ trove_oslomsg_notify_password }}@{{ host }}:{{ trove_oslomsg_notify_port }}{% if not loop.last %},{% else %}/{{ _trove_oslomsg_notify_vhost_conf }}{% if trove_oslomsg_notify_use_ssl | bool %}?ssl=1&ssl_version={{ trove_oslomsg_notify_ssl_version }}&ssl_ca_file={{ trove_oslomsg_notify_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} diff --git a/vars/main.yml b/vars/main.yml index 0d363ed..2f96935 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -24,6 +24,17 @@ _trove_conductor_is_first_play_host: >- inventory_hostname == (groups[trove_services['trove-conductor']['group']] | intersect(ansible_play_hosts)) | first) | bool }} +_trove_oslomsg_rpc_vhost_conf: >- + {{ + (trove_oslomsg_rpc_vhost is string) | ternary( + trove_oslomsg_rpc_vhost, trove_oslomsg_rpc_vhost | selectattr('state', 'eq', 'present') | map(attribute='name') | first) + }} +_trove_oslomsg_notify_vhost_conf: >- + {{ + (trove_oslomsg_notify_vhost is string) | ternary( + trove_oslomsg_notify_vhost, trove_oslomsg_notify_vhost | selectattr('state', 'eq', 'present') | map(attribute='name') | first) + }} + filtered_trove_services: |- {% set services = [] %} {% for key, value in trove_services.items() %}