From 9adc5586ad716f2075916f36cbd8f73d95d39c70 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Fri, 20 Oct 2023 11:31:04 +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. Depends-On: https://review.opendev.org/c/openstack/openstack-ansible/+/919714 Depends-On: https://review.opendev.org/c/openstack/openstack-ansible/+/919702 Change-Id: I02302332819be71346a256a86ae58fed3892279a --- defaults/main.yml | 13 ++++++++++++- templates/manila.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 ac9fdbc..f96b084 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -83,7 +83,13 @@ manila_oslomsg_rpc_servers: "{{ oslomsg_rpc_servers | default('127.0.0.1') }}" manila_oslomsg_rpc_port: "{{ oslomsg_rpc_port | default('5672') }}" manila_oslomsg_rpc_use_ssl: "{{ oslomsg_rpc_use_ssl | default(False) }}" manila_oslomsg_rpc_userid: manila -manila_oslomsg_rpc_vhost: /manila +# vhost name depends on value of oslomsg_rabbit_quorum_queues. In case quorum queues +# are not used - vhost name will be prefixed with leading `/`. +manila_oslomsg_rpc_vhost: + - name: /manila + state: "{{ manila_oslomsg_rabbit_quorum_queues | ternary('absent', 'present') }}" + - name: manila + state: "{{ manila_oslomsg_rabbit_quorum_queues | ternary('present', 'absent') }}" manila_oslomsg_rpc_ssl_version: "{{ oslomsg_rpc_ssl_version | default('TLSv1_2') }}" manila_oslomsg_rpc_ssl_ca_file: "{{ oslomsg_rpc_ssl_ca_file | default('') }}" @@ -100,6 +106,11 @@ manila_oslomsg_notify_vhost: "{{ manila_oslomsg_rpc_vhost }}" manila_oslomsg_notify_ssl_version: "{{ oslomsg_notify_ssl_version | default('TLSv1_2') }}" manila_oslomsg_notify_ssl_ca_file: "{{ oslomsg_notify_ssl_ca_file | default('') }}" +## RabbitMQ integration +manila_oslomsg_rabbit_quorum_queues: "{{ oslomsg_rabbit_quorum_queues | default(True) }}" +manila_oslomsg_rabbit_quorum_delivery_limit: "{{ oslomsg_rabbit_quorum_delivery_limit | default(0) }}" +manila_oslomsg_rabbit_quorum_max_memory_bytes: "{{ oslomsg_rabbit_quorum_max_memory_bytes | default(0) }}" + ## (Qdrouterd) integration # TODO(evrardjp): Change structure when more backends will be supported manila_oslomsg_amqp1_enabled: "{{ manila_oslomsg_rpc_transport == 'amqp' }}" diff --git a/templates/manila.conf.j2 b/templates/manila.conf.j2 index 077ff46..331fd27 100644 --- a/templates/manila.conf.j2 +++ b/templates/manila.conf.j2 @@ -20,7 +20,7 @@ api_paste_config = /etc/manila/api-paste.ini executor_thread_pool_size = {{ manila_rpc_executor_thread_pool_size }} rpc_response_timeout = {{ manila_rpc_response_timeout }} -transport_url = {{ manila_oslomsg_rpc_transport }}://{% for host in manila_oslomsg_rpc_servers.split(',') %}{{ manila_oslomsg_rpc_userid }}:{{ manila_oslomsg_rpc_password }}@{{ host }}:{{ manila_oslomsg_rpc_port }}{% if not loop.last %},{% else %}/{{ manila_oslomsg_rpc_vhost }}{% if manila_oslomsg_rpc_use_ssl | bool %}?ssl=1&ssl_version={{ manila_oslomsg_rpc_ssl_version }}&ssl_ca_file={{ manila_oslomsg_rpc_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} +transport_url = {{ manila_oslomsg_rpc_transport }}://{% for host in manila_oslomsg_rpc_servers.split(',') %}{{ manila_oslomsg_rpc_userid }}:{{ manila_oslomsg_rpc_password }}@{{ host }}:{{ manila_oslomsg_rpc_port }}{% if not loop.last %},{% else %}/{{ _manila_oslomsg_rpc_vhost_conf }}{% if manila_oslomsg_rpc_use_ssl | bool %}?ssl=1&ssl_version={{ manila_oslomsg_rpc_ssl_version }}&ssl_ca_file={{ manila_oslomsg_rpc_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} ## Quota quota_shares = {{ manila_quota_shares }} @@ -55,10 +55,13 @@ connection_recycle_time = {{ manila_db_connection_recycle_time }} [oslo_messaging_rabbit] ssl = {{ manila_oslomsg_rpc_use_ssl }} +rabbit_quorum_queue = {{ manila_oslomsg_rabbit_quorum_queues }} +rabbit_quorum_delivery_limit = {{ manila_oslomsg_rabbit_quorum_delivery_limit }} +rabbit_quorum_max_memory_bytes = {{ manila_oslomsg_rabbit_quorum_max_memory_bytes }} [oslo_messaging_notifications] driver = {{ (manila_ceilometer_enabled | bool) | ternary('messagingv2', 'noop') }} -transport_url = {{ manila_oslomsg_notify_transport }}://{% for host in manila_oslomsg_notify_servers.split(',') %}{{ manila_oslomsg_notify_userid }}:{{ manila_oslomsg_notify_password }}@{{ host }}:{{ manila_oslomsg_notify_port }}{% if not loop.last %},{% else %}/{{ manila_oslomsg_notify_vhost }}{% if manila_oslomsg_notify_use_ssl | bool %}?ssl=1&ssl_version={{ manila_oslomsg_notify_ssl_version }}&ssl_ca_file={{ manila_oslomsg_notify_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} +transport_url = {{ manila_oslomsg_notify_transport }}://{% for host in manila_oslomsg_notify_servers.split(',') %}{{ manila_oslomsg_notify_userid }}:{{ manila_oslomsg_notify_password }}@{{ host }}:{{ manila_oslomsg_notify_port }}{% if not loop.last %},{% else %}/{{ _manila_oslomsg_notify_vhost_conf }}{% if manila_oslomsg_notify_use_ssl | bool %}?ssl=1&ssl_version={{ manila_oslomsg_notify_ssl_version }}&ssl_ca_file={{ manila_oslomsg_notify_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} [oslo_concurrency] lock_path = {{ manila_lock_dir }}/{{ manila_system_slice_name }} diff --git a/vars/main.yml b/vars/main.yml index 422ecb4..007e2bf 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -24,6 +24,17 @@ _manila_share_is_first_play_host: >- inventory_hostname == (groups[manila_services['manila-share']['group']] | intersect(ansible_play_hosts)) | first) | bool }} +_manila_oslomsg_rpc_vhost_conf: >- + {{ + (manila_oslomsg_rpc_vhost is string) | ternary( + manila_oslomsg_rpc_vhost, manila_oslomsg_rpc_vhost | selectattr('state', 'eq', 'present') | map(attribute='name') | first) + }} +_manila_oslomsg_notify_vhost_conf: >- + {{ + (manila_oslomsg_notify_vhost is string) | ternary( + manila_oslomsg_notify_vhost, manila_oslomsg_notify_vhost | selectattr('state', 'eq', 'present') | map(attribute='name') | first) + }} + _manila_default_share_type_list: "{{ manila_backends.keys() | list }}" _manila_default_share_type: "{{ ((_manila_default_share_type_list | length) > 0) | ternary(_manila_default_share_type_list[0], '') }}"