From e7f7e7d122aa6c0fc8c99355f9888406b495c528 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Thu, 19 Oct 2023 14:30:35 +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/ansible-role-zookeeper/+/899386 Change-Id: I8c418906b75edb633948f2c074170454a8f3e2d0 --- defaults/main.yml | 13 ++++++++++++- templates/designate.conf.j2 | 7 +++++-- vars/main.yml | 12 ++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index f3865c3..2ea96ea 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -101,7 +101,13 @@ designate_oslomsg_rpc_servers: "{{ oslomsg_rpc_servers | default('127.0.0.1') }} designate_oslomsg_rpc_port: "{{ oslomsg_rpc_port | default('5672') }}" designate_oslomsg_rpc_use_ssl: "{{ oslomsg_rpc_use_ssl | default(False) }}" designate_oslomsg_rpc_userid: designate-rpc -designate_oslomsg_rpc_vhost: /designate +# vhost name depends on value of oslomsg_rabbit_quorum_queues. In case quorum queues +# are not used - vhost name will be prefixed with leading `/`. +designate_oslomsg_rpc_vhost: + - name: /designate + state: "{{ designate_oslomsg_rabbit_quorum_queues | ternary('absent', 'present') }}" + - name: designate + state: "{{ designate_oslomsg_rabbit_quorum_queues | ternary('present', 'absent') }}" designate_oslomsg_rpc_ssl_version: "{{ oslomsg_rpc_ssl_version | default('TLSv1_2') }}" designate_oslomsg_rpc_ssl_ca_file: "{{ oslomsg_rpc_ssl_ca_file | default('') }}" @@ -119,6 +125,11 @@ designate_oslomsg_notify_vhost: "{{ designate_oslomsg_rpc_vhost }}" designate_oslomsg_notify_ssl_version: "{{ oslomsg_notify_ssl_version | default('TLSv1_2') }}" designate_oslomsg_notify_ssl_ca_file: "{{ oslomsg_notify_ssl_ca_file | default('') }}" +## RabbitMQ integration +designate_oslomsg_rabbit_quorum_queues: "{{ oslomsg_rabbit_quorum_queues | default(True) }}" +designate_oslomsg_rabbit_quorum_delivery_limit: "{{ oslomsg_rabbit_quorum_delivery_limit | default(0) }}" +designate_oslomsg_rabbit_quorum_max_memory_bytes: "{{ oslomsg_rabbit_quorum_max_memory_bytes | default(0) }}" + ## (Qdrouterd) info # TODO(ansmith): Change structure when more backends will be supported designate_oslomsg_amqp1_enabled: "{{ designate_oslomsg_rpc_transport == 'amqp' }}" diff --git a/templates/designate.conf.j2 b/templates/designate.conf.j2 index 0c88ada..2eae5cd 100644 --- a/templates/designate.conf.j2 +++ b/templates/designate.conf.j2 @@ -24,17 +24,20 @@ root_helper = sudo designate-rootwrap /etc/designate/rootwrap.conf #network_api = neutron ## RabbitMQ RPC -transport_url = {{ designate_oslomsg_rpc_transport }}://{% for host in designate_oslomsg_rpc_servers.split(',') %}{{ designate_oslomsg_rpc_userid }}:{{ designate_oslomsg_rpc_password }}@{{ host }}:{{ designate_oslomsg_rpc_port }}{% if not loop.last %},{% else %}/{{ designate_oslomsg_rpc_vhost }}{% if designate_oslomsg_rpc_use_ssl | bool %}?ssl=1&ssl_version={{ designate_oslomsg_rpc_ssl_version }}&ssl_ca_file={{ designate_oslomsg_rpc_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} +transport_url = {{ designate_oslomsg_rpc_transport }}://{% for host in designate_oslomsg_rpc_servers.split(',') %}{{ designate_oslomsg_rpc_userid }}:{{ designate_oslomsg_rpc_password }}@{{ host }}:{{ designate_oslomsg_rpc_port }}{% if not loop.last %},{% else %}/{{ _designate_oslomsg_rpc_vhost_conf }}{% if designate_oslomsg_rpc_use_ssl | bool %}?ssl=1&ssl_version={{ designate_oslomsg_rpc_ssl_version }}&ssl_ca_file={{ designate_oslomsg_rpc_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} # RabbitMQ Config [oslo_messaging_rabbit] ssl = {{ designate_oslomsg_rpc_use_ssl }} rabbit_notification_exchange = designate rabbit_notification_topic = notifications +rabbit_quorum_queue = {{ designate_oslomsg_rabbit_quorum_queues }} +rabbit_quorum_delivery_limit = {{ designate_oslomsg_rabbit_quorum_delivery_limit }} +rabbit_quorum_max_memory_bytes = {{ designate_oslomsg_rabbit_quorum_max_memory_bytes }} [oslo_messaging_notifications] driver = {{ (designate_ceilometer_enabled | bool) | ternary('messagingv2', 'noop') }} -transport_url = {{ designate_oslomsg_notify_transport }}://{% for host in designate_oslomsg_notify_servers.split(',') %}{{ designate_oslomsg_notify_userid }}:{{ designate_oslomsg_notify_password }}@{{ host }}:{{ designate_oslomsg_notify_port }}{% if not loop.last %},{% else %}/{{ designate_oslomsg_notify_vhost }}{% if designate_oslomsg_notify_use_ssl | bool %}?ssl=1&ssl_version={{ designate_oslomsg_notify_ssl_version }}&ssl_ca_file={{ designate_oslomsg_notify_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} +transport_url = {{ designate_oslomsg_notify_transport }}://{% for host in designate_oslomsg_notify_servers.split(',') %}{{ designate_oslomsg_notify_userid }}:{{ designate_oslomsg_notify_password }}@{{ host }}:{{ designate_oslomsg_notify_port }}{% if not loop.last %},{% else %}/{{ _designate_oslomsg_notify_vhost_conf }}{% if designate_oslomsg_notify_use_ssl | bool %}?ssl=1&ssl_version={{ designate_oslomsg_notify_ssl_version }}&ssl_ca_file={{ designate_oslomsg_notify_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} {% if designate_backend_ssl | bool %} [ssl] diff --git a/vars/main.yml b/vars/main.yml index 5646619..bf6b9b1 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -19,6 +19,18 @@ _designate_is_first_play_host: >- inventory_hostname == (groups[designate_services['designate-api']['group']] | intersect(ansible_play_hosts)) | first) | bool }} +_designate_oslomsg_rpc_vhost_conf: >- + {{ + (designate_oslomsg_rpc_vhost is string) | ternary( + designate_oslomsg_rpc_vhost, designate_oslomsg_rpc_vhost | selectattr('state', 'eq', 'present') | map(attribute='name') | first) + }} + +_designate_oslomsg_notify_vhost_conf: >- + {{ + (designate_oslomsg_notify_vhost is string) | ternary( + designate_oslomsg_notify_vhost, designate_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.