From 3f7085e58a1c89f2f2f7128d5264951bd888dd6b Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Fri, 20 Oct 2023 13:45:23 +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-plugins/+/896017 Change-Id: I947be8d94b3263ed69311667af693a481765b1c4 --- defaults/main.yml | 13 ++++++++++++- templates/sahara.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 07122a4..fb7a32a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -72,7 +72,13 @@ sahara_oslomsg_rpc_servers: "{{ oslomsg_rpc_servers | default('127.0.0.1') }}" sahara_oslomsg_rpc_port: "{{ oslomsg_rpc_port | default('5672') }}" sahara_oslomsg_rpc_use_ssl: "{{ oslomsg_rpc_use_ssl | default(False) }}" sahara_oslomsg_rpc_userid: sahara -sahara_oslomsg_rpc_vhost: /sahara +# vhost name depends on value of oslomsg_rabbit_quorum_queues. In case quorum queues +# are not used - vhost name will be prefixed with leading `/`. +sahara_oslomsg_rpc_vhost: + - name: /sahara + state: "{{ sahara_oslomsg_rabbit_quorum_queues | ternary('absent', 'present') }}" + - name: sahara + state: "{{ sahara_oslomsg_rabbit_quorum_queues | ternary('present', 'absent') }}" sahara_oslomsg_rpc_ssl_version: "{{ oslomsg_rpc_ssl_version | default('TLSv1_2') }}" sahara_oslomsg_rpc_ssl_ca_file: "{{ oslomsg_rpc_ssl_ca_file | default('') }}" @@ -89,6 +95,11 @@ sahara_oslomsg_notify_vhost: "{{ sahara_oslomsg_rpc_vhost }}" sahara_oslomsg_notify_ssl_version: "{{ oslomsg_notify_ssl_version | default('TLSv1_2') }}" sahara_oslomsg_notify_ssl_ca_file: "{{ oslomsg_notify_ssl_ca_file | default('') }}" +## RabbitMQ integration +sahara_oslomsg_rabbit_quorum_queues: "{{ oslomsg_rabbit_quorum_queues | default(True) }}" +sahara_oslomsg_rabbit_quorum_delivery_limit: "{{ oslomsg_rabbit_quorum_delivery_limit | default(0) }}" +sahara_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 sahara_oslomsg_amqp1_enabled: "{{ sahara_oslomsg_rpc_transport == 'amqp' }}" diff --git a/templates/sahara.conf.j2 b/templates/sahara.conf.j2 index 347c64f..22eea65 100644 --- a/templates/sahara.conf.j2 +++ b/templates/sahara.conf.j2 @@ -24,7 +24,7 @@ proxy_user_role_names = {{ sahara_proxy_user_role_names }} {% endif %} ## RPC Backend -transport_url = {{ sahara_oslomsg_rpc_transport }}://{% for host in sahara_oslomsg_rpc_servers.split(',') %}{{ sahara_oslomsg_rpc_userid }}:{{ sahara_oslomsg_rpc_password }}@{{ host }}:{{ sahara_oslomsg_rpc_port }}{% if not loop.last %},{% else %}/{{ sahara_oslomsg_rpc_vhost }}{% if sahara_oslomsg_rpc_use_ssl | bool %}?ssl=1&ssl_version={{ sahara_oslomsg_rpc_ssl_version }}&ssl_ca_file={{ sahara_oslomsg_rpc_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} +transport_url = {{ sahara_oslomsg_rpc_transport }}://{% for host in sahara_oslomsg_rpc_servers.split(',') %}{{ sahara_oslomsg_rpc_userid }}:{{ sahara_oslomsg_rpc_password }}@{{ host }}:{{ sahara_oslomsg_rpc_port }}{% if not loop.last %},{% else %}/{{ _sahara_oslomsg_rpc_vhost_conf }}{% if sahara_oslomsg_rpc_use_ssl | bool %}?ssl=1&ssl_version={{ sahara_oslomsg_rpc_ssl_version }}&ssl_ca_file={{ sahara_oslomsg_rpc_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} [database] connection = mysql+pymysql://{{ sahara_galera_user }}:{{ sahara_container_mysql_password }}@{{ sahara_galera_address }}:{{ sahara_galera_port }}/{{ sahara_galera_database }}?charset=utf8{% if sahara_galera_use_ssl | bool %}&ssl_verify_cert=true{% if sahara_galera_ssl_ca_cert | length > 0 %}&ssl_ca={{ sahara_galera_ssl_ca_cert }}{% endif %}{% endif +%} @@ -64,10 +64,13 @@ policy_dirs = {{ sahara_policy_dirs }} # Ceilometer options [oslo_messaging_notifications] driver = {{ (sahara_ceilometer_enabled | bool) | ternary('messagingv2', 'noop') }} -transport_url = {{ sahara_oslomsg_notify_transport }}://{% for host in sahara_oslomsg_notify_servers.split(',') %}{{ sahara_oslomsg_notify_userid }}:{{ sahara_oslomsg_notify_password }}@{{ host }}:{{ sahara_oslomsg_notify_port }}{% if not loop.last %},{% else %}/{{ sahara_oslomsg_notify_vhost }}{% if sahara_oslomsg_notify_use_ssl | bool %}?ssl=1&ssl_version={{ sahara_oslomsg_notify_ssl_version }}&ssl_ca_file={{ sahara_oslomsg_notify_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} +transport_url = {{ sahara_oslomsg_notify_transport }}://{% for host in sahara_oslomsg_notify_servers.split(',') %}{{ sahara_oslomsg_notify_userid }}:{{ sahara_oslomsg_notify_password }}@{{ host }}:{{ sahara_oslomsg_notify_port }}{% if not loop.last %},{% else %}/{{ _sahara_oslomsg_notify_vhost_conf }}{% if sahara_oslomsg_notify_use_ssl | bool %}?ssl=1&ssl_version={{ sahara_oslomsg_notify_ssl_version }}&ssl_ca_file={{ sahara_oslomsg_notify_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} [oslo_messaging_rabbit] ssl = {{ sahara_oslomsg_rpc_use_ssl }} +rabbit_quorum_queue = {{ sahara_oslomsg_rabbit_quorum_queues }} +rabbit_quorum_delivery_limit = {{ sahara_oslomsg_rabbit_quorum_delivery_limit }} +rabbit_quorum_max_memory_bytes = {{ sahara_oslomsg_rabbit_quorum_max_memory_bytes }} [profiler] enabled = {{ sahara_profiler_enabled }} diff --git a/vars/main.yml b/vars/main.yml index f97e3fb..57fb2f0 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -18,6 +18,17 @@ _sahara_is_first_play_host: >- (sahara_services['sahara-api']['group'] in group_names and inventory_hostname == (groups[sahara_services['sahara-api']['group']] | intersect(ansible_play_hosts)) | first) | bool }} +_sahara_oslomsg_rpc_vhost_conf: >- + {{ + (sahara_oslomsg_rpc_vhost is string) | ternary( + sahara_oslomsg_rpc_vhost, sahara_oslomsg_rpc_vhost | selectattr('state', 'eq', 'present') | map(attribute='name') | first) + }} +_sahara_oslomsg_notify_vhost_conf: >- + {{ + (sahara_oslomsg_notify_vhost is string) | ternary( + sahara_oslomsg_notify_vhost, sahara_oslomsg_notify_vhost | selectattr('state', 'eq', 'present') | map(attribute='name') | first) + }} + filtered_sahara_services: |- {% set services = [] %}