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
(cherry picked from commit 8e40680310)
This commit is contained in:
Mike Dorman 2015-06-22 14:32:06 -06:00 committed by Martin Mágr
parent 48fe29a341
commit ac0be6e51f
2 changed files with 48 additions and 15 deletions

View File

@ -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;
}

View File

@ -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
{