The Samba-Bugzilla – Attachment 13232 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]
Draft fix and tests for master
BZ12802.patch (text/plain), 7.64 KB, created by
Martin Schwenke
on 2017-05-24 10:35:02 UTC
(
hide
)
Description:
Draft fix and tests for master
Filename:
MIME Type:
Creator:
Martin Schwenke
Created:
2017-05-24 10:35:02 UTC
Size:
7.64 KB
patch
obsolete
>From 8fc36696f7e3c8e1b0663bac1b3980bf7df22edd 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> >--- > ctdb/tools/ctdb.c | 5 ----- > 1 file changed, 5 deletions(-) > >diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c >index ae74ef818cb..14b6957e1f0 100644 >--- a/ctdb/tools/ctdb.c >+++ b/ctdb/tools/ctdb.c >@@ -5664,11 +5664,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.11.0 > > >From fb7aad28f84d8985e220e7d4ce293c76eab117de 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> >--- > ctdb/tools/ctdb.c | 21 +++++++++++++-------- > 1 file changed, 13 insertions(+), 8 deletions(-) > >diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c >index 14b6957e1f0..e0a3e0ccc97 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"); >@@ -5667,7 +5671,8 @@ 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); >+ bool print_hdr = (argc == 1 && strcmp(argv[0], "all") == 0); >+ print_nodemap(mem_ctx, ctdb, nodemap, ctdb->cmd_pnn, print_hdr); > } > > ret = 0; >-- >2.11.0 > > >From 6909f76813e5c8060823d707387bfd417f2ea96d 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> >--- > 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 | 28 ++++++++++++++++++++++++++++ > 4 files changed, 117 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 00000000000..5912e6501aa >--- /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 00000000000..01ccd5129b4 >--- /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 00000000000..0cd24ba9cab >--- /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 00000000000..ee9350e92fd >--- /dev/null >+++ b/ctdb/tests/tool/ctdb.nodestatus.006.sh >@@ -0,0 +1,28 @@ >+#!/bin/sh >+ >+. "${TEST_SCRIPTS_DIR}/unit.sh" >+ >+define_test "current, 3 nodes, node 0 disabled+stopped, query node 0" >+ >+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 >-- >2.11.0 >
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
Actions:
View
Attachments on
bug 12802
:
13232
|
13237