Explorar o código

votequorum: Make display of qdevice more intuitive.

corosync-quorumtool displays the votes of the qdevice whether
or not it is active. This is confusing because if it is not active
then the display looks like there is a vote being contributed to
quorum when there is not.

This patch displays 0 for qdevice votes if the device is present
(but inactive) and adds the votes after the name. If the device is
contributing votes then they are displayed as normal.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Christine Caulfield %!s(int64=10) %!d(string=hai) anos
pai
achega
fc9817fec4
Modificáronse 2 ficheiros con 19 adicións e 4 borrados
  1. 2 2
      test/testvotequorum2.c
  2. 17 2
      tools/corosync-quorumtool.c

+ 2 - 2
test/testvotequorum2.c

@@ -100,7 +100,7 @@ static void usage(const char *command)
         printf("      -p <num>  Number of times to poll qdevice (default 0=infinte)\n");
         printf("      -p <num>  Number of times to poll qdevice (default 0=infinte)\n");
         printf("      -t <secs> Time (in seconds) to wait between polls (default=1)\n");
         printf("      -t <secs> Time (in seconds) to wait between polls (default=1)\n");
         printf("      -n <name> Name of quorum device (default QDEVICE)\n");
         printf("      -n <name> Name of quorum device (default QDEVICE)\n");
-        printf("      -c        Cast vote (default yes)\n");
+        printf("      -c        Don't cast vote (default is to cast vote)\n");
         printf("      -q        Don't print device status every poll time (default=will print)\n");
         printf("      -q        Don't print device status every poll time (default=will print)\n");
         printf("      -m        Master wins (default no)\n");
         printf("      -m        Master wins (default no)\n");
         printf("      -1        Print status once and exit\n");
         printf("      -1        Print status once and exit\n");
@@ -127,7 +127,7 @@ int main(int argc, char *argv[])
 		        master_wins = 1;
 		        master_wins = 1;
 			break;
 			break;
 		case 'c':
 		case 'c':
-		        cast_vote = 1;
+		        cast_vote = 0;
 			break;
 			break;
 		case '1':
 		case '1':
 		        once = 1;
 		        once = 1;

+ 17 - 2
tools/corosync-quorumtool.c

@@ -416,6 +416,7 @@ static int compare_nodenames(const void *one, const void *two)
 static void display_nodes_data(nodeid_format_t nodeid_format, name_format_t name_format, sorttype_t sort_type)
 static void display_nodes_data(nodeid_format_t nodeid_format, name_format_t name_format, sorttype_t sort_type)
 {
 {
 	int i, display_qdevice = 0;
 	int i, display_qdevice = 0;
+	unsigned int our_flags = 0;
 	struct votequorum_info info[g_view_list_entries];
 	struct votequorum_info info[g_view_list_entries];
 	/*
 	/*
 	 * cache node info because we need to parse them twice
 	 * cache node info because we need to parse them twice
@@ -488,6 +489,7 @@ static void display_nodes_data(nodeid_format_t nodeid_format, name_format_t name
 		printf("%s", g_view_list[i].name);
 		printf("%s", g_view_list[i].name);
 		if (g_view_list[i].node_id == our_nodeid) {
 		if (g_view_list[i].node_id == our_nodeid) {
 			printf(" (local)");
 			printf(" (local)");
+			our_flags = info[i].flags;
 		}
 		}
 		printf("\n");
 		printf("\n");
 	}
 	}
@@ -506,8 +508,21 @@ static void display_nodes_data(nodeid_format_t nodeid_format, name_format_t name
 		} else {
 		} else {
 			printf("0x%08x ", VOTEQUORUM_QDEVICE_NODEID);
 			printf("0x%08x ", VOTEQUORUM_QDEVICE_NODEID);
 		}
 		}
-		print_uint32_padded(info[0].qdevice_votes);
-		printf("           %s\n", info[0].qdevice_name);
+		/* If the quorum device is inactive on this node then show votes as 0
+		   so that the display is not confusing */
+		if (our_flags & VOTEQUORUM_INFO_QDEVICE_CAST_VOTE) {
+			print_uint32_padded(info[0].qdevice_votes);
+		}
+		else {
+			print_uint32_padded(0);
+		}
+		printf("           %s", info[0].qdevice_name);
+		if (our_flags & VOTEQUORUM_INFO_QDEVICE_CAST_VOTE) {
+			printf("\n");
+		}
+		else {
+			printf(" (votes %d)\n", info[0].qdevice_votes);
+		}
 	}
 	}
 
 
 }
 }