Bug 12802 - `ctdb nodestatus` incorrectly displays status for all nodes with wrong exit code
Summary: `ctdb nodestatus` incorrectly displays status for all nodes with wrong exit code
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: CTDB (show other bugs)
Version: 4.6.3
Hardware: x64 Linux
: P5 regression (vote)
Target Milestone: ---
Assignee: Karolin Seeger
QA Contact: Samba QA Contact
Depends on:
Reported: 2017-05-24 05:57 UTC by Anoop C S
Modified: 2017-06-02 07:57 UTC (History)
4 users (show)

See Also:

Draft fix and tests for master (7.64 KB, patch)
2017-05-24 10:35 UTC, Martin Schwenke
no flags Details
Patches for v4-5, v4-6 (8.75 KB, patch)
2017-05-26 03:39 UTC, Amitay Isaacs
martins: review+

Note You need to log in before you can comment on or make changes to this bug.
Description Anoop C S 2017-05-24 05:57:22 UTC
In a 2 node samba ctdb cluster, running `ctdb nodestatus` incorrectly displays the status for all nodes as follows:

# ctdb nodestatus
Number of nodes:2
pnn:0  OK (THIS NODE)
pnn:1  OK

# echo $?

As per man page for ctdb(1), by default intention of `ctdb nodestatus` command is to display the status of current node and exit with corresponding exit code.
. . .
ctdb nodestatus defaults to providing status for only the current node.
If PNN-LIST is provided then status is given for the indicated node(s).
. . .

Following that the exit code returned now also reflects the status of other nodes i.e, running `ctdb nodestatus` with a node in stopped state(using `ctdb stop`) results in the following output:

# ctdb nodestatus
Number of nodes:2
pnn:0  OK (THIS NODE)

# echo $?

Additional info:
I can confirm that with v4.4.6, everything was working fine as expected.
Comment 1 Martin Schwenke 2017-05-24 10:21:21 UTC
Will add fix and some tests
Comment 2 Martin Schwenke 2017-05-24 10:24:39 UTC
Doesn't match documentation
Comment 3 Martin Schwenke 2017-05-24 10:35:02 UTC
Created attachment 13232 [details]
Draft fix and tests for master
Comment 4 Martin Schwenke 2017-05-24 10:37:17 UTC
Attached patch contains:

8fc36696f7e ctdb-tools: Stop "ctdb nodestatus" from always showing all nodes
fb7aad28f84 ctdb-tools: "ctdb nodestatus" should only display header for "all"
6909f76813e ctdb-tests: Add some extra tests for "ctdb nodestatus"

If I apply only the test commit then the last 3 (of 4 new tests) fail:

 PASSED  ./ctdb/tests/tool/ctdb.nodestatus.001.sh
 PASSED  ./ctdb/tests/tool/ctdb.nodestatus.002.sh
 PASSED  ./ctdb/tests/tool/ctdb.nodestatus.003.sh
*FAILED* ./ctdb/tests/tool/ctdb.nodestatus.004.sh
*FAILED* ./ctdb/tests/tool/ctdb.nodestatus.005.sh
*FAILED* ./ctdb/tests/tool/ctdb.nodestatus.006.sh

3/6 tests passed

With the fixes applied:

 PASSED  ./ctdb/tests/tool/ctdb.nodestatus.001.sh
 PASSED  ./ctdb/tests/tool/ctdb.nodestatus.002.sh
 PASSED  ./ctdb/tests/tool/ctdb.nodestatus.003.sh
 PASSED  ./ctdb/tests/tool/ctdb.nodestatus.004.sh
 PASSED  ./ctdb/tests/tool/ctdb.nodestatus.005.sh
 PASSED  ./ctdb/tests/tool/ctdb.nodestatus.006.sh

6/6 tests passed
Comment 5 Martin Schwenke 2017-05-24 10:38:34 UTC
Attached patch is for master but applies cleanly to v4-5-test.
Comment 6 Amitay Isaacs 2017-05-26 03:39:08 UTC
Created attachment 13237 [details]
Patches for v4-5, v4-6
Comment 7 Martin Schwenke 2017-05-26 04:23:05 UTC
Hi Karolin,

This is ready for 4.5 and 4.6.

Comment 8 Karolin Seeger 2017-05-30 10:17:13 UTC
(In reply to Martin Schwenke from comment #7)
Pushed to autobuild-v4-{6,5}-test.
Comment 9 Karolin Seeger 2017-06-02 07:57:09 UTC
(In reply to Karolin Seeger from comment #8)
Pushed to both branches.
Closing out bug report.