Răsfoiți Sursa

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>
(cherry picked from commit 0c16442f2d93f32a229b87d2672e2dc8025ec704)
Jan Friesse 6 ani în urmă
părinte
comite
068ac8e47e
1 a modificat fișierele cu 7 adăugiri și 3 ștergeri
  1. 7 3
      exec/votequorum.c

+ 7 - 3
exec/votequorum.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2015 Red Hat, Inc.
+ * Copyright (c) 2009-2020 Red Hat, Inc.
  *
  * All rights reserved.
  *
@@ -2683,8 +2683,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;
 	}