Blame SOURCES/bz1641944-rabbitmq-cluster-monitor-mnesia-status.patch

00d327
From fcaa52bb98a8686d993550c6f4ab7867625c8059 Mon Sep 17 00:00:00 2001
00d327
From: John Eckersberg <jeckersb@redhat.com>
00d327
Date: Wed, 29 Aug 2018 16:18:55 -0400
00d327
Subject: [PATCH] rabbitmq-cluster: get cluster status from mnesia during
00d327
 monitor
00d327
00d327
If mnesia is not running (for example if `rabbitmqctl stop_app` has
00d327
been called, or the service has paused during partition due to the
00d327
pause_minority strategy) then the cluster_status command to
00d327
rabbitmqctl will read the cached cluster status from disk and the
00d327
command returns 0 even though the service isn't really running at all.
00d327
00d327
Instead, force the cluster status to be read from mnesia.  If mnesia
00d327
is not running due to the above or similar circumstances, the command
00d327
will catch that and properly fail the monitor action.
00d327
00d327
Resolves: RHBZ#1595753
00d327
---
00d327
 heartbeat/rabbitmq-cluster | 20 +++++---------------
00d327
 1 file changed, 5 insertions(+), 15 deletions(-)
00d327
00d327
diff --git a/heartbeat/rabbitmq-cluster b/heartbeat/rabbitmq-cluster
00d327
index a7d2db614..204917475 100755
00d327
--- a/heartbeat/rabbitmq-cluster
00d327
+++ b/heartbeat/rabbitmq-cluster
00d327
@@ -181,26 +181,16 @@ remove_pid () {
00d327
 rmq_monitor() {
00d327
 	local rc
00d327
 
00d327
-	$RMQ_CTL cluster_status > /dev/null 2>&1
00d327
-	rc=$?
00d327
-	case "$rc" in
00d327
-	0)
00d327
+	if $RMQ_CTL eval 'rabbit_mnesia:cluster_status_from_mnesia().' | grep -q '^{ok'; then
00d327
 		ocf_log debug "RabbitMQ server is running normally"
00d327
 		rmq_write_nodename
00d327
-		
00d327
+
00d327
 		return $OCF_SUCCESS
00d327
-	;;
00d327
-	2|68|69|70|75|78)
00d327
-		ocf_log info "RabbitMQ server is not running"
00d327
+	else
00d327
+		ocf_log info "RabbitMQ server could not get cluster status from mnesia"
00d327
 		rmq_delete_nodename
00d327
 		return $OCF_NOT_RUNNING
00d327
-	;;
00d327
-	*)
00d327
-		ocf_log err "Unexpected return code from '$RMQ_CTL cluster_status' exit code: $rc"
00d327
-		rmq_delete_nodename
00d327
-		return $OCF_ERR_GENERIC
00d327
-	;;
00d327
-	esac
00d327
+	fi
00d327
 }
00d327
 
00d327
 rmq_init_and_wait()