You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

53 lines
2.0 KiB

From 279bae7ec9a571a4d52b0d876850e27772eb0933 Mon Sep 17 00:00:00 2001
From: Jiri Stransky <jistr@redhat.com>
Date: Thu, 23 Jun 2016 12:55:06 +0200
Subject: [PATCH] RabbitMQ: Forget node before 2nd joining attempt
If a first attempt at joining an existing cluster has failed and we
resort to wiping the local RabbitMQ data, make sure we also request the
local node to be forgotten from the existing cluster before we make the
join attempt, otherwise the node will be rejected.
---
heartbeat/rabbitmq-cluster | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/heartbeat/rabbitmq-cluster b/heartbeat/rabbitmq-cluster
index 0724901..b9ae38e 100755
--- a/heartbeat/rabbitmq-cluster
+++ b/heartbeat/rabbitmq-cluster
@@ -279,6 +279,22 @@ rmq_join_existing()
return $OCF_SUCCESS
}
+rmq_forget_cluster_node_remotely() {
+ local running_cluster_nodes="$1"
+ local node_to_forget="$2"
+
+ ocf_log info "Forgetting $node_to_forget via nodes [ $(echo $running_cluster_nodes | tr '\n' ' ') ]."
+ for running_cluster_node in $running_cluster_nodes; do
+ rabbitmqctl -n $running_cluster_node forget_cluster_node $node_to_forget
+ if [ $? = 0 ]; then
+ ocf_log info "Succeeded forgetting $node_to_forget via $running_cluster_node."
+ return
+ else
+ ocf_log err "Failed to forget node $node_to_forget via $running_cluster_node."
+ fi
+ done
+}
+
rmq_notify() {
node_list="${OCF_RESKEY_CRM_meta_notify_stop_uname}"
mode="${OCF_RESKEY_CRM_meta_notify_type}-${OCF_RESKEY_CRM_meta_notify_operation}"
@@ -336,9 +352,12 @@ rmq_start() {
rmq_join_existing "$join_list"
if [ $? -ne 0 ]; then
ocf_log info "node failed to join, wiping data directory and trying again"
+ local local_rmq_node="$(${HA_SBIN_DIR}/crm_attribute -N $NODENAME -l forever --query --name $RMQ_CRM_ATTR_COOKIE_LAST_KNOWN -q)"
+
# if the graceful join fails, use the hammer and reset all the data.
rmq_stop
rmq_wipe_data
+ rmq_forget_cluster_node_remotely "$join_list" "$local_rmq_node"
rmq_join_existing "$join_list"
rc=$?