The Samba-Bugzilla – Attachment 13237 Details for
Bug 12802
`ctdb nodestatus` incorrectly displays status for all nodes with wrong exit code
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patches for v4-5, v4-6
BZ12802.patch (text/plain), 8.75 KB, created by
Amitay Isaacs
on 2017-05-26 03:39:08 UTC
(
hide
)
Description:
Patches for v4-5, v4-6
Filename:
MIME Type:
Creator:
Amitay Isaacs
Created:
2017-05-26 03:39:08 UTC
Size:
8.75 KB
patch
obsolete
>From b20056aad7976a7f1cf8e52fe2f82b1354525f4a Mon Sep 17 00:00:00 2001 >From: Martin Schwenke <martin@meltin.net> >Date: Wed, 24 May 2017 20:24:54 +1000 >Subject: [PATCH 1/3] 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@meltin.net> >Reviewed-by: Amitay Isaacs <amitay@gmail.com> >(cherry picked from commit a600d467e2842ab05e429c5a67be5b222ddd1c12) >--- > ctdb/tools/ctdb.c | 5 ----- > 1 file changed, 5 deletions(-) > >diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c >index 050906c..57974fd 100644 >--- a/ctdb/tools/ctdb.c >+++ b/ctdb/tools/ctdb.c >@@ -5663,11 +5663,6 @@ static int control_nodestatus(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb, > 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 { >-- >2.9.4 > > >From 8d3ea3da882b0ffb558aa1d23f147b5a3fea229b Mon Sep 17 00:00:00 2001 >From: Martin Schwenke <martin@meltin.net> >Date: Wed, 24 May 2017 20:27:58 +1000 >Subject: [PATCH 2/3] 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@meltin.net> >Reviewed-by: Amitay Isaacs <amitay@gmail.com> >(cherry picked from commit 1d10c8e9e637619b754b4a273d3c714fbca7d503) >--- > ctdb/tools/ctdb.c | 24 ++++++++++++++++-------- > 1 file changed, 16 insertions(+), 8 deletions(-) > >diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c >index 57974fd..93e4802 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"); >@@ -5650,6 +5654,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"); >@@ -5657,6 +5662,9 @@ 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)) { >@@ -5666,7 +5674,7 @@ static int control_nodestatus(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb, > 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; >-- >2.9.4 > > >From 347d79aad7db7cb8d6043b7a0112e3013111f188 Mon Sep 17 00:00:00 2001 >From: Martin Schwenke <martin@meltin.net> >Date: Wed, 24 May 2017 20:21:55 +1000 >Subject: [PATCH 3/3] 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@meltin.net> >Reviewed-by: Amitay Isaacs <amitay@gmail.com> > >Autobuild-User(master): Martin Schwenke <martins@samba.org> >Autobuild-Date(master): Fri May 26 05:24:34 CEST 2017 on sn-devel-144 > >(cherry picked from commit ade535371b86294c12ca3f7eb98d8ef7ecd29caa) >--- > ctdb/tests/tool/ctdb.nodestatus.003.sh | 33 ++++++++++++++++++++++++++++ > ctdb/tests/tool/ctdb.nodestatus.004.sh | 28 ++++++++++++++++++++++++ > ctdb/tests/tool/ctdb.nodestatus.005.sh | 28 ++++++++++++++++++++++++ > ctdb/tests/tool/ctdb.nodestatus.006.sh | 40 ++++++++++++++++++++++++++++++++++ > 4 files changed, 129 insertions(+) > create mode 100755 ctdb/tests/tool/ctdb.nodestatus.003.sh > create mode 100755 ctdb/tests/tool/ctdb.nodestatus.004.sh > create mode 100755 ctdb/tests/tool/ctdb.nodestatus.005.sh > create mode 100755 ctdb/tests/tool/ctdb.nodestatus.006.sh > >diff --git a/ctdb/tests/tool/ctdb.nodestatus.003.sh b/ctdb/tests/tool/ctdb.nodestatus.003.sh >new file mode 100755 >index 0000000..5912e65 >--- /dev/null >+++ b/ctdb/tests/tool/ctdb.nodestatus.003.sh >@@ -0,0 +1,33 @@ >+#!/bin/sh >+ >+. "${TEST_SCRIPTS_DIR}/unit.sh" >+ >+define_test "all, 3 nodes, 1 unhealthy" >+ >+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 >+Number of nodes:3 >+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 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| >+|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 >diff --git a/ctdb/tests/tool/ctdb.nodestatus.004.sh b/ctdb/tests/tool/ctdb.nodestatus.004.sh >new file mode 100755 >index 0000000..01ccd51 >--- /dev/null >+++ b/ctdb/tests/tool/ctdb.nodestatus.004.sh >@@ -0,0 +1,28 @@ >+#!/bin/sh >+ >+. "${TEST_SCRIPTS_DIR}/unit.sh" >+ >+define_test "current, 3 nodes, node 0 unhealthy" >+ >+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 0 <<EOF >+pnn:2 192.168.20.43 OK (THIS NODE) >+EOF >+simple_test >+ >+required_result 0 <<EOF >+|Node|IP|Disconnected|Banned|Disabled|Unhealthy|Stopped|Inactive|PartiallyOnline|ThisNode| >+|2|192.168.20.43|0|0|0|0|0|0|0|Y| >+EOF >+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 >-- >2.9.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
martins
:
review+
Actions:
View
Attachments on
bug 12802
:
13232
| 13237