]> review.fuel-infra Code Review - puppet-modules/puppet-ceilometer.git/commitdiff
Add rabbit_ha_queues option
authorXingchao Yu <xingchao@unitedstack.com>
Sat, 16 Jan 2016 07:35:12 +0000 (15:35 +0800)
committerXingchao Yu <xingchao@unitedstack.com>
Sat, 16 Jan 2016 13:05:31 +0000 (21:05 +0800)
There are two ways for setting up RabbitMQ HA:

 1. Configure rabbit_hosts to multi rabbit hosts.
 2. Set up a loadbalancer in front of RabbitMQ cluster,
    provide a unique address in rabbit_host

But rabbit_ha_queues option is controled by rabbit_hosts if conditional
statement. When users try the second method: changing rabbit_ha_queues to true.
If they don't set rabbit_hosts, then current logic will not work.

This patch aims to add an rabbit_ha_queues option, set to undef by
default for backward compatbility.

Change-Id: Id1245002dfbb6f314c6082f554221ee247be630c

manifests/init.pp
spec/classes/ceilometer_init_spec.rb

index 6df00b10dc6609024cf05710c842a844b3c37bc7..e5dca78c206c5fbb56a10d48ea1db865a035d6d7 100644 (file)
 #    (Optional) virtualhost to use.
 #    Defaults to '/'.
 #
+# [*rabbit_ha_queues*]
+#   (Optional) Use HA queues in RabbitMQ (x-ha-policy: all).
+#   Defaults to undef.
+#
 # [*rabbit_heartbeat_timeout_threshold*]
 #   (Optional) Number of seconds after which the RabbitMQ broker is considered
 #   down if the heartbeat keepalive fails.  Any value >0 enables heartbeats.
@@ -167,6 +171,7 @@ class ceilometer(
   $rabbit_userid                      = 'guest',
   $rabbit_password                    = '',
   $rabbit_virtual_host                = '/',
+  $rabbit_ha_queues                   = undef,
   $rabbit_heartbeat_timeout_threshold = 0,
   $rabbit_heartbeat_rate              = 2,
   $rabbit_use_ssl                     = false,
@@ -244,11 +249,15 @@ class ceilometer(
       }
     }
 
+    if $rabbit_ha_queues == undef {
       if size($rabbit_hosts) > 1 {
         ceilometer_config { 'oslo_messaging_rabbit/rabbit_ha_queues': value => true }
       } else {
         ceilometer_config { 'oslo_messaging_rabbit/rabbit_ha_queues': value => false }
       }
+    } else {
+      ceilometer_config { 'oslo_messaging_rabbit/rabbit_ha_queues': value => $rabbit_ha_queues }
+    }
 
       ceilometer_config {
         'oslo_messaging_rabbit/rabbit_userid':                value => $rabbit_userid;
index eb8672a9375327d5557862b05fe3f7c53452836b..98793253aeca9bc4054ffaf5606a38e8eaafdb56 100644 (file)
@@ -45,6 +45,12 @@ describe 'ceilometer' do
       it_configures 'rabbit with SSL support'
       it_configures 'rabbit without HA support (with backward compatibility)'
       it_configures 'rabbit with connection heartbeats'
+
+      context 'with rabbit_ha_queues' do
+        before { params.merge!( rabbit_params ).merge!( :rabbit_ha_queues => true ) }
+        it_configures 'rabbit with rabbit_ha_queues'
+       end
+
     end
 
     context 'with rabbit_hosts parameter' do
@@ -159,6 +165,13 @@ describe 'ceilometer' do
 
   end
 
+  shared_examples_for 'rabbit with rabbit_ha_queues' do
+
+    it 'configures rabbit' do
+      is_expected.to contain_ceilometer_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value( params[:rabbit_ha_queues] )
+    end
+  end
+
   shared_examples_for 'rabbit with HA support' do
 
     it 'configures rabbit' do