From 0ba35bf8416e3e1f1edb4171c895a4c3e34ca6ab Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Fri, 10 Nov 2023 17:05:45 +0100 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: Id5f6cabed7ec035845865d6d5facc63590c56d43 --- defaults/main.yml | 11 ++++++++++- templates/proxy-server.conf.j2 | 2 +- vars/main.yml | 6 ++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 4d7932ea..d01a820c 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -196,10 +196,19 @@ swift_oslomsg_notify_servers: "{{ oslomsg_notify_servers | default('127.0.0.1') swift_oslomsg_notify_port: "{{ oslomsg_notify_port | default('5672') }}" swift_oslomsg_notify_use_ssl: "{{ oslomsg_notify_use_ssl | default(False) }}" swift_oslomsg_notify_userid: swift -swift_oslomsg_notify_vhost: /swift +swift_oslomsg_notify_vhost: + - name: /swift + state: "{{ swift_oslomsg_rabbit_quorum_queues | ternary('absent', 'present') }}" + - name: swift + state: "{{ swift_oslomsg_rabbit_quorum_queues | ternary('present', 'absent') }}" + swift_oslomsg_notify_ssl_version: "{{ oslomsg_notify_ssl_version | default('TLSv1_2') }}" swift_oslomsg_notify_ssl_ca_file: "{{ oslomsg_notify_ssl_ca_file | default('') }}" +swift_oslomsg_rabbit_quorum_queues: "{{ oslomsg_rabbit_quorum_queues | default(True) }}" +swift_oslomsg_rabbit_quorum_delivery_limit: "{{ oslomsg_rabbit_quorum_delivery_limit | default(0) }}" +swift_oslomsg_rabbit_quorum_max_memory_bytes: "{{ oslomsg_rabbit_quorum_max_memory_bytes | default(0) }}" + ## General Swift configuration # We are not capping the default value for these swift variables which define # the number of worker threads for each of the swift services (except the swift diff --git a/templates/proxy-server.conf.j2 b/templates/proxy-server.conf.j2 index 7120c6eb..f7f910cb 100644 --- a/templates/proxy-server.conf.j2 +++ b/templates/proxy-server.conf.j2 @@ -176,7 +176,7 @@ use = egg:swift#xprofile paste.filter_factory = ceilometermiddleware.swift:filter_factory control_exchange = swift driver = messagingv2 -url = {{ swift_oslomsg_notify_transport }}://{% for host in swift_oslomsg_notify_servers.split(',') %}{{ swift_oslomsg_notify_userid }}:{{ swift_oslomsg_notify_password }}@{{ host }}:{{ swift_oslomsg_notify_port }}{% if not loop.last %},{% else %}/{{ swift_oslomsg_notify_vhost }}{% if swift_oslomsg_notify_use_ssl | bool %}?ssl=1&ssl_version={{ swift_oslomsg_notify_ssl_version }}&ssl_ca_file={{ swift_oslomsg_notify_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} +url = {{ swift_oslomsg_notify_transport }}://{% for host in swift_oslomsg_notify_servers.split(',') %}{{ swift_oslomsg_notify_userid }}:{{ swift_oslomsg_notify_password }}@{{ host }}:{{ swift_oslomsg_notify_port }}{% if not loop.last %},{% else %}/{{ _swift_oslomsg_notify_vhost_conf }}{% if swift_oslomsg_notify_use_ssl | bool %}?ssl=1&ssl_version={{ swift_oslomsg_notify_ssl_version }}&ssl_ca_file={{ swift_oslomsg_notify_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} topic = notifications {% if gnocchi_service_project_name is defined %} diff --git a/vars/main.yml b/vars/main.yml index bf742a91..23a65736 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -21,6 +21,12 @@ _swift_proxy_is_first_play_host: >- _swift_is_first_play_host: >- {{ ('swift_hosts' in group_names and inventory_hostname == (groups['swift_hosts'] | intersect(ansible_play_hosts)) | first) | bool }} +_swift_oslomsg_notify_vhost_conf: >- + {{ + (swift_oslomsg_notify_vhost is string) | ternary( + swift_oslomsg_notify_vhost, swift_oslomsg_notify_vhost | selectattr('state', 'eq', 'present') | map(attribute='name') | first) + }} + filtered_swift_services: |- {% set services = [] %} {% for key,value in swift_services.items() %}