Add rabbit_ha_queues option

There are two ways for setting up RabbitMQ HA:

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

In current, 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 is aim to add an rabbit_ha_queues option, set it to undef
by default for forward compatbility.

Change-Id: I9f61c113b41cb00f7f95e80e2cabe1641aed74e7
Close-Bug: #1485287
This commit is contained in:
Xingchao Yu 2015-08-21 15:46:41 +08:00
parent aa3be49105
commit 81333fce40
2 changed files with 33 additions and 5 deletions

View File

@ -21,6 +21,10 @@
# [*rabbit_virtual_host*]
# virtual_host to use. Optional. 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.
@ -86,6 +90,7 @@ class glance::notify::rabbitmq(
$rabbit_port = '5672',
$rabbit_hosts = false,
$rabbit_virtual_host = '/',
$rabbit_ha_queues = undef,
$rabbit_heartbeat_timeout_threshold = 0,
$rabbit_heartbeat_rate = 2,
$rabbit_use_ssl = false,
@ -111,17 +116,26 @@ class glance::notify::rabbitmq(
if $rabbit_hosts {
glance_api_config {
'oslo_messaging_rabbit/rabbit_hosts': value => join($rabbit_hosts, ',');
'oslo_messaging_rabbit/rabbit_ha_queues': value => true
}
} else {
glance_api_config {
'oslo_messaging_rabbit/rabbit_host': value => $rabbit_host;
'oslo_messaging_rabbit/rabbit_port': value => $rabbit_port;
'oslo_messaging_rabbit/rabbit_hosts': value => "${rabbit_host}:${rabbit_port}";
'oslo_messaging_rabbit/rabbit_ha_queues': value => false
}
}
# by default rabbit_ha_queues is undef
if $rabbit_ha_queues == undef {
if $rabbit_hosts {
glance_api_config { 'oslo_messaging_rabbit/rabbit_ha_queues': value => true }
} else {
glance_api_config { 'oslo_messaging_rabbit/rabbit_ha_queues': value => false }
}
} else {
glance_api_config { 'oslo_messaging_rabbit/rabbit_ha_queues': value => $rabbit_ha_queues }
}
glance_api_config {
'DEFAULT/notification_driver': value => $notification_driver;
'oslo_messaging_rabbit/rabbit_virtual_host': value => $rabbit_virtual_host;

View File

@ -114,9 +114,9 @@ describe 'glance::notify::rabbitmq' do
describe 'when passing params for multiple rabbit hosts' do
let :params do
{
:rabbit_password => 'pass',
:rabbit_userid => 'guest3',
:rabbit_hosts => ['nonlocalhost3:5673', 'nonlocalhost4:5673']
:rabbit_password => 'pass',
:rabbit_userid => 'guest3',
:rabbit_hosts => ['nonlocalhost3:5673', 'nonlocalhost4:5673']
}
end
it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_userid').with_value('guest3') }
@ -127,6 +127,20 @@ describe 'glance::notify::rabbitmq' do
it { is_expected.to_not contain_glance_api_config('oslo_messaging_rabbit/rabbit_host') }
end
describe 'a single rabbit_host with enable ha queues' do
let :params do
{
:rabbit_password => 'pass',
:rabbit_userid => 'guest3',
:rabbit_ha_queues => true,
}
end
it 'should contain rabbit_ha_queues' do
is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value('true')
end
end
describe 'when passing params for rabbitmq heartbeat' do
let :params do
{