From a5d922e4ed9e83ef7cce99d17f2b7ea6f47c1b05 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Mon, 13 Feb 2023 18:37:02 +0100 Subject: [PATCH] Add quorum support for glance This change implements and enables by default quorum support for rabbitmq as well as providing default variables to globally tune it's behaviour. Depends-On: https://review.opendev.org/c/openstack/oslo.messaging/+/873630 Depends-On: https://review.opendev.org/c/openstack/openstack-ansible/+/873618 Depends-On: https://review.opendev.org/c/openstack/openstack-ansible-plugins/+/875399 Change-Id: I87a5a1bb5028706e1768f53f53c4567cbdff64c9 --- defaults/main.yml | 13 ++++++++++++- templates/glance-api.conf.j2 | 11 +++++++++-- vars/main.yml | 3 +++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 07161747..a349edcf 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -101,7 +101,13 @@ glance_oslomsg_rpc_servers: "{{ oslomsg_rpc_servers | default('127.0.0.1') }}" glance_oslomsg_rpc_port: "{{ oslomsg_rpc_port | default('5672') }}" glance_oslomsg_rpc_use_ssl: "{{ oslomsg_rpc_use_ssl | default(False) }}" glance_oslomsg_rpc_userid: glance -glance_oslomsg_rpc_vhost: /glance +# vhost name depends on value of oslomsg_rabbit_quorum_queues. In case quorum queues +# are not used - vhost name will be prefixed with leading `/`. +glance_oslomsg_rpc_vhost: + - name: /glance + state: "{{ glance_oslomsg_rabbit_quorum_queues | ternary('absent', 'present') }}" + - name: glance + state: "{{ glance_oslomsg_rabbit_quorum_queues | ternary('present', 'absent') }}" glance_oslomsg_rpc_ssl_version: "{{ oslomsg_rpc_ssl_version | default('TLSv1_2') }}" glance_oslomsg_rpc_ssl_ca_file: "{{ oslomsg_rpc_ssl_ca_file | default('') }}" @@ -118,6 +124,11 @@ glance_oslomsg_notify_vhost: "{{ glance_oslomsg_rpc_vhost }}" glance_oslomsg_notify_ssl_version: "{{ oslomsg_notify_ssl_version | default('TLSv1_2') }}" glance_oslomsg_notify_ssl_ca_file: "{{ oslomsg_notify_ssl_ca_file | default('') }}" +## RabbitMQ integration +glance_oslomsg_rabbit_quorum_queues: "{{ oslomsg_rabbit_quorum_queues | default(True) }}" +glance_oslomsg_rabbit_quorum_delivery_limit: "{{ oslomsg_rabbit_quorum_delivery_limit | default(0) }}" +glance_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 glance_oslomsg_amqp1_enabled: "{{ glance_oslomsg_rpc_transport == 'amqp' }}" diff --git a/templates/glance-api.conf.j2 b/templates/glance-api.conf.j2 index 6756d2eb..30172a4d 100644 --- a/templates/glance-api.conf.j2 +++ b/templates/glance-api.conf.j2 @@ -16,7 +16,7 @@ cinder_catalog_info = volumev3:cinderv3:internalURL enable_v2_api = {{ glance_enable_v2_api | bool }} -transport_url = {{ glance_oslomsg_rpc_transport }}://{% for host in glance_oslomsg_rpc_servers.split(',') %}{{ glance_oslomsg_rpc_userid }}:{{ glance_oslomsg_rpc_password }}@{{ host }}:{{ glance_oslomsg_rpc_port }}{% if not loop.last %},{% else %}/{{ glance_oslomsg_rpc_vhost }}{% if glance_oslomsg_rpc_use_ssl | bool %}?ssl=1&ssl_version={{ glance_oslomsg_rpc_ssl_version }}&ssl_ca_file={{ glance_oslomsg_rpc_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} +transport_url = {{ glance_oslomsg_rpc_transport }}://{% for host in glance_oslomsg_rpc_servers.split(',') %}{{ glance_oslomsg_rpc_userid }}:{{ glance_oslomsg_rpc_password }}@{{ host }}:{{ glance_oslomsg_rpc_port }}{% if not loop.last %},{% else %}/{{ _glance_oslomsg_rpc_vhost_conf }}{% if glance_oslomsg_rpc_use_ssl | bool %}?ssl=1&ssl_version={{ glance_oslomsg_rpc_ssl_version }}&ssl_ca_file={{ glance_oslomsg_rpc_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} scrub_time = 43200 @@ -70,10 +70,17 @@ policy_file = {{ glance_policy_file }} policy_default_rule = {{ glance_policy_default_rule }} policy_dirs = {{ glance_policy_dirs }} +{% if glance_oslomsg_rpc_transport == 'rabbit' %} +[oslo_messaging_rabbit] +rabbit_quorum_queue = {{ glance_oslomsg_rabbit_quorum_queues }} +rabbit_quorum_delivery_limit = {{ glance_oslomsg_rabbit_quorum_delivery_limit }} +rabbit_quorum_max_memory_bytes = {{ glance_oslomsg_rabbit_quorum_max_memory_bytes }} +{% endif %} + [oslo_messaging_notifications] topics = notifications driver = {{ (glance_ceilometer_enabled | bool) | ternary('messagingv2', 'noop') }} -transport_url = {{ glance_oslomsg_notify_transport }}://{% for host in glance_oslomsg_notify_servers.split(',') %}{{ glance_oslomsg_notify_userid }}:{{ glance_oslomsg_notify_password }}@{{ host }}:{{ glance_oslomsg_notify_port }}{% if not loop.last %},{% else %}/{{ glance_oslomsg_notify_vhost }}{% if glance_oslomsg_notify_use_ssl | bool %}?ssl=1&ssl_version={{ glance_oslomsg_notify_ssl_version }}&ssl_ca_file={{ glance_oslomsg_notify_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} +transport_url = {{ glance_oslomsg_notify_transport }}://{% for host in glance_oslomsg_notify_servers.split(',') %}{{ glance_oslomsg_notify_userid }}:{{ glance_oslomsg_notify_password }}@{{ host }}:{{ glance_oslomsg_notify_port }}{% if not loop.last %},{% else %}/{{ _glance_oslomsg_notify_vhost_conf }}{% if glance_oslomsg_notify_use_ssl | bool %}?ssl=1&ssl_version={{ glance_oslomsg_notify_ssl_version }}&ssl_ca_file={{ glance_oslomsg_notify_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} [paste_deploy] flavor = {{ glance_flavor }} diff --git a/vars/main.yml b/vars/main.yml index 47e4c887..eb1436b7 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -15,6 +15,9 @@ _glance_is_first_play_host: "{{ (glance_services['glance-api']['group'] in group_names and inventory_hostname == (groups[glance_services['glance-api']['group']] | intersect(ansible_play_hosts)) | first) | bool }}" +_glance_oslomsg_rpc_vhost_conf: "{{ (glance_oslomsg_rpc_vhost is string) | ternary(glance_oslomsg_rpc_vhost, glance_oslomsg_rpc_vhost | selectattr('state', 'eq', 'present') | map(attribute='name') | first) }}" +_glance_oslomsg_notify_vhost_conf: "{{ (glance_oslomsg_notify_vhost is string) | ternary(glance_oslomsg_notify_vhost, glance_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.