1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00
Commit Graph

56 Commits

Author SHA1 Message Date
Martin Schwenke
d44fed601d ctdb-tools: Avoid filtering stderr when onnode not running in parallel
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
85a4375788 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-04-27 06:53:16 +02:00
Martin Schwenke
b499775527 ctdb-scripts: Split CTDB configuration loading
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-28 02:57:20 +02:00
Martin Schwenke
6cf861a544 ctdb-scripts: Drop CTDB_NODES configuration option
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-19 02:23:20 +01:00
Martin Schwenke
16a93d7691 ctdb-tools: Drop onnode CTDB_NODES_FILE environment variable
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-19 02:23:19 +01:00
Martin Schwenke
9a12d6af05 ctdb-tools: Reindent parts of onnode
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-01 19:39:15 +01:00
Martin Schwenke
8f9ac94190 ctdb-tools: Remove test hooks from onnode
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-01 19:39:15 +01:00
Martin Schwenke
254a18422c ctdb-tools: Revisit stray file descriptor avoidance in onnode
Commit 635da189dc 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-01 19:39:15 +01:00
Martin Schwenke
248c374137 ctdb-tools: Introduce a variable to hold the ssh command
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-01 19:39:15 +01:00
Martin Schwenke
9260ca217f ctdb-tools: Change onnode to use ONNODE_SSH and ONNODE_SSH_OPTS
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>
2018-03-01 19:39:15 +01:00
Martin Schwenke
b71becc150 ctdb-scripts: Ignore shellcheck SC2181 warning (use of $?)
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-14 05:15:25 +02:00
Martin Schwenke
2b0e266d07 ctdb-tools: Avoid shellcheck SC2181 warnings (use of $?) in onnode
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2017-08-14 05:15:25 +02:00
Martin Schwenke
aa12ea7793 ctdb-tools: Use a clear and readable if-statement
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-14 05:15:25 +02:00
Martin Schwenke
4dc41cd2b6 ctdb-tools: Reformat and explain complex code
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>
2017-08-14 05:15:25 +02:00
Martin Schwenke
c3c106e41f ctdb-tools: Simplify "ctdb pnn" output format
Just print the PNN.

Update dependent code.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-25 21:29:46 +02:00
Martin Schwenke
dfa2c1d5d2 ctdb-scripts: Avoid shellcheck warning SC2124 (string=array)
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-21 02:24:27 +02:00
Martin Schwenke
f19f44e0c3 ctdb-scripts: Avoid shellcheck warning SC2155 (declare, assign)
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-21 02:24:27 +02:00
Martin Schwenke
9255d645f3 ctdb-scripts: Avoid shellcheck warnings SC2046, SC2086 (double-quoting)
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-21 02:24:26 +02:00
Martin Schwenke
f6c25a455a ctdb-scripts: Avoid shellcheck warning SC2034 (unused variables)
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-07-21 02:24:26 +02:00
Martin Schwenke
0c373f2854 ctdb-tools: Drop onnode node specifications for recmaster/lvs/natgw
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
2016-04-25 10:34:47 +02:00
Martin Schwenke
b933b91a0b ctdb-scripts: Update important installed files to use build-time defaults
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>
2015-09-15 08:56:21 +02:00
Martin Schwenke
2d480792e7 ctdb-tools: Bracket IP addresses in onnode (for IPv6)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-12-05 21:02:40 +01:00
Martin Schwenke
55df9c86c1 ctdb-tools: Update onnode and ctdb-diagnostics to use ctdb -X
Also update onnode unit tests.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-12-05 21:02:40 +01:00
Martin Schwenke
297a4a640d ctdb-onnode: New -i option to stop stdin from being closed
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-11-27 18:46:16 +01:00
Martin Schwenke
e8de58abd7 tools/onnode: Fix healthy/ok node handling
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)
2013-10-29 17:14:55 +11:00
Martin Schwenke
f53b4f82f5 tools/onnode: Add -P option to push files to given nodes
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)
2012-07-30 15:34:41 +10:00
Martin Schwenke
2e3febe283 onnode: unset EXTRA_SSH_OPTS when using fakessh
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-10-18 11:51:06 +11:00
Martin Schwenke
5ddc10128a onnode: fix natgwlist nodespec
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-08 14:24:00 +10:00
Martin Schwenke
1ef399e48d onnode: fix get_nodes_with_status()
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-08 14:23:40 +10:00
Martin Schwenke
41436193dd onnode: Remove an unnecessary comment.
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-08 14:23:14 +10:00
Martin Schwenke
f730194f12 onnode: Future-proof get_nodes_with_status().
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-08 14:22:49 +10:00
Martin Schwenke
f3ea7bec68 onnode: Exit with error for unknown command-line flags.
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-08 14:22:16 +10:00
Martin Schwenke
350f3e5b09 onnode: Be defensive when listing IPs of nodes with designated status.
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-08 14:21:53 +10:00
Martin Schwenke
597083d37a onnode - Fix long standing bug in onnode healthy/ok/connected/con.
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)
2011-06-08 14:21:26 +10:00
Martin Schwenke
9660f9c887 onnode: update algorithm for finding nodes file.
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)
2010-01-21 13:40:03 +11:00
Martin Schwenke
14b3c37d9d onnode - respect $CTDB_BASE rather than hard-coding /etc/ctdb.
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit a9aa2e06774e8cd59a86d3343d3da2a2769561b5)
2010-01-21 13:16:18 +11:00
Martin Schwenke
787a6e44c6 New onnode options: -f to specify nodes file, -n to allow use of hostnames.
The -f option allows an alternate nodes file to be specified,
overriding the CTDB_NODES_FILE environment variable.

The -n option allows hostnames to be used instead of node numbers.
Using a range of hostnames is invalid, so hostnames can't contain
hyphens ('-') - sorry!  You can use this option without a nodes file
by specifying "-f /dev/null".

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 46474e5f21fd97dd765c616647ff46055a9970e7)
2009-10-14 13:44:57 +11:00
Ronnie Sahlberg
029fd6b00f Revert "try to restart statd everytime it fails, not just the first time"
This reverts commit 4f7b39a4871af28df1c4545ec37db179fa47a7da.

(This used to be ctdb commit db7b96304e4725f29b12398b7582e385daed63ed)
2009-09-15 19:33:35 +10:00
Ronnie Sahlberg
59cacded72 try to restart statd everytime it fails, not just the first time
(This used to be ctdb commit 4f7b39a4871af28df1c4545ec37db179fa47a7da)
2009-09-15 13:35:58 +10:00
Martin Schwenke
021892346c onnode: add "any" nodespec to select any node with running CTDB.
In testing and other situations (e.g. eventscripts) it is necessary to
select a node where a ctdb command can be run.  The whole idea here is
to avoid nodes where ctdbd is not running and where most ctdb commands
would fail.  This implements a standard way of doing this involving a
recursive onnode command.

There is still a small window for a race, where the selected node is
suddenly shutdown, but this is unavoidable.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit fb47cce86c0edae5caaf485f13ae7a151b6cb00d)
2009-09-08 15:10:20 +10:00
Martin Schwenke
50650fbbd1 onnode: update tests for healthy and connected to cope with new stopped bit.
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit bfc926c866e361ab28330747544b268ba130bf30)
2009-07-28 16:00:11 +10:00
Martin Schwenke
4697829e7c Fix minor onnode bugs relating to local daemons.
Commit a0f5148ac749758e2dfbd6099e829c5bf1d900e6 caused a subtle
regression.  Due to the subtlety, this description is much longer than
the 1 line patch that fixes it!  The regression, where a process that
invokes onnode is unexpectedly blocked, is only apparent if the
following conditions are met:

1. $CTDB_NODES_SOCKETS is set;
2. The command passed to onnode attempts to background a process; and
3. onnode is run in certain types of subshell (e.g. foo=$(onnode ...)).

In particular, when testing against local daemons (i.e. condition (1)
is met), tests/simple/07_ctdb_process_exists.sh would fail (because it
does both (2), (3)).

The problem is caused by the use of file descriptor 3 in the code that
allows separate filtering of stdout and stderr.  A backgrounded
process will have this descriptor open and the $(...) construct
appears to wait for all file descriptors to be closed.  This only
happens with local daemons because SSH is replaced by a shell and file
descriptor 3 leaks into that shell.  It does not occur when SSH is
used because the file descriptor does not leak into the remote shell
where the process is backgrounded.

The fix is simply to redirect file descriptor 3 to /dev/null in the
fakessh function, which is used when $CTDB_NODES_SOCKETS is set.

Also fixed is another minor bug when the -o option and
$CTDB_NODES_SOCKETS are used in combination.  The code uses the node
name as a suffix for the output filename(s).  Usually this is an IP
address.  However, when $CTDB_NODES_SOCKETS is in use the node name is
the socket name, which might be a path several directories deep.
Each output file is created via a simple redirection and this would
fail if unexpected directories appear in the filename.  3 possible
fixes were considered:

1. Replace all '/'s in the node name by '_'s.  Nice and simple.
2. Use the basename of the node name.  However, sockets may be in
   different directories but have the same basename.
3. Create all required directories before redirecting.  This is a
   little more complex and probably doesn't meet the user's
   expectations.

Option (1) is implemented here.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit c97d56d93d9c1007a4e85affb19ed0c2d0e11b6d)
2009-06-19 12:12:39 +10:00
Ronnie Sahlberg
45aa542064 teach ONNODE about deleted nodes
(This used to be ctdb commit 03d304e72a5839dc8d8d2e2312b346c21dca5774)
2009-06-02 15:03:44 +10:00
Martin Schwenke
53c9643104 Fix lvsmaster and natgwlist nodespecs.
They both need to use a -Y option to ctdb and for natgwlist we only
want the 1st line.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit e781ff61e17d733349021bb036514f823c7cbfbb)
2009-05-12 08:58:57 +10:00
Martin Schwenke
6098464175 New lvs/lvsmaster and natgw/natgwlist nodespecs for onnode.
Some code re-factoring to implement this and to make it easy to
implement new ones.  New simpler implementation of echo_nth() no
longer uses deleted get_nth() function.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 29559f5dd099bec210e98909c9b2e048461b7c81)
2009-05-12 08:58:23 +10:00
Martin Schwenke
9616959bd6 New option "-o <prefix>" saves stdout from each node to file <prefix>.<ip>.
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit a0f5148ac749758e2dfbd6099e829c5bf1d900e6)
2009-05-12 08:58:04 +10:00
Martin Schwenke
d741559fa6 Add some simple tests that can be run from within the tree.
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit eacb2ef82ea4809d874158756db973dd1e3fc8fc)
2008-11-20 20:40:01 +11:00
Martin Schwenke
62a65ebc38 onnode changes. "ok" is an alias for "healthy", "con" is an alias for
"connected".  Allow "rm" or "recmaster" to be a nodespec for the
recovery master. Better error handling for interaction with ctdb
client.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 05bdafed82106a0d8bfa53cd730eb3e1db68a51f)
2008-09-12 16:55:18 +10:00
Martin Schwenke
0013ec94de Changes to onnode. Add "healthy" and "connected" as possible
nodespecs.  Since we're now explicitly using bash, use local variables
when sensible.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 16626eaf9c63adfe780e8f51f9cd97810647e731)
2008-09-12 11:22:50 +10:00
Martin Schwenke
e78ebc8184 Merge commit 'origin/master' into martins
(This used to be ctdb commit 79ad588d61a56a062c043eae6aba3370ec10ac61)
2008-09-12 10:34:03 +10:00
Andrew Tridgell
3fa8aaa4e2 fixed up exit status for onnode
(This used to be ctdb commit c26afe26cc5c1f9cd9eef74166b5fc39dde591d3)
2008-07-14 09:19:22 +10:00