From e164cd56d843b2ddb4bb0680d8b27175ffb7ebb5 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Fri, 20 Oct 2023 14:17:25 +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: I2e3f464534bffe9edd9d969c8d6a24adce06c02c --- defaults/main.yml | 13 ++++++++++++- templates/zun.conf.j2 | 8 +++++--- vars/main.yml | 11 +++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 28c5b51..36cc8c1 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -165,7 +165,13 @@ zun_oslomsg_rpc_servers: "{{ oslomsg_rpc_servers | default('127.0.0.1') }}" zun_oslomsg_rpc_port: "{{ oslomsg_rpc_port | default('5672') }}" zun_oslomsg_rpc_use_ssl: "{{ oslomsg_rpc_use_ssl | default(False) }}" zun_oslomsg_rpc_userid: zun -zun_oslomsg_rpc_vhost: /zun +# vhost name depends on value of oslomsg_rabbit_quorum_queues. In case quorum queues +# are not used - vhost name will be prefixed with leading `/`. +zun_oslomsg_rpc_vhost: + - name: /zun + state: "{{ zun_oslomsg_rabbit_quorum_queues | ternary('absent', 'present') }}" + - name: zun + state: "{{ zun_oslomsg_rabbit_quorum_queues | ternary('present', 'absent') }}" zun_oslomsg_rpc_ssl_version: "{{ oslomsg_rpc_ssl_version | default('TLSv1_2') }}" zun_oslomsg_rpc_ssl_ca_file: "{{ oslomsg_rpc_ssl_ca_file | default('') }}" @@ -182,6 +188,11 @@ zun_oslomsg_notify_vhost: "{{ zun_oslomsg_rpc_vhost }}" zun_oslomsg_notify_ssl_version: "{{ oslomsg_notify_ssl_version | default('TLSv1_2') }}" zun_oslomsg_notify_ssl_ca_file: "{{ oslomsg_notify_ssl_ca_file | default('') }}" +## RabbitMQ integration +zun_oslomsg_rabbit_quorum_queues: "{{ oslomsg_rabbit_quorum_queues | default(True) }}" +zun_oslomsg_rabbit_quorum_delivery_limit: "{{ oslomsg_rabbit_quorum_delivery_limit | default(0) }}" +zun_oslomsg_rabbit_quorum_max_memory_bytes: "{{ oslomsg_rabbit_quorum_max_memory_bytes | default(0) }}" + # If this is not set, then the playbook will try to guess it. # zun_virt_type: kvm diff --git a/templates/zun.conf.j2 b/templates/zun.conf.j2 index f2bdcb5..eb6f40e 100644 --- a/templates/zun.conf.j2 +++ b/templates/zun.conf.j2 @@ -2,7 +2,7 @@ debug = {{ debug | bool }} use_journal = true rpc_conn_pool_size = {{ zun_rpc_conn_pool_size }} -transport_url = {{ zun_oslomsg_rpc_transport }}://{% for host in zun_oslomsg_rpc_servers.split(',') %}{{ zun_oslomsg_rpc_userid }}:{{ zun_oslomsg_rpc_password }}@{{ host }}:{{ zun_oslomsg_rpc_port }}{% if not loop.last %},{% else %}/{{ zun_oslomsg_rpc_vhost }}{% if zun_oslomsg_rpc_use_ssl | bool %}?ssl=1&ssl_version={{ zun_oslomsg_rpc_ssl_version }}&ssl_ca_file={{ zun_oslomsg_rpc_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} +transport_url = {{ zun_oslomsg_rpc_transport }}://{% for host in zun_oslomsg_rpc_servers.split(',') %}{{ zun_oslomsg_rpc_userid }}:{{ zun_oslomsg_rpc_password }}@{{ host }}:{{ zun_oslomsg_rpc_port }}{% if not loop.last %},{% else %}/{{ _zun_oslomsg_rpc_vhost_conf }}{% if zun_oslomsg_rpc_use_ssl | bool %}?ssl=1&ssl_version={{ zun_oslomsg_rpc_ssl_version }}&ssl_ca_file={{ zun_oslomsg_rpc_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} use_sandbox = true image_driver_list = glance,docker @@ -89,7 +89,7 @@ lock_path = {{ zun_lock_dir }}/{{ zun_system_slice_name }} [oslo_messaging_notifications] driver = {{ (zun_ceilometer_enabled | bool) | ternary('messagingv2', 'noop') }} -transport_url = {{ zun_oslomsg_notify_transport }}://{% for host in zun_oslomsg_notify_servers.split(',') %}{{ zun_oslomsg_notify_userid }}:{{ zun_oslomsg_notify_password }}@{{ host }}:{{ zun_oslomsg_notify_port }}{% if not loop.last %},{% else %}/{{ zun_oslomsg_notify_vhost }}{% if zun_oslomsg_notify_use_ssl | bool %}?ssl=1&ssl_version={{ zun_oslomsg_notify_ssl_version }}&ssl_ca_file={{ zun_oslomsg_notify_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} +transport_url = {{ zun_oslomsg_notify_transport }}://{% for host in zun_oslomsg_notify_servers.split(',') %}{{ zun_oslomsg_notify_userid }}:{{ zun_oslomsg_notify_password }}@{{ host }}:{{ zun_oslomsg_notify_port }}{% if not loop.last %},{% else %}/{{ _zun_oslomsg_notify_vhost_conf }}{% if zun_oslomsg_notify_use_ssl | bool %}?ssl=1&ssl_version={{ zun_oslomsg_notify_ssl_version }}&ssl_ca_file={{ zun_oslomsg_notify_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} {% if zun_ceilometer_enabled or zun_designate_enabled %} {% set notification_topics = [] %} {% if zun_ceilometer_enabled %} @@ -104,7 +104,9 @@ topics = {{ notification_topics | join(',') }} [oslo_messaging_rabbit] ssl = {{ zun_oslomsg_notify_use_ssl | bool }} - +rabbit_quorum_queue = {{ zun_oslomsg_rabbit_quorum_queues }} +rabbit_quorum_delivery_limit = {{ zun_oslomsg_rabbit_quorum_delivery_limit }} +rabbit_quorum_max_memory_bytes = {{ zun_oslomsg_rabbit_quorum_max_memory_bytes }} [placement_client] endpoint_type = {{ zun_service_endpoint_type }} diff --git a/vars/main.yml b/vars/main.yml index fb6d532..dbfa38e 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -13,6 +13,17 @@ # See the License for the specific language governing permissions and # limitations under the License. +_zun_oslomsg_rpc_vhost_conf: >- + {{ + (zun_oslomsg_rpc_vhost is string) | ternary( + zun_oslomsg_rpc_vhost, zun_oslomsg_rpc_vhost | selectattr('state', 'eq', 'present') | map(attribute='name') | first) + }} +_zun_oslomsg_notify_vhost_conf: >- + {{ + (zun_oslomsg_notify_vhost is string) | ternary( + zun_oslomsg_notify_vhost, zun_oslomsg_notify_vhost | selectattr('state', 'eq', 'present') | map(attribute='name') | first) + }} + # # Compile a list of the services on a host based on whether # the host is in the host group and the service is enabled.