Retry rabbitmq password change
Due to the bug referenced below, on Fedora it is possible for
the rabbitmq password change to fail the first time rabbitmq is
started. This change adds a retry loop to avoid the problem in
devstack. One retry should be enough in most (all?) cases, but
this will retry up to ten times just to be safe.
Note that just retrying the password change is not enough. The
rabbitmq-server service must be restarted as well.
Change-Id: I403dcd503aa8e74e2ba6312a0decf0d4fd0d8795
bz: https://bugzilla.redhat.com/show_bug.cgi?id=1059028
diff --git a/lib/rpc_backend b/lib/rpc_backend
index f59c800..3651bc0 100644
--- a/lib/rpc_backend
+++ b/lib/rpc_backend
@@ -139,12 +139,18 @@
if is_service_enabled rabbit; then
# Start rabbitmq-server
echo_summary "Starting RabbitMQ"
- if is_fedora || is_suse; then
- # service is not started by default
- restart_service rabbitmq-server
- fi
- # change the rabbit password since the default is "guest"
- sudo rabbitmqctl change_password guest $RABBIT_PASSWORD
+ # NOTE(bnemec): Retry initial rabbitmq configuration to deal with
+ # the fact that sometimes it fails to start properly.
+ # Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1059028
+ for i in `seq 10`; do
+ if is_fedora || is_suse; then
+ # service is not started by default
+ restart_service rabbitmq-server
+ fi
+ # change the rabbit password since the default is "guest"
+ sudo rabbitmqctl change_password guest $RABBIT_PASSWORD && break
+ [[ $i -eq "10" ]] && die $LINENO "Failed to set rabbitmq password"
+ done
if is_service_enabled n-cell; then
# Add partitioned access for the child cell
if [ -z `sudo rabbitmqctl list_vhosts | grep child_cell` ]; then