Blame SOURCES/bz1881114-galera-recover-joining-non-existing-cluster.patch

030326
From 028bd6aab181104fe68166c8ec9c0485e12f9376 Mon Sep 17 00:00:00 2001
030326
From: Damien Ciabrini <dciabrin@redhat.com>
030326
Date: Fri, 18 Sep 2020 18:34:22 +0200
030326
Subject: [PATCH] galera: recover from joining a non existing cluster
030326
030326
galera being a M/S resource, the resource agent decides
030326
when and how to promote a resource based on the current
030326
state of the galera cluster. If there's no cluster,
030326
a resource is promoted as the bootstrap node. Otherwise
030326
it is promoted as a joiner node.
030326
030326
There can be some time between the moment when a node is
030326
promoted and when the promote operation effectively
030326
takes place. So if a node is promoted for joining a cluster,
030326
all the running galera nodes are stopped before the promote
030326
operation start, the joining node won't be able to join the
030326
cluster, and it can't bootstrap a new one either because it
030326
doesn't have the most recent copy of the DB.
030326
030326
In that case, do not make the promotion fail, and force
030326
a demotion instead. This ensures that a normal bootstrap
030326
election will take place eventually, without blocking
030326
the joining node due to a failed promotion.
030326
---
030326
 heartbeat/galera | 13 ++++++++++---
030326
 1 file changed, 10 insertions(+), 3 deletions(-)
030326
030326
diff --git a/heartbeat/galera b/heartbeat/galera
030326
index 74f11d8c5..d2f4faa86 100755
030326
--- a/heartbeat/galera
030326
+++ b/heartbeat/galera
030326
@@ -727,9 +727,16 @@ galera_promote()
030326
             ocf_log info "Node <${NODENAME}> is bootstrapping the cluster"
030326
             extra_opts="--wsrep-cluster-address=gcomm://"
030326
         else
030326
-            ocf_exit_reason "Failure, Attempted to promote Master instance of $OCF_RESOURCE_INSTANCE before bootstrap node has been detected."
030326
-            clear_last_commit
030326
-            return $OCF_ERR_GENERIC
030326
+            # We are being promoted without having the bootstrap
030326
+            # attribute in the CIB, which means we are supposed to
030326
+            # join a cluster; however if we end up here, there is no
030326
+            # Master remaining right now, which means there is no
030326
+            # cluster to join anymore. So force a demotion, and and
030326
+            # let the RA decide later which node should be the next
030326
+            # bootstrap node.
030326
+            ocf_log warn "There is no running cluster to join, demoting ourself"
030326
+            clear_master_score
030326
+            return $OCF_SUCCESS
030326
         fi
030326
     fi
030326