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

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