messaging: enable HA queues when HAproxy binding is enabled

If HAproxy binding is enabled for RabbitMQ service, we need to ensure
queres are replicated and this is done by a specific policy.

Since OpenStack is already tagging queues with rabbit_ha_queues=True
parameter everywhere, we just create the policy and the queues by
themselves.

This is enabled only if HAproxy binding is enabled for now, because the
feature seems required when using RabbitMQ load-balancing. The other
use-case (when using Oslo messaging to failover to another RabbitMQ node)
does not require this policy. If a node is down, OpenStack will fallback
to another RabbitMQ node in the list from parameters.

This patch allows you to configure 'exactly' or 'all' RabbitMQ HA policy modes.

Why using 'exactly' mode ?
To let operators scale up/down the replication accross an exact number
of nodes.

How it works ?
Queue is mirrored to count nodes in the cluster. If there are less than
count nodes in the cluster, the queue is mirrored to all nodes. If there
are more than count nodes in the cluster, and a node containing a mirror
goes down, then a new mirror will be created on another node.

Also change the Puppetfile to have latest commits in puppetlabs-rabbitmq
to have some fix related to rabbitmq_policy provider.
Without this fix, some parameters are not integers but string, and we
need integer.

Closes-bug #1434474

Change-Id: I3f732360f83e10e0ae525573f9afdb7f68475149
This commit is contained in:
Emilien Macchi 2015-03-30 12:08:11 -04:00
parent 5e07f511b4
commit 7f2ae4f105
2 changed files with 68 additions and 0 deletions

View File

@ -32,6 +32,17 @@
# Could be set to 'disk' or 'ram'.
# Defaults to 'disc'
#
# [*cluster_count*]
# (optional) Queue is mirrored to count nodes in the cluster.
# If there are less than count nodes in the cluster, the queue
# is mirrored to all nodes. If there are more than count nodes
# in the cluster, and a node containing a mirror goes down,
# then a new mirror will be created on another node.
# If a value is set, RabbitMQ policy will be 'exactly'.
# Otherwise, undef will set the policy to 'all' by default.
# To enable this feature, you need 'haproxy_binding' to true.
# Defaults to undef
#
# [*haproxy_binding*]
# (optional) Enable or not HAproxy binding for load-balancing.
# Defaults to false
@ -58,6 +69,7 @@
class cloud::messaging(
$erlang_cookie,
$cluster_node_type = 'disc',
$cluster_count = undef,
$rabbit_names = $::hostname,
$rabbit_password = 'rabbitpassword',
$haproxy_binding = false,
@ -140,6 +152,24 @@ class cloud::messaging(
}
if $haproxy_binding {
if $cluster_count {
$policy_name = "ha-exactly-${cluster_count}@/"
$definition = {
'ha-mode' => 'exactly',
'ha-params' => $cluster_count,
}
} else {
$policy_name = 'ha-all@/'
$definition = {
'ha-mode' => 'all',
}
}
rabbitmq_policy { $policy_name:
pattern => '^(?!amq\.).*',
definition => $definition,
}
@@haproxy::balancermember{"${::fqdn}-rabbitmq":
listening_service => 'rabbitmq_cluster',
server_names => $::hostname,

View File

@ -29,6 +29,7 @@ describe 'cloud::messaging' do
:rabbit_password => 'secrete',
:erlang_cookie => 'MY_COOKIE',
:rabbitmq_ip => '10.0.0.1',
:haproxy_binding => false,
}
end
@ -90,6 +91,43 @@ describe 'cloud::messaging' do
)
end
end
context 'with HAproxy binding and HA policy to exactly' do
before :each do
params.merge!(
:haproxy_binding => true,
:cluster_count => 3,
)
end
it 'configure ha-exactly rabbitmq_policy' do
is_expected.to contain_rabbitmq_policy('ha-exactly-3@/').with(
:pattern => '^(?!amq\.).*',
:definition => {
'ha-mode' => 'exactly',
'ha-params' => 3,
},
)
end
end
context 'with HAproxy binding and HA policy to all' do
before :each do
params.merge!(
:haproxy_binding => true,
)
end
it 'configure ha-exactly rabbitmq_policy' do
is_expected.to contain_rabbitmq_policy('ha-all@/').with(
:pattern => '^(?!amq\.).*',
:definition => {
'ha-mode' => 'all',
},
)
end
end
end
context 'on Debian platforms' do