summaryrefslogtreecommitdiff
path: root/ctdb/tools/onnode
AgeCommit message (Collapse)AuthorFilesLines
2023-07-05ctdb-tools: Avoid ShellCheck warning SC2317Martin Schwenke1-0/+2
New in ShellCheck 0.9.0: SC2317 (info): Command appears to be unreachable. Check usage (or ignore if invoked indirectly). Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Andreas Schneider <asn@samba.org>
2022-07-22ctdb-scripts: Avoid ShellCheck warning SC2295Martin Schwenke1-2/+2
For example: In /home/martins/samba/samba/ctdb/tools/onnode line 304: [ "$nodes" != "${nodes%[ ${nl}]*}" ] && verbose=true ^---^ SC2295 (info): Expansions inside ${..} need to be quoted separately, otherwise they match as patterns. Did you mean: [ "$nodes" != "${nodes%[ "${nl}"]*}" ] && verbose=true For more information: https://www.shellcheck.net/wiki/SC2295 -- Expansions inside ${..} need to b... Who knew? Thanks ShellCheck! Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2020-07-16ctdb-tools: Improve onnode's ShellCheck credibilityMartin Schwenke1-2/+2
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> Autobuild-User(master): Amitay Isaacs <amitay@samba.org> Autobuild-Date(master): Thu Jul 16 06:51:47 UTC 2020 on sn-devel-184
2020-07-16ctdb-tools: Allow onnode -P to respect ONNODE_SSHMartin Schwenke1-0/+3
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2020-07-16ctdb-tools: Whitespace fixupsMartin Schwenke1-14/+14
Drop some unnecessary whitespace and re-indent push(). Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2020-07-16ctdb-tools: Drop undocumented ONNODE_SSH_OPTS variableMartin Schwenke1-2/+1
Options can be set in ONNODE_SSH, so this variable is unnecessary. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-09-17ctdb-scripts: Silence shellcheck warning SC2166Martin Schwenke1-2/+2
This covers the following: SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. SC2166: Prefer [ p ] || [ q ] as [ p -o q ] is not well defined. POSIX agrees that -a and -o should not be used: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html Fixing these doesn't cause much churn. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-08-14ctdb-tools: Drop 'o' option from getopts commandMartin Schwenke1-1/+1
Commit 90de5e0594b9180226b9a13293afe31f18576b3d remove the processing for this option but forgot to remove it from the getopts command. Versions of ShellCheck >= 0.4.7 warn on this, so it is worth fixing. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14086 RN: Fix onnode test failure with ShellCheck >= 0.4.7 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-07-05ctdb-tools: Drop separate parallel+verbose stdout/stderr filteringMartin Schwenke1-31/+5
This has been broken for 10 years since commit 9616959bd6938e4c5c3713fe986c1e17cbdc574c, which introduced the separate filtering. This commit was missing a redirect of the output of stderr_filter() to stderr. Since nobody depends on the separate filtering (i.e. nobody reported a bug), just return to combining stdout and stderr, and filtering them together. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-07-05ctdb-tools: Drop no-op stdout-filter from non-parallel caseMartin Schwenke1-1/+1
This filter no longer does anything useful in this context. By default it adds a pipeline with trailing cat process. In many contexts, stdout of the process being run is still open so the cat process will stay around and will stop onnode from exiting. The filters should all go away because they are simply an example of code that is trying to be too clever while causing unfortunate corner cases. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-07-05ctdb-tools: Drop onnode -o optionMartin Schwenke1-6/+1
I don't think anyone uses this and it causes complications. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-11-06ctdb-tools: Detect unknown node numberMartin Schwenke1-2/+6
If there aren't enough addresses in the list then the shift will silently fail and the printed address will be the unshifted value of $1, which is incorrect/unexpected. So, sanity check the node number. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-10-08ctdb-tools: Have onnode pass -n option even when regular ssh not in useMartin Schwenke1-6/+3
ONNODE_SSH is really a test hook, so it doesn't need to support completely random values. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-07-28ctdb-tools: Avoid use of non-portable getopt in onnodeMartin Schwenke1-31/+22
getopt is being used with non-portable options. Use simpler, POSIX-compliant getopts instead. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-07-28ctdb-tools: Improve portability by not using /bin/bash directlyMartin Schwenke1-1/+1
FreeBSD and others do not have /bin/bash, so use "/usr/bin/env bash" for better flexibility. There are still many integration tests that use /bin/bash but this at least lets FreeBSD start running tests. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-05-12ctdb-scripts: Don't load CTDB configuration in onnodeMartin Schwenke1-4/+0
onnode does not use any configuration options. Drop sourcing of functions file since the only function used was loadconfig(). Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-04-27ctdb-tools: Avoid filtering stderr when onnode not running in parallelMartin Schwenke1-6/+1
stderr_filter() only does anything useful when running in parallel (i.e. with the -p option). So, simplify the non-parallel case by not using stderr_filter(). As a side-effect, this fixes an issue introduced in commit 85a4375788d8ef8345ec390807f18299abdadb20 where local daemon tests would hang when trying to start daemons with VALGRIND set (to a valgrind command that does not use --log-file). This is because valgrind would keep stderr open for its output so the pipeline involving stderr_filter() would never complete. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-28ctdb-scripts: Split CTDB configuration loadingMartin Schwenke1-1/+2
loadconfig() currently tries to load the CTDB configuration and also any system configuration relevant to the current (event) script. Instead add a new function load_system_config() to load the distribution-specific system configuration for a component. Call this directly in the rare scripts that need the system configuration. Also call load_system_config when loading the CTDB configuration to pull in anything from the CTDB system configuration. This is partly for backward compatibility but also to get options that can be used anywhere. loadconfig() no longer takes an argument. It simply loads the CTDB configuration. Drop support for falling back to /etc/ctdb/sysconfig/ctdb (or similar). Surely there's nobody who uses that! Also, drop the indirection where loadconfig() calls _loadconfig(). This was used years ago as a test hook and is no longer required. Inexplicably, this change introduces a new shellcheck test failure, so silence this. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-19ctdb-scripts: Drop CTDB_NODES configuration optionMartin Schwenke1-2/+0
Tests now deviate from the compile-time default by setting CTDB_BASE. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-19ctdb-tools: Drop onnode CTDB_NODES_FILE environment variableMartin Schwenke1-4/+5
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-01ctdb-tools: Reindent parts of onnodeMartin Schwenke1-75/+75
No functional changes. Best viewed with diff/show -w to avoid whitespace differences. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-01ctdb-tools: Remove test hooks from onnodeMartin Schwenke1-14/+0
CTDB_NODES_SOCKETS is no longer used. The test code uses ONNODE_SSH to run a fake ssh client. Leave indenting sloppy and fix it in the next commit so that this change is clear. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-01ctdb-tools: Revisit stray file descriptor avoidance in onnodeMartin Schwenke1-3/+3
Commit 635da189dccef6516d490c228407b9987986c578 fixed a problem where a stray file descriptor leaked into a subshell. Explicitly close the file descriptor at the outermost possible point rather than relying on fakessh() to do it. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-01ctdb-tools: Introduce a variable to hold the ssh commandMartin Schwenke1-2/+3
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-01ctdb-tools: Change onnode to use ONNODE_SSH and ONNODE_SSH_OPTSMartin Schwenke1-8/+8
Instead of more generic SSH and EXTRA_SSH_OPTS. Quietly drop reference to rsh in case it gives anyone ideas. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2017-08-14ctdb-scripts: Ignore shellcheck SC2181 warning (use of $?)Martin Schwenke1-1/+5
Given the size of the command substitutions it would be less clear to embed the assignments and substitutions inside a conditional. It is clearer if the exit code is checked afterwards. However, do fix some untidy uses of != instead of -ne when comparing with $?. Make the code easier to understand by reversing the logic and using -eq and ||. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2017-08-14ctdb-tools: Avoid shellcheck SC2181 warnings (use of $?) in onnodeMartin Schwenke1-10/+6
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2017-08-14ctdb-tools: Use a clear and readable if-statementMartin Schwenke1-2/+2
This is consistent with the if-statement above. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2017-08-14ctdb-tools: Reformat and explain complex codeMartin Schwenke1-2/+21
There are multiple command groups and redirects on very long lines. Reformat the long lines to break them up and add a comment to explain what is happening. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-25ctdb-tools: Simplify "ctdb pnn" output formatMartin Schwenke1-3/+3
Just print the PNN. Update dependent code. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21ctdb-scripts: Avoid shellcheck warning SC2124 (string=array)Martin Schwenke1-1/+1
SC2124: Assigning an array to a string! Assign as array, or use * instead of @ to concatenate. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21ctdb-scripts: Avoid shellcheck warning SC2155 (declare, assign)Martin Schwenke1-2/+2
SC2155: Declare and assign separately to avoid masking return values. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21ctdb-scripts: Avoid shellcheck warnings SC2046, SC2086 (double-quoting)Martin Schwenke1-11/+21
SC2046: Quote this to prevent word splitting. SC2086: Double quote to prevent globbing and word splitting. Add some quoting where it makes sense. Use shellcheck directives for false-positives. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21ctdb-scripts: Avoid shellcheck warning SC2034 (unused variables)Martin Schwenke1-1/+1
SC2034: VAR appears unused. Verify it or export it. Drop some variables that are unnecessarily used. Use shellcheck directive for false-positives. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-04-25ctdb-tools: Drop onnode node specifications for recmaster/lvs/natgwMartin Schwenke1-60/+1
LVS and NAT gateway support had bit-rotted. We don't use any of these in scripts/tests and we very much doubt anyone else uses them. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> Autobuild-User(master): Amitay Isaacs <amitay@samba.org> Autobuild-Date(master): Mon Apr 25 10:34:47 CEST 2016 on sn-devel-144
2015-09-15ctdb-scripts: Update important installed files to use build-time defaultsMartin Schwenke1-5/+12
In this case: ctdbd_wrapper, onnode, ctdb_diagnostics, ctdb.sudoers. Set sensible defaults from configure options. Update documentation to match, trying to fix up anything that has been missed before. The onnode unit tests need a symlink to the functions file. The simple integration tests need to set CTDB_BASE and also need symlinks to functions/nodes. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Jose A. Rivera <jarrpa@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> fixup Signed-off-by: Martin Schwenke <martin@meltin.net>
2014-12-05ctdb-tools: Bracket IP addresses in onnode (for IPv6)Martin Schwenke1-2/+2
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-12-05ctdb-tools: Update onnode and ctdb-diagnostics to use ctdb -XMartin Schwenke1-3/+3
Also update onnode unit tests. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2013-11-27ctdb-onnode: New -i option to stop stdin from being closedMartin Schwenke1-5/+10
This can be useful for piping data to onnode in certain circumstances. There are now also enough command-line options that they should definitely be alphabetically ordered. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Michael Adam <obnox@samba.org>
2013-10-29tools/onnode: Fix healthy/ok node handlingMartin Schwenke1-2/+2
This bit-rotted a long time ago when the "ThisNode" column was added to "ctdb -Y status" output. The fake "ctdb -Y status" output in the test was never updated to reflect this change. Instead of making sure that all columns are "0", just check that they're not "1". This implicitly ignores "Y" and "N" in this "ThisNode" column without having to do anything else clever. Also update associated tests. The main "ctdb ok" test had a duplicate opening line for a here document, which was tickled by this change. This fixes samba bz#8122. Signed-off-by: Martin Schwenke <martin@meltin.net> onnode test fixup Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 01a46205c3a3d6609dc0b0324319b89667dffa32)
2012-07-30tools/onnode: Add -P option to push files to given nodesMartin Schwenke1-13/+36
A list of files is given rather than a command. These files are pushed to the specified nodes. Quoting is fragile/broken so filenames with spaces won't work - you win some, you lose some. :-) All of the other onnode options should work together with this option. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit aed9b98ddbbf3e81de4f7257a10676565f7d7507)
2011-10-18onnode: unset EXTRA_SSH_OPTS when using fakesshMartin Schwenke1-0/+1
This case was never tested and fakessh obviously won't handle the extra arguments. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 02184bd5b9ab94cdf2b9ff92e56a509f92f9e4aa)
2011-06-08onnode: fix natgwlist nodespecMartin Schwenke1-5/+21
This hasn't worked for a while if ever. We treat this case specially because the output has 2 works on the 1st line. We also handle the error case where /etc/ctdb_natgw_nodes exists but none of the other $NATGW_* configuration is done. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 66e89797c7866d207a5bbf1836f52d70dba7cea6)
2011-06-08onnode: fix get_nodes_with_status()Martin Schwenke1-8/+11
Setting IFS and looping though items with colons in them doesn't work. Change this to read through the output line by line. The header line needs to be thrown away by throwing away everything up to the 1st newline. Keep stderr from the "ctdb status" command, otherwise debugging is impossible. On error, append any output from ctdb to onnode's error message. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit d60592cf99999f10344a05ef0571fb300bb9d97c)
2011-06-08onnode: Remove an unnecessary comment.Martin Schwenke1-1/+0
The comment about $CTDB_NODES_SOCKETS is meaningless. The code ti refers to works just find with $CTDB_NODES_SOCKETS. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 74e69a564bac653dadfffe8b08145b9b3be16e61)
2011-06-08onnode: Future-proof get_nodes_with_status().Martin Schwenke1-28/+29
The current code requires knowledge of the number of status bits output by "ctdb status -Y". This changes the code to be completely general. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit e1788f25fde3d1f26bf4831a331741aa280f6fbc)
2011-06-08onnode: Exit with error for unknown command-line flags.Martin Schwenke1-1/+3
Use of "local" was masking errors in command-line processing. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit ca80adda7517b43147ef30156ae34c66b29fa2bd)
2011-06-08onnode: Be defensive when listing IPs of nodes with designated status.Martin Schwenke1-1/+1
The current version gives the last item left after stripping the known fields. If an insufficent number of status fields is stripped then this would return a residual status field value, which turned out to be a valid IP address for localhost... so no error occurs. This change means that the node number is stripped and any residual status field value will stay appended, causing an error the first time this command is tested. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 74715e6ec7b67c6f0e863aa51c87279758d6bf91)
2011-06-08onnode - Fix long standing bug in onnode healthy/ok/connected/con.Martin Schwenke1-2/+2
When the output of "ctdb status -Y" changed to add an extra status column we didn't fix onnode. This adds a match for the extra column. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 793febaebd3d484ddfbbcb47aaa0cdf3cfc1a00d)
2010-01-21onnode: update algorithm for finding nodes file.Martin Schwenke1-2/+15
2 changes: * If a relative nodes file is specified via -f or $CTDB_NODES_FILE but this file does not exist then try looking for the file in /etc/ctdb (or $CTDB_BASE if set). * If a nodes file is specified via -f or $CTDB_NODES_FILE but this file does not exist (even when checked as per above) then do not fall back to /etc/ctdb/nodes ((or $CTDB_BASE if set). The old behaviour was surprising and hid errors. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 6b5a5bb62369284585057caf09f05d2d5e3b9927)