Fix rabbitmq-ready check for single node HA deployments

The current rabbitmq-ready exec waits for rabbitmq to become clustered
before it allows user creation. Unfortunately this doesn't work when
the deployment contains a single node, because rabbit doesn't trigger
the clustering mode at all.

Set the exec test according to the number of rabbit nodes, in order
to check for cluster state only when necessary.

Closes-Bug: #1741345

Change-Id: I24e5e344b7f657ce5d42a7c7c45be7b5ed5e6445
Co-Authored-By: John Eckersberg <jeckersb@redhat.com>
(cherry picked from commit 1cfecc39dc)
This commit is contained in:
Damien Ciabrini 2018-01-05 09:50:17 +00:00 committed by Emilien Macchi
parent 77b4e589b5
commit 958f824c85
1 changed files with 11 additions and 5 deletions

View File

@ -220,13 +220,19 @@ class tripleo::profile::pacemaker::rabbitmq_bundle (
before => Exec['rabbitmq-ready'],
}
# This grep makes sure the rabbit app in erlang is up and running
# which is enough to guarantee that the user will eventually get
# replicated around the cluster
if size($rabbit_nodes) == 1 {
$check_command = 'rabbitmqctl status | grep -F "{rabbit,"'
} else {
# This grep makes sure the rabbit app in erlang is up and running
# which is enough to guarantee that the user will eventually get
# replicated around the cluster
$check_command = 'rabbitmqctl eval "rabbit_mnesia:is_clustered()." | grep -q true'
}
exec { 'rabbitmq-ready':
path => '/usr/sbin:/usr/bin:/sbin:/bin',
command => 'rabbitmqctl eval "rabbit_mnesia:is_clustered()." | grep -q true',
unless => 'rabbitmqctl eval "rabbit_mnesia:is_clustered()." | grep -q true',
command => $check_command,
unless => $check_command,
timeout => 30,
tries => 180,
try_sleep => 10,