Blame SOURCES/bz1641946-2-rabbitmq-cluster-fix-stop-regression.patch

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