From 8e4068031037e60646525c37de512c0ffe4443a7 Mon Sep 17 00:00:00 2001 From: Mike Dorman Date: Mon, 22 Jun 2015 14:32:06 -0600 Subject: [PATCH] Add support for RabbitMQ connection heartbeat 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: I3aef101e3a099bcbd96ee32efa7c5f849e6000cf --- manifests/notify/rabbitmq.pp | 49 ++++++++++++++------- spec/classes/glance_notify_rabbitmq_spec.rb | 14 ++++++ 2 files changed, 48 insertions(+), 15 deletions(-) diff --git a/manifests/notify/rabbitmq.pp b/manifests/notify/rabbitmq.pp index a5543492..87110e83 100644 --- a/manifests/notify/rabbitmq.pp +++ b/manifests/notify/rabbitmq.pp @@ -21,6 +21,21 @@ # [*rabbit_virtual_host*] # virtual_host 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 @@ -61,21 +76,23 @@ class glance::notify::rabbitmq( $rabbit_password, - $rabbit_userid = 'guest', - $rabbit_host = 'localhost', - $rabbit_port = '5672', - $rabbit_hosts = false, - $rabbit_virtual_host = '/', - $rabbit_use_ssl = false, - $kombu_ssl_ca_certs = undef, - $kombu_ssl_certfile = undef, - $kombu_ssl_keyfile = undef, - $kombu_ssl_version = 'TLSv1', - $rabbit_notification_exchange = 'glance', - $rabbit_notification_topic = 'notifications', - $rabbit_durable_queues = false, - $amqp_durable_queues = false, - $notification_driver = 'messaging', + $rabbit_userid = 'guest', + $rabbit_host = 'localhost', + $rabbit_port = '5672', + $rabbit_hosts = false, + $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', + $rabbit_notification_exchange = 'glance', + $rabbit_notification_topic = 'notifications', + $rabbit_durable_queues = false, + $amqp_durable_queues = false, + $notification_driver = 'messaging', ) { if $rabbit_durable_queues { @@ -106,6 +123,8 @@ class glance::notify::rabbitmq( 'oslo_messaging_rabbit/rabbit_userid': value => $rabbit_userid; 'oslo_messaging_rabbit/rabbit_notification_exchange': value => $rabbit_notification_exchange; 'oslo_messaging_rabbit/rabbit_notification_topic': value => $rabbit_notification_topic; + 'oslo_messaging_rabbit/heartbeat_timeout_threshold': value => $rabbit_heartbeat_timeout_threshold; + 'oslo_messaging_rabbit/heartbeat_rate': value => $rabbit_heartbeat_rate; 'oslo_messaging_rabbit/rabbit_use_ssl': value => $rabbit_use_ssl; 'DEFAULT/amqp_durable_queues': value => $amqp_durable_queues_real; } diff --git a/spec/classes/glance_notify_rabbitmq_spec.rb b/spec/classes/glance_notify_rabbitmq_spec.rb index 7f5f76fa..ad84e284 100644 --- a/spec/classes/glance_notify_rabbitmq_spec.rb +++ b/spec/classes/glance_notify_rabbitmq_spec.rb @@ -26,6 +26,8 @@ describe 'glance::notify::rabbitmq' do it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_virtual_host').with_value('/') } it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_notification_exchange').with_value('glance') } it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_notification_topic').with_value('notifications') } + it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('0') } + it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/heartbeat_rate').with_value('2') } end describe 'when passing params and use ssl' do @@ -122,6 +124,18 @@ describe 'glance::notify::rabbitmq' do it { is_expected.to_not contain_glance_api_config('oslo_messaging_rabbit/rabbit_host') } end + describe 'when passing params for rabbitmq heartbeat' do + let :params do + { + :rabbit_password => 'pass', + :rabbit_heartbeat_timeout_threshold => '60', + :rabbit_heartbeat_rate => '10', + } + end + it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('60') } + it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/heartbeat_rate').with_value('10') } + end + describe 'when using deprecated params' do let :params do {