[SCM] Samba Shared Repository - branch master updated

Martin Schwenke martins at samba.org
Fri May 26 03:25:02 UTC 2017


The branch, master has been updated
       via  ade5353 ctdb-tests: Add some extra tests for "ctdb nodestatus"
       via  1d10c8e ctdb-tools: "ctdb nodestatus" should only display header for "all"
       via  a600d46 ctdb-tools: Stop "ctdb nodestatus" from always showing all nodes
      from  fa6753d libnet join: Fix error handling on provision_store_self_join failure

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit ade535371b86294c12ca3f7eb98d8ef7ecd29caa
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed May 24 20:21:55 2017 +1000

    ctdb-tests: Add some extra tests for "ctdb nodestatus"
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12802
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    Autobuild-User(master): Martin Schwenke <martins at samba.org>
    Autobuild-Date(master): Fri May 26 05:24:34 CEST 2017 on sn-devel-144

commit 1d10c8e9e637619b754b4a273d3c714fbca7d503
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed May 24 20:27:58 2017 +1000

    ctdb-tools: "ctdb nodestatus" should only display header for "all"
    
    The "Number of nodes:" header should only be displayed when "all" is
    specified.  This is how the command behaved in Samba <= 4.4.
    
    Printing the number of nodes is not helpful and is rather confusing in
    the default case where only the status of the current node is printed.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12802
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit a600d467e2842ab05e429c5a67be5b222ddd1c12
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed May 24 20:24:54 2017 +1000

    ctdb-tools: Stop "ctdb nodestatus" from always showing all nodes
    
    Exit code should only reflect current or specified nodes too.
    
    Drop an unwanted call to get_nodemap() that overwrites the previously
    calculated node map.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12802
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

-----------------------------------------------------------------------

Summary of changes:
 ...db.nodestatus.001.sh => ctdb.nodestatus.003.sh} | 12 +++----
 ...db.nodestatus.001.sh => ctdb.nodestatus.004.sh} | 13 +++----
 ctdb/tests/tool/ctdb.nodestatus.005.sh             | 28 +++++++++++++++
 ctdb/tests/tool/ctdb.nodestatus.006.sh             | 40 ++++++++++++++++++++++
 ctdb/tools/ctdb.c                                  | 29 +++++++++-------
 5 files changed, 94 insertions(+), 28 deletions(-)
 copy ctdb/tests/tool/{ctdb.nodestatus.001.sh => ctdb.nodestatus.003.sh} (73%)
 copy ctdb/tests/tool/{ctdb.nodestatus.001.sh => ctdb.nodestatus.004.sh} (64%)
 create mode 100755 ctdb/tests/tool/ctdb.nodestatus.005.sh
 create mode 100755 ctdb/tests/tool/ctdb.nodestatus.006.sh


Changeset truncated at 500 lines:

diff --git a/ctdb/tests/tool/ctdb.nodestatus.001.sh b/ctdb/tests/tool/ctdb.nodestatus.003.sh
similarity index 73%
copy from ctdb/tests/tool/ctdb.nodestatus.001.sh
copy to ctdb/tests/tool/ctdb.nodestatus.003.sh
index 2217afc..5912e65 100755
--- a/ctdb/tests/tool/ctdb.nodestatus.001.sh
+++ b/ctdb/tests/tool/ctdb.nodestatus.003.sh
@@ -2,11 +2,11 @@
 
 . "${TEST_SCRIPTS_DIR}/unit.sh"
 
-define_test "all, 3 nodes, all OK"
+define_test "all, 3 nodes, 1 unhealthy"
 
 setup_ctdbd <<EOF
 NODEMAP
-0       192.168.20.41   0x0
+0       192.168.20.41   0x2
 1       192.168.20.42   0x0
 2       192.168.20.43   0x0     CURRENT RECMASTER
 
@@ -16,17 +16,17 @@ IFACES
 :eth1:1:4:
 EOF
 
-required_result 0 <<EOF
+required_result 2 <<EOF
 Number of nodes:3
-pnn:0 192.168.20.41    OK
+pnn:0 192.168.20.41    UNHEALTHY
 pnn:1 192.168.20.42    OK
 pnn:2 192.168.20.43    OK (THIS NODE)
 EOF
 simple_test all
 
-required_result 0 <<EOF
+required_result 2 <<EOF
 |Node|IP|Disconnected|Banned|Disabled|Unhealthy|Stopped|Inactive|PartiallyOnline|ThisNode|
-|0|192.168.20.41|0|0|0|0|0|0|0|N|
+|0|192.168.20.41|0|0|0|1|0|0|0|N|
 |1|192.168.20.42|0|0|0|0|0|0|0|N|
 |2|192.168.20.43|0|0|0|0|0|0|0|Y|
 EOF
diff --git a/ctdb/tests/tool/ctdb.nodestatus.001.sh b/ctdb/tests/tool/ctdb.nodestatus.004.sh
similarity index 64%
copy from ctdb/tests/tool/ctdb.nodestatus.001.sh
copy to ctdb/tests/tool/ctdb.nodestatus.004.sh
index 2217afc..01ccd51 100755
--- a/ctdb/tests/tool/ctdb.nodestatus.001.sh
+++ b/ctdb/tests/tool/ctdb.nodestatus.004.sh
@@ -2,11 +2,11 @@
 
 . "${TEST_SCRIPTS_DIR}/unit.sh"
 
-define_test "all, 3 nodes, all OK"
+define_test "current, 3 nodes, node 0 unhealthy"
 
 setup_ctdbd <<EOF
 NODEMAP
-0       192.168.20.41   0x0
+0       192.168.20.41   0x2
 1       192.168.20.42   0x0
 2       192.168.20.43   0x0     CURRENT RECMASTER
 
@@ -17,17 +17,12 @@ IFACES
 EOF
 
 required_result 0 <<EOF
-Number of nodes:3
-pnn:0 192.168.20.41    OK
-pnn:1 192.168.20.42    OK
 pnn:2 192.168.20.43    OK (THIS NODE)
 EOF
-simple_test all
+simple_test
 
 required_result 0 <<EOF
 |Node|IP|Disconnected|Banned|Disabled|Unhealthy|Stopped|Inactive|PartiallyOnline|ThisNode|
-|0|192.168.20.41|0|0|0|0|0|0|0|N|
-|1|192.168.20.42|0|0|0|0|0|0|0|N|
 |2|192.168.20.43|0|0|0|0|0|0|0|Y|
 EOF
-simple_test -X all
+simple_test -X
diff --git a/ctdb/tests/tool/ctdb.nodestatus.005.sh b/ctdb/tests/tool/ctdb.nodestatus.005.sh
new file mode 100755
index 0000000..0cd24ba
--- /dev/null
+++ b/ctdb/tests/tool/ctdb.nodestatus.005.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "current, 3 nodes, node 0 unhealthy, query node 0"
+
+setup_ctdbd <<EOF
+NODEMAP
+0       192.168.20.41   0x2
+1       192.168.20.42   0x0
+2       192.168.20.43   0x0     CURRENT RECMASTER
+
+IFACES
+:Name:LinkStatus:References:
+:eth2:1:2:
+:eth1:1:4:
+EOF
+
+required_result 2 <<EOF
+pnn:0 192.168.20.41    UNHEALTHY
+EOF
+simple_test 0
+
+required_result 2 <<EOF
+|Node|IP|Disconnected|Banned|Disabled|Unhealthy|Stopped|Inactive|PartiallyOnline|ThisNode|
+|0|192.168.20.41|0|0|0|1|0|0|0|N|
+EOF
+simple_test -X 0
diff --git a/ctdb/tests/tool/ctdb.nodestatus.006.sh b/ctdb/tests/tool/ctdb.nodestatus.006.sh
new file mode 100755
index 0000000..ec189fc
--- /dev/null
+++ b/ctdb/tests/tool/ctdb.nodestatus.006.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "current, 3 nodes, node 0 disabled+stopped, various queries"
+
+setup_ctdbd <<EOF
+NODEMAP
+0       192.168.20.41   0x24
+1       192.168.20.42   0x0
+2       192.168.20.43   0x0     CURRENT RECMASTER
+
+IFACES
+:Name:LinkStatus:References:
+:eth2:1:2:
+:eth1:1:4:
+EOF
+
+required_result 36 <<EOF
+pnn:0 192.168.20.41    DISABLED|STOPPED|INACTIVE
+EOF
+simple_test 0
+
+required_result 36 <<EOF
+|Node|IP|Disconnected|Banned|Disabled|Unhealthy|Stopped|Inactive|PartiallyOnline|ThisNode|
+|0|192.168.20.41|0|0|1|0|1|1|0|N|
+EOF
+simple_test -X 0
+
+required_result 36 <<EOF
+pnn:0 192.168.20.41    DISABLED|STOPPED|INACTIVE
+pnn:1 192.168.20.42    OK
+EOF
+simple_test 0,1
+
+required_result 0 <<EOF
+pnn:1 192.168.20.42    OK
+pnn:2 192.168.20.43    OK (THIS NODE)
+EOF
+simple_test 1,2
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index ae74ef8..0890992 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -802,7 +802,8 @@ static void print_nodemap_machine(TALLOC_CTX *mem_ctx,
 }
 
 static void print_nodemap(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
-			  struct ctdb_node_map *nodemap, uint32_t mypnn)
+			  struct ctdb_node_map *nodemap, uint32_t mypnn,
+			  bool print_header)
 {
 	struct ctdb_node_and_flags *node;
 	int num_deleted_nodes = 0;
@@ -814,11 +815,14 @@ static void print_nodemap(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
 		}
 	}
 
-	if (num_deleted_nodes == 0) {
-		printf("Number of nodes:%d\n", nodemap->num);
-	} else {
-		printf("Number of nodes:%d (including %d deleted nodes)\n",
-		       nodemap->num, num_deleted_nodes);
+	if (print_header) {
+		if (num_deleted_nodes == 0) {
+			printf("Number of nodes:%d\n", nodemap->num);
+		} else {
+			printf("Number of nodes:%d "
+			       "(including %d deleted nodes)\n",
+			       nodemap->num, num_deleted_nodes);
+		}
 	}
 
 	for (i=0; i<nodemap->num; i++) {
@@ -844,7 +848,7 @@ static void print_status(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
 {
 	int i;
 
-	print_nodemap(mem_ctx, ctdb, nodemap, mypnn);
+	print_nodemap(mem_ctx, ctdb, nodemap, mypnn, true);
 
 	if (vnnmap->generation == INVALID_GENERATION) {
 		printf("Generation:INVALID\n");
@@ -5651,6 +5655,7 @@ static int control_nodestatus(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
 	const char *nodestring = NULL;
 	struct ctdb_node_map *nodemap;
 	int ret, i;
+	bool print_hdr = false;
 
 	if (argc > 1) {
 		usage("nodestatus");
@@ -5658,21 +5663,19 @@ static int control_nodestatus(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
 
 	if (argc == 1) {
 		nodestring = argv[0];
+		if (strcmp(nodestring, "all") == 0) {
+			print_hdr = true;
+		}
 	}
 
 	if (! parse_nodestring(mem_ctx, ctdb, nodestring, &nodemap)) {
 		return 1;
 	}
 
-	nodemap = get_nodemap(ctdb, false);
-	if (nodemap == NULL) {
-		return 1;
-	}
-
 	if (options.machinereadable) {
 		print_nodemap_machine(mem_ctx, ctdb, nodemap, ctdb->cmd_pnn);
 	} else {
-		print_nodemap(mem_ctx, ctdb, nodemap, ctdb->cmd_pnn);
+		print_nodemap(mem_ctx, ctdb, nodemap, ctdb->cmd_pnn, print_hdr);
 	}
 
 	ret = 0;


-- 
Samba Shared Repository



More information about the samba-cvs mailing list