From ec5918f2f6ee54c3384e85866e98b67ef01e1e1e Mon Sep 17 00:00:00 2001 From: Ben Nemec Date: Thu, 30 Jan 2014 16:07:23 +0000 Subject: [PATCH] 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 --- lib/rpc_backend | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/rpc_backend b/lib/rpc_backend index f59c80096f..3651bc0d20 100644 --- a/lib/rpc_backend +++ b/lib/rpc_backend @@ -139,12 +139,18 @@ function restart_rpc_backend() { 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