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

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