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

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