Blame SOURCES/bz1745713-rabbitmq-cluster-3-fix-stop-regression.patch

734564
From 19ee29342f8bb573722991b8cbe4503309ad0bf9 Mon Sep 17 00:00:00 2001
734564
From: John Eckersberg <jeckersb@redhat.com>
734564
Date: Fri, 2 Nov 2018 13:12:53 -0400
734564
Subject: [PATCH] rabbitmq-cluster: fix regression in rmq_stop
734564
734564
This regression was introduced in PR#1249 (cc23c55).  The stop action
734564
was modified to use rmq_app_running in order to check the service
734564
status, which allows for the following sequence of events:
734564
734564
- service is started, unclustered
734564
- stop_app is called
734564
- cluster_join is attempted and fails
734564
- stop is called
734564
734564
Because stop_app was called, rmq_app_running returns $OCF_NOT_RUNNING
734564
and the stop action is a no-op.  This means the erlang VM continues
734564
running.
734564
734564
When the start action is attempted again, a new erlang VM is launched,
734564
but this VM fails to boot because the old one is still running and is
734564
registered with the same name (rabbit@nodename).
734564
734564
This adds a new function, rmq_node_alive, which does a simple eval to
734564
test whether the erlang VM is up, independent of the rabbit app.  The
734564
stop action now uses rmq_node_alive to check the service status, so
734564
even if stop_app was previously called, the erlang VM will be stopped
734564
properly.
734564
734564
Resolves: RHBZ#1639826
734564
---
734564
 heartbeat/rabbitmq-cluster | 12 +++++++++++-
734564
 1 file changed, 11 insertions(+), 1 deletion(-)
734564
734564
diff --git a/heartbeat/rabbitmq-cluster b/heartbeat/rabbitmq-cluster
734564
index 78b2bbadf..a2de9dc20 100755
734564
--- a/heartbeat/rabbitmq-cluster
734564
+++ b/heartbeat/rabbitmq-cluster
734564
@@ -188,6 +188,16 @@ rmq_app_running() {
734564
 	fi
734564
 }
734564
 
734564
+rmq_node_alive() {
734564
+	if $RMQ_CTL eval 'ok.'; then
734564
+		ocf_log debug "RabbitMQ node is alive"
734564
+		return $OCF_SUCCESS
734564
+	else
734564
+		ocf_log debug "RabbitMQ node is down"
734564
+		return $OCF_NOT_RUNNING
734564
+	fi
734564
+}
734564
+
734564
 rmq_monitor() {
734564
 	local rc
734564
 
734564
@@ -514,7 +524,7 @@ rmq_stop() {
734564
 		end.
734564
 	"
734564
 
734564
-	rmq_app_running
734564
+	rmq_node_alive
734564
 	if [ $? -eq $OCF_NOT_RUNNING ]; then
734564
 		return $OCF_SUCCESS
734564
 	fi