]> review.fuel-infra Code Review - puppet-modules/puppet-ceilometer.git/commitdiff
Add support for RabbitMQ connection heartbeat
authorMike Dorman <mdorman@godaddy.com>
Mon, 22 Jun 2015 20:03:24 +0000 (14:03 -0600)
committerMike Dorman <mdorman@godaddy.com>
Tue, 7 Jul 2015 17:31:07 +0000 (11:31 -0600)
Kilo oslo.messaging added heartbeating support for RabbitMQ
connections.  This patch adds support for this in Puppet modules
by managing the oslo_messaging_rabbit/heartbeat_timeout_threshold
and oslo_messaging_rabbit/heartbeat_rate settings.

Closes-bug: 1467667
Change-Id: I985d081c86975c5b216f6346cbd9a368dd0d33d3

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

index 577e3533f2cfd23f3caf247d871c1727cf61b291..3769f3ce986e8dd68bf8104f0c0819955f7071ce 100644 (file)
 #    password to connect to the rabbit_server. Optional. Defaults to empty.
 #  [*rabbit_virtual_host*]
 #    virtualhost to use. Optional. Defaults to '/'
+#
+# [*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.
+#   Heartbeating helps to ensure the TCP connection to RabbitMQ isn't silently
+#   closed, resulting in missed or lost messages from the queue.
+#   (Requires kombu >= 3.0.7 and amqp >= 1.4.0)
+#   Defaults to 0
+#
+# [*rabbit_heartbeat_rate*]
+#   (optional) How often during the rabbit_heartbeat_timeout_threshold period to
+#   check the heartbeat on RabbitMQ connection.  (i.e. rabbit_heartbeat_rate=2
+#   when rabbit_heartbeat_timeout_threshold=60, the heartbeat will be checked
+#   every 30 seconds.
+#   Defaults to 2
+#
 #  [*rabbit_use_ssl*]
 #    (optional) Connect over SSL for RabbitMQ
 #    Defaults to false
 # (optional) various QPID options
 #
 class ceilometer(
-  $metering_secret     = false,
-  $notification_topics = ['notifications'],
-  $package_ensure      = 'present',
-  $debug               = false,
-  $log_dir             = '/var/log/ceilometer',
-  $verbose             = false,
-  $use_syslog          = false,
-  $log_facility        = 'LOG_USER',
-  $rpc_backend         = 'ceilometer.openstack.common.rpc.impl_kombu',
-  $rabbit_host         = '127.0.0.1',
-  $rabbit_port         = 5672,
-  $rabbit_hosts        = undef,
-  $rabbit_userid       = 'guest',
-  $rabbit_password     = '',
-  $rabbit_virtual_host = '/',
-  $rabbit_use_ssl      = false,
-  $kombu_ssl_ca_certs  = undef,
-  $kombu_ssl_certfile  = undef,
-  $kombu_ssl_keyfile   = undef,
-  $kombu_ssl_version   = 'TLSv1',
-  $qpid_hostname = 'localhost',
-  $qpid_port = 5672,
-  $qpid_username = 'guest',
-  $qpid_password = 'guest',
-  $qpid_heartbeat = 60,
-  $qpid_protocol = 'tcp',
-  $qpid_tcp_nodelay = true,
-  $qpid_reconnect = true,
-  $qpid_reconnect_timeout = 0,
-  $qpid_reconnect_limit = 0,
-  $qpid_reconnect_interval_min = 0,
-  $qpid_reconnect_interval_max = 0,
-  $qpid_reconnect_interval = 0
+  $metering_secret                    = false,
+  $notification_topics                = ['notifications'],
+  $package_ensure                     = 'present',
+  $debug                              = false,
+  $log_dir                            = '/var/log/ceilometer',
+  $verbose                            = false,
+  $use_syslog                         = false,
+  $log_facility                       = 'LOG_USER',
+  $rpc_backend                        = 'ceilometer.openstack.common.rpc.impl_kombu',
+  $rabbit_host                        = '127.0.0.1',
+  $rabbit_port                        = 5672,
+  $rabbit_hosts                       = undef,
+  $rabbit_userid                      = 'guest',
+  $rabbit_password                    = '',
+  $rabbit_virtual_host                = '/',
+  $rabbit_heartbeat_timeout_threshold = 0,
+  $rabbit_heartbeat_rate              = 2,
+  $rabbit_use_ssl                     = false,
+  $kombu_ssl_ca_certs                 = undef,
+  $kombu_ssl_certfile                 = undef,
+  $kombu_ssl_keyfile                  = undef,
+  $kombu_ssl_version                  = 'TLSv1',
+  $qpid_hostname                      = 'localhost',
+  $qpid_port                          = 5672,
+  $qpid_username                      = 'guest',
+  $qpid_password                      = 'guest',
+  $qpid_heartbeat                     = 60,
+  $qpid_protocol                      = 'tcp',
+  $qpid_tcp_nodelay                   = true,
+  $qpid_reconnect                     = true,
+  $qpid_reconnect_timeout             = 0,
+  $qpid_reconnect_limit               = 0,
+  $qpid_reconnect_interval_min        = 0,
+  $qpid_reconnect_interval_max        = 0,
+  $qpid_reconnect_interval            = 0,
 ) {
 
   validate_string($metering_secret)
@@ -187,10 +205,12 @@ class ceilometer(
       }
 
       ceilometer_config {
-        'oslo_messaging_rabbit/rabbit_userid'          : value => $rabbit_userid;
-        'oslo_messaging_rabbit/rabbit_password'        : value => $rabbit_password, secret => true;
-        'oslo_messaging_rabbit/rabbit_virtual_host'    : value => $rabbit_virtual_host;
-        'oslo_messaging_rabbit/rabbit_use_ssl'         : value => $rabbit_use_ssl;
+        'oslo_messaging_rabbit/rabbit_userid':                value => $rabbit_userid;
+        'oslo_messaging_rabbit/rabbit_password':              value => $rabbit_password, secret => true;
+        'oslo_messaging_rabbit/rabbit_virtual_host':          value => $rabbit_virtual_host;
+        'oslo_messaging_rabbit/rabbit_use_ssl':               value => $rabbit_use_ssl;
+        'oslo_messaging_rabbit/heartbeat_timeout_threshold':  value => $rabbit_heartbeat_timeout_threshold;
+        'oslo_messaging_rabbit/heartbeat_rate':               value => $rabbit_heartbeat_rate;
       }
 
       if $rabbit_use_ssl {
index 536a30614bce2bf3c49e7d98d4cd6fb1ebb94344..594fbb09ed58da9be4e6bbd54accd5dae934c16d 100644 (file)
@@ -39,6 +39,7 @@ describe 'ceilometer' do
       it_configures 'a ceilometer base installation'
       it_configures 'rabbit with SSL support'
       it_configures 'rabbit without HA support (with backward compatibility)'
+      it_configures 'rabbit with connection heartbeats'
     end
 
     context 'with rabbit_hosts parameter' do
@@ -178,6 +179,8 @@ describe 'ceilometer' do
       is_expected.to contain_ceilometer_config('oslo_messaging_rabbit/rabbit_password').with_value( params[:rabbit_password] )
       is_expected.to contain_ceilometer_config('oslo_messaging_rabbit/rabbit_password').with_value( params[:rabbit_password] ).with_secret(true)
       is_expected.to contain_ceilometer_config('oslo_messaging_rabbit/rabbit_virtual_host').with_value( params[:rabbit_virtual_host] )
+      is_expected.to contain_ceilometer_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('0')
+      is_expected.to contain_ceilometer_config('oslo_messaging_rabbit/heartbeat_rate').with_value('2')
     end
 
     it { is_expected.to contain_ceilometer_config('oslo_messaging_rabbit/rabbit_host').with_value( params[:rabbit_host] ) }
@@ -194,6 +197,8 @@ describe 'ceilometer' do
       is_expected.to contain_ceilometer_config('oslo_messaging_rabbit/rabbit_password').with_value( params[:rabbit_password] )
       is_expected.to contain_ceilometer_config('oslo_messaging_rabbit/rabbit_password').with_value( params[:rabbit_password] ).with_secret(true)
       is_expected.to contain_ceilometer_config('oslo_messaging_rabbit/rabbit_virtual_host').with_value( params[:rabbit_virtual_host] )
+      is_expected.to contain_ceilometer_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('0')
+      is_expected.to contain_ceilometer_config('oslo_messaging_rabbit/heartbeat_rate').with_value('2')
     end
 
     it { is_expected.to contain_ceilometer_config('oslo_messaging_rabbit/rabbit_host').with_ensure('absent') }
@@ -210,6 +215,8 @@ describe 'ceilometer' do
       is_expected.to contain_ceilometer_config('oslo_messaging_rabbit/rabbit_password').with_value( params[:rabbit_password] )
       is_expected.to contain_ceilometer_config('oslo_messaging_rabbit/rabbit_password').with_value( params[:rabbit_password] ).with_secret(true)
       is_expected.to contain_ceilometer_config('oslo_messaging_rabbit/rabbit_virtual_host').with_value( params[:rabbit_virtual_host] )
+      is_expected.to contain_ceilometer_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('0')
+      is_expected.to contain_ceilometer_config('oslo_messaging_rabbit/heartbeat_rate').with_value('2')
     end
 
     it { is_expected.to contain_ceilometer_config('oslo_messaging_rabbit/rabbit_host').with_ensure('absent') }
@@ -219,6 +226,18 @@ describe 'ceilometer' do
 
   end
 
+  shared_examples_for 'rabbit with connection heartbeats' do
+    context "with heartbeat configuration" do
+      before { params.merge!(
+        :rabbit_heartbeat_timeout_threshold => '60',
+        :rabbit_heartbeat_rate              => '10'
+      ) }
+
+      it { is_expected.to contain_ceilometer_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('60') }
+      it { is_expected.to contain_ceilometer_config('oslo_messaging_rabbit/heartbeat_rate').with_value('10') }
+    end
+  end
+
   shared_examples_for 'rabbit with SSL support' do
     context "with default parameters" do
       it { is_expected.to contain_ceilometer_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value('false') }