Blob Blame History Raw
From 0c16442f2d93f32a229b87d2672e2dc8025ec704 Mon Sep 17 00:00:00 2001
From: Jan Friesse <jfriesse@redhat.com>
Date: Wed, 4 Mar 2020 11:42:15 +0100
Subject: [PATCH] votequorum: Change check of expected_votes

Previously value of new expected_votes was checked so newly computed
quorum value was in the interval <total_votes / 2, total_votes>. The
upper range prevented the cluster to become unquorate, but bottom check
was almost useless because it allowed to change expected_votes so it is
smaller than total_votes.

Solution is to check if expected_votes is bigger or equal to total_votes
and for quorate cluster only check if cluster doesn't become unquorate
(for unquorate cluster one can set upper range freely - as it is
perfectly possible when using config file)

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
---
 exec/votequorum.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/exec/votequorum.c b/exec/votequorum.c
index 52424fa..b152425 100644
--- a/exec/votequorum.c
+++ b/exec/votequorum.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2015 Red Hat, Inc.
+ * Copyright (c) 2009-2020 Red Hat, Inc.
  *
  * All rights reserved.
  *
@@ -2688,8 +2688,12 @@ static void message_handler_req_lib_votequorum_setexpected (void *conn, const vo
 	 */
 	newquorum = calculate_quorum(1, req_lib_votequorum_setexpected->expected_votes, &total_votes);
 	allow_downscale = allow_downscale_status;
-	if (newquorum < total_votes / 2 ||
-	    newquorum > total_votes) {
+	/*
+	 * Setting expected_votes < total_votes doesn't make sense.
+	 * For quorate cluster prevent cluster to become unquorate.
+	 */
+	if (req_lib_votequorum_setexpected->expected_votes < total_votes ||
+	    (cluster_is_quorate && (newquorum > total_votes))) {
 		error = CS_ERR_INVALID_PARAM;
 		goto error_exit;
 	}
-- 
1.8.3.1