Browse code

Merge "Fix rabbitmq retry for error checking"

Jenkins authored on 2014/12/18 09:57:08
Showing 1 changed files
... ...
@@ -176,17 +176,31 @@ function restart_rpc_backend {
176 176
         echo_summary "Starting RabbitMQ"
177 177
         # NOTE(bnemec): Retry initial rabbitmq configuration to deal with
178 178
         # the fact that sometimes it fails to start properly.
179
-        # Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1059028
179
+        # Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1144100
180 180
         local i
181 181
         for i in `seq 10`; do
182
+            local rc=0
183
+
184
+            [[ $i -eq "10" ]] && die $LINENO "Failed to set rabbitmq password"
185
+
182 186
             if is_fedora || is_suse; then
183 187
                 # service is not started by default
184 188
                 restart_service rabbitmq-server
185 189
             fi
186
-            rabbit_setuser "$RABBIT_USERID" "$RABBIT_PASSWORD"
190
+
191
+            rabbit_setuser "$RABBIT_USERID" "$RABBIT_PASSWORD" || rc=$?
192
+            if [ $rc -ne 0 ]; then
193
+                continue
194
+            fi
195
+
187 196
             # change the rabbit password since the default is "guest"
188
-            sudo rabbitmqctl change_password $RABBIT_USERID $RABBIT_PASSWORD && break
189
-            [[ $i -eq "10" ]] && die $LINENO "Failed to set rabbitmq password"
197
+            sudo rabbitmqctl change_password \
198
+                $RABBIT_USERID $RABBIT_PASSWORD || rc=$?
199
+            if [ $rc -ne 0 ]; then
200
+                continue;
201
+            fi
202
+
203
+            break
190 204
         done
191 205
         if is_service_enabled n-cell; then
192 206
             # Add partitioned access for the child cell