From c15dc767fd2ea583227e22ca250d5ecbf423900d Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Fri, 20 Oct 2023 13:56:46 +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: I9b9de6cdfac8ba3a89b874cd920df8d5b01e81f2 --- defaults/main.yml | 13 ++++++++++++- templates/tacker.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 32c83a2..b77100a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -75,7 +75,13 @@ tacker_oslomsg_rpc_servers: "{{ oslomsg_rpc_servers | default('127.0.0.1') }}" tacker_oslomsg_rpc_port: "{{ oslomsg_rpc_port | default('5672') }}" tacker_oslomsg_rpc_use_ssl: "{{ oslomsg_rpc_use_ssl | default(False) }}" tacker_oslomsg_rpc_userid: tacker -tacker_oslomsg_rpc_vhost: /tacker +# vhost name depends on value of oslomsg_rabbit_quorum_queues. In case quorum queues +# are not used - vhost name will be prefixed with leading `/`. +tacker_oslomsg_rpc_vhost: + - name: /tacker + state: "{{ tacker_oslomsg_rabbit_quorum_queues | ternary('absent', 'present') }}" + - name: tacker + state: "{{ tacker_oslomsg_rabbit_quorum_queues | ternary('present', 'absent') }}" tacker_oslomsg_rpc_ssl_version: "{{ oslomsg_rpc_ssl_version | default('TLSv1_2') }}" tacker_oslomsg_rpc_ssl_ca_file: "{{ oslomsg_rpc_ssl_ca_file | default('') }}" @@ -92,6 +98,11 @@ tacker_oslomsg_notify_vhost: "{{ tacker_oslomsg_rpc_vhost }}" tacker_oslomsg_notify_ssl_version: "{{ oslomsg_notify_ssl_version | default('TLSv1_2') }}" tacker_oslomsg_notify_ssl_ca_file: "{{ oslomsg_notify_ssl_ca_file | default('') }}" +## RabbitMQ integration +tacker_oslomsg_rabbit_quorum_queues: "{{ oslomsg_rabbit_quorum_queues | default(True) }}" +tacker_oslomsg_rabbit_quorum_delivery_limit: "{{ oslomsg_rabbit_quorum_delivery_limit | default(0) }}" +tacker_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 tacker_oslomsg_amqp1_enabled: "{{ tacker_oslomsg_rpc_transport == 'amqp' }}" diff --git a/templates/tacker.conf.j2 b/templates/tacker.conf.j2 index 880154a..5608a04 100644 --- a/templates/tacker.conf.j2 +++ b/templates/tacker.conf.j2 @@ -4,7 +4,7 @@ debug = {{ debug }} # oslo.messaging rpc transport -transport_url = {{ tacker_oslomsg_rpc_transport }}://{% for host in tacker_oslomsg_rpc_servers.split(',') %}{{ tacker_oslomsg_rpc_userid }}:{{ tacker_oslomsg_rpc_password }}@{{ host }}:{{ tacker_oslomsg_rpc_port }}{% if not loop.last %},{% else %}/{{ tacker_oslomsg_rpc_vhost }}{% if tacker_oslomsg_rpc_use_ssl | bool %}?ssl=1&ssl_version={{ tacker_oslomsg_rpc_ssl_version }}&ssl_ca_file={{ tacker_oslomsg_rpc_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} +transport_url = {{ tacker_oslomsg_rpc_transport }}://{% for host in tacker_oslomsg_rpc_servers.split(',') %}{{ tacker_oslomsg_rpc_userid }}:{{ tacker_oslomsg_rpc_password }}@{{ host }}:{{ tacker_oslomsg_rpc_port }}{% if not loop.last %},{% else %}/{{ _tacker_oslomsg_rpc_vhost_conf }}{% if tacker_oslomsg_rpc_use_ssl | bool %}?ssl=1&ssl_version={{ tacker_oslomsg_rpc_ssl_version }}&ssl_ca_file={{ tacker_oslomsg_rpc_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} # Where to store Tacker state files. This directory must be writable by the # user executing the agent. @@ -96,7 +96,10 @@ openstack = {{ tacker_etc_dir }}/vim/fernet_keys [oslo_messaging_rabbit] ssl = {{ tacker_oslomsg_notify_use_ssl | bool }} +rabbit_quorum_queue = {{ tacker_oslomsg_rabbit_quorum_queues }} +rabbit_quorum_delivery_limit = {{ tacker_oslomsg_rabbit_quorum_delivery_limit }} +rabbit_quorum_max_memory_bytes = {{ tacker_oslomsg_rabbit_quorum_max_memory_bytes }} [oslo_messaging_notifications] driver = {{ (tacker_ceilometer_enabled | bool) | ternary('messagingv2', 'noop') }} -transport_url = {{ tacker_oslomsg_notify_transport }}://{% for host in tacker_oslomsg_notify_servers.split(',') %}{{ tacker_oslomsg_notify_userid }}:{{ tacker_oslomsg_notify_password }}@{{ host }}:{{ tacker_oslomsg_notify_port }}{% if not loop.last %},{% else %}/{{ tacker_oslomsg_notify_vhost }}{% if tacker_oslomsg_notify_use_ssl | bool %}?ssl=1&ssl_version={{ tacker_oslomsg_notify_ssl_version }}&ssl_ca_file={{ tacker_oslomsg_notify_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} +transport_url = {{ tacker_oslomsg_notify_transport }}://{% for host in tacker_oslomsg_notify_servers.split(',') %}{{ tacker_oslomsg_notify_userid }}:{{ tacker_oslomsg_notify_password }}@{{ host }}:{{ tacker_oslomsg_notify_port }}{% if not loop.last %},{% else %}/{{ _tacker_oslomsg_notify_vhost_conf }}{% if tacker_oslomsg_notify_use_ssl | bool %}?ssl=1&ssl_version={{ tacker_oslomsg_notify_ssl_version }}&ssl_ca_file={{ tacker_oslomsg_notify_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} diff --git a/vars/main.yml b/vars/main.yml index dc4c044..248889a 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -17,3 +17,15 @@ _tacker_is_first_play_host: >- {{ ('tacker_all' in group_names and inventory_hostname == (groups['tacker_all'] | intersect(ansible_play_hosts)) | first) | bool }} + +_tacker_oslomsg_rpc_vhost_conf: >- + {{ + (tacker_oslomsg_rpc_vhost is string) | ternary( + tacker_oslomsg_rpc_vhost, tacker_oslomsg_rpc_vhost | selectattr('state', 'eq', 'present') | map(attribute='name') | first) + }} + +_tacker_oslomsg_notify_vhost_conf: >- + {{ + (tacker_oslomsg_notify_vhost is string) | ternary( + tacker_oslomsg_notify_vhost, tacker_oslomsg_notify_vhost | selectattr('state', 'eq', 'present') | map(attribute='name') | first) + }}