Blame SOURCES/bz1780134-2-votequorum-Reflect-runtime-change-of-2Node-to-WFA.patch

c6d3cb
From bfbed8c320b0c0c5d3db48630f3de77e5fd62b75 Mon Sep 17 00:00:00 2001
c6d3cb
From: Jan Friesse <jfriesse@redhat.com>
c6d3cb
Date: Thu, 16 Jan 2020 15:43:59 +0100
c6d3cb
Subject: [PATCH] votequorum: Reflect runtime change of 2Node to WFA
c6d3cb
c6d3cb
When 2Node mode is set, WFA is also set unless WFA is configured
c6d3cb
explicitly. This behavior was not reflected on runtime change, so
c6d3cb
restarted corosync behavior was different (WFA not set). Also when
c6d3cb
cluster is reduced from 3 nodes to 2 nodes during runtime, WFA was not
c6d3cb
set, what may result in two quorate partitions.
c6d3cb
c6d3cb
Solution is to set WFA depending on 2Node when WFA
c6d3cb
is not explicitly configured.
c6d3cb
c6d3cb
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
c6d3cb
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
c6d3cb
(cherry picked from commit 8ce65bf951bc1e5b2d64b60ea027fbdc551d4fc8)
c6d3cb
---
c6d3cb
 exec/votequorum.c | 24 +++++++++++++++++++-----
c6d3cb
 1 file changed, 19 insertions(+), 5 deletions(-)
c6d3cb
c6d3cb
diff --git a/exec/votequorum.c b/exec/votequorum.c
c6d3cb
index 2fb5db9..d87b6fd 100644
c6d3cb
--- a/exec/votequorum.c
c6d3cb
+++ b/exec/votequorum.c
c6d3cb
@@ -80,6 +80,7 @@ static uint8_t two_node = 0;
c6d3cb
 
c6d3cb
 static uint8_t wait_for_all = 0;
c6d3cb
 static uint8_t wait_for_all_status = 0;
c6d3cb
+static uint8_t wait_for_all_autoset = 0; /* Wait for all is not set explicitly and follows two_node */
c6d3cb
 
c6d3cb
 static enum {ATB_NONE, ATB_LOWEST, ATB_HIGHEST, ATB_LIST} auto_tie_breaker = ATB_NONE, initial_auto_tie_breaker = ATB_NONE;
c6d3cb
 static int lowest_node_id = -1;
c6d3cb
@@ -1316,12 +1317,10 @@ static char *votequorum_readconfig(int runtime)
c6d3cb
 	 * Enable special features
c6d3cb
 	 */
c6d3cb
 	if (!runtime) {
c6d3cb
-		if (two_node) {
c6d3cb
-			wait_for_all = 1;
c6d3cb
-		}
c6d3cb
-
c6d3cb
 		(void)icmap_get_uint8("quorum.allow_downscale", &allow_downscale);
c6d3cb
-		(void)icmap_get_uint8("quorum.wait_for_all", &wait_for_all);
c6d3cb
+		if (icmap_get_uint8("quorum.wait_for_all", &wait_for_all) != CS_OK) {
c6d3cb
+			wait_for_all_autoset = 1;
c6d3cb
+		}
c6d3cb
 		(void)icmap_get_uint8("quorum.last_man_standing", &last_man_standing);
c6d3cb
 		(void)icmap_get_uint32("quorum.last_man_standing_window", &last_man_standing_window);
c6d3cb
 		(void)icmap_get_uint8("quorum.expected_votes_tracking", &ev_tracking);
c6d3cb
@@ -1362,6 +1361,15 @@ static char *votequorum_readconfig(int runtime)
c6d3cb
 
c6d3cb
 	}
c6d3cb
 
c6d3cb
+	/*
c6d3cb
+	 * Changing of wait_for_all during runtime is not supported, but changing of two_node is
c6d3cb
+	 * and two_node may set wfa if not configured explicitly. It is safe to unset it
c6d3cb
+	 * (or set it back) when two_node changes.
c6d3cb
+	 */
c6d3cb
+	if (wait_for_all_autoset) {
c6d3cb
+		wait_for_all = two_node;
c6d3cb
+	}
c6d3cb
+
c6d3cb
 	/* two_node and auto_tie_breaker are not compatible as two_node uses
c6d3cb
 	 * a fence race to decide quorum whereas ATB decides based on node id
c6d3cb
 	 */
c6d3cb
@@ -1541,6 +1549,12 @@ static char *votequorum_readconfig(int runtime)
c6d3cb
 	update_two_node();
c6d3cb
 	if (wait_for_all) {
c6d3cb
 		update_wait_for_all_status(1);
c6d3cb
+	} else if (wait_for_all_autoset && wait_for_all_status) {
c6d3cb
+		/*
c6d3cb
+		 * Reset wait for all status for consistency when wfa is auto-unset by 2node.
c6d3cb
+		 * wait_for_all_status would be ignored by are_we_quorate anyway.
c6d3cb
+		 */
c6d3cb
+		update_wait_for_all_status(0);
c6d3cb
 	}
c6d3cb
 
c6d3cb
 out:
c6d3cb
-- 
c6d3cb
1.8.3.1
c6d3cb