Author: Takashi Kajinami <kajinamit@oss.nttdata.com>
Date: Fri, 14 Mar 2025 09:42:23 +0900
Description: Add a rabbit_transient_queues_ttl and amqp_auto_delete params
 The amqp_auto_delete option needs this patch:
 https://review.opendev.org/c/openstack/puppet-oslo/+/944132
 .
 Since transient_queues_ttl is also managed by oslo::messaging::rabbit,
 there's no way to use manila_config to set it, so this patch is
 mandatory for one to set rabbit_transient_queues_ttl in manila.conf.
Co-Authored-By: Thomas Goirand <zigo@debian.org>
Change-Id: Iadfcd0859e2912d3f636ab4f550f056890357b90
Origin: upstream, https://review.opendev.org/c/openstack/puppet-manila/+/944304
Last-Update: 2025-03-26

diff --git a/manifests/init.pp b/manifests/init.pp
index 38a886c..303e147 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -61,6 +61,14 @@
 #   (Optional) Use quorum queues for transients queues in RabbitMQ.
 #   Defaults to $facts['os_service_default']
 #
+# [*rabbit_transient_queues_ttl*]
+#   (Optional) Positive integer representing duration in seconds for
+#   queue TTL (x-expires). Queues which are unused for the duration
+#   of the TTL are automatically deleted.
+#   The parameter affects only reply and fanout queues. (integer value)
+#   Min to 1
+#   Defaults to $facts['os_service_default']
+#
 # [*rabbit_quorum_delivery_limit*]
 #   (Optional) Each time a message is rdelivered to a consumer, a counter is
 #   incremented. Once the redelivery count exceeds the delivery limit
@@ -112,6 +120,10 @@
 #   (optional) Use durable queues in amqp.
 #   Defaults to $facts['os_service_default'].
 #
+# [*amqp_auto_delete*]
+#   (Optional) Define if transient queues should be auto-deleted (boolean value)
+#   Defaults to $facts['os_service_default']
+#
 # [*use_ssl*]
 #   (optional) Enable SSL on the API server
 #   Defaults to false, not set
@@ -213,6 +225,7 @@
   $rabbit_ha_queues                   = $facts['os_service_default'],
   $rabbit_quorum_queue                = $facts['os_service_default'],
   $rabbit_transient_quorum_queue      = $facts['os_service_default'],
+  $rabbit_transient_queues_ttl        = $facts['os_service_default'],
   $rabbit_quorum_delivery_limit       = $facts['os_service_default'],
   $rabbit_quorum_max_memory_length    = $facts['os_service_default'],
   $rabbit_quorum_max_memory_bytes     = $facts['os_service_default'],
@@ -224,6 +237,7 @@
   $kombu_ssl_version                  = $facts['os_service_default'],
   $kombu_failover_strategy            = $facts['os_service_default'],
   $amqp_durable_queues                = $facts['os_service_default'],
+  $amqp_auto_delete                   = $facts['os_service_default'],
   $rabbit_heartbeat_in_pthread        = $facts['os_service_default'],
   $rabbit_qos_prefetch_count          = $facts['os_service_default'],
   $package_ensure                     = 'present',
@@ -269,6 +283,7 @@
   oslo::messaging::rabbit { 'manila_config':
     rabbit_use_ssl                  => $rabbit_use_ssl,
     amqp_durable_queues             => $amqp_durable_queues,
+    amqp_auto_delete                => $amqp_auto_delete,
     rabbit_ha_queues                => $rabbit_ha_queues,
     kombu_ssl_ca_certs              => $kombu_ssl_ca_certs,
     kombu_ssl_certfile              => $kombu_ssl_certfile,
@@ -281,6 +296,7 @@
     rabbit_qos_prefetch_count       => $rabbit_qos_prefetch_count,
     rabbit_quorum_queue             => $rabbit_quorum_queue,
     rabbit_transient_quorum_queue   => $rabbit_transient_quorum_queue,
+    rabbit_transient_queues_ttl     => $rabbit_transient_queues_ttl,
     rabbit_quorum_delivery_limit    => $rabbit_quorum_delivery_limit,
     rabbit_quorum_max_memory_length => $rabbit_quorum_max_memory_length,
     rabbit_quorum_max_memory_bytes  => $rabbit_quorum_max_memory_bytes,
diff --git a/releasenotes/notes/amqp_auto_delete-052b56b650d9b05a.yaml b/releasenotes/notes/amqp_auto_delete-052b56b650d9b05a.yaml
new file mode 100644
index 0000000..bb24709
--- /dev/null
+++ b/releasenotes/notes/amqp_auto_delete-052b56b650d9b05a.yaml
@@ -0,0 +1,5 @@
+---
+features:
+  - |
+    Add a new ``amqp_auto_delete`` parameter, so that transient queues are
+    automatically deleted.
diff --git a/releasenotes/notes/rabbit_transient_queues_ttl-bad0a37a1a6a679d.yaml b/releasenotes/notes/rabbit_transient_queues_ttl-bad0a37a1a6a679d.yaml
new file mode 100644
index 0000000..2a8a34a
--- /dev/null
+++ b/releasenotes/notes/rabbit_transient_queues_ttl-bad0a37a1a6a679d.yaml
@@ -0,0 +1,6 @@
+---
+features:
+  - |
+    A new parameter ``rabbit_transient_queues_ttl`` has been added to the
+    manila class to configure how long transient queue should stay until
+    they are automatically deleted.
diff --git a/spec/classes/manila_init_spec.rb b/spec/classes/manila_init_spec.rb
index a894621..04fbcea 100644
--- a/spec/classes/manila_init_spec.rb
+++ b/spec/classes/manila_init_spec.rb
@@ -36,6 +36,7 @@
         is_expected.to contain_oslo__messaging__rabbit('manila_config').with(
           :rabbit_use_ssl                  => '<SERVICE DEFAULT>',
           :amqp_durable_queues             => '<SERVICE DEFAULT>',
+          :amqp_auto_delete                => '<SERVICE DEFAULT>',
           :rabbit_ha_queues                => '<SERVICE DEFAULT>',
           :kombu_failover_strategy         => '<SERVICE DEFAULT>',
           :heartbeat_timeout_threshold     => '<SERVICE DEFAULT>',
@@ -44,6 +45,7 @@
           :rabbit_qos_prefetch_count       => '<SERVICE DEFAULT>',
           :rabbit_quorum_queue             => '<SERVICE DEFAULT>',
           :rabbit_transient_quorum_queue   => '<SERVICE DEFAULT>',
+          :rabbit_transient_queues_ttl     => '<SERVICE DEFAULT>',
           :rabbit_quorum_delivery_limit    => '<SERVICE DEFAULT>',
           :rabbit_quorum_max_memory_length => '<SERVICE DEFAULT>',
           :rabbit_quorum_max_memory_bytes  => '<SERVICE DEFAULT>',
@@ -138,27 +140,17 @@
       )}
     end
 
-    context 'with amqp_durable_queues disabled' do
-      let :params do
-        req_params.merge({
-          :amqp_durable_queues => false,
-        })
-      end
-
-      it { is_expected.to contain_oslo__messaging__rabbit('manila_config').with(
-        :amqp_durable_queues => false,
-      )}
-    end
-
-    context 'with amqp_durable_queues enabled' do
+    context 'with amqp options' do
       let :params do
         req_params.merge({
           :amqp_durable_queues => true,
+          :amqp_auto_delete    => false,
         })
       end
 
       it { is_expected.to contain_oslo__messaging__rabbit('manila_config').with(
         :amqp_durable_queues => true,
+        :amqp_auto_delete    => false,
       )}
     end
 
