1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-27 03:21:53 +03:00
Commit Graph

5525 Commits

Author SHA1 Message Date
Amitay Isaacs
1f523a628a ctdb-tests: Avoid early exits in scripts that appear on tail of a pipe
When executing a shell script code "foo | bar", if "bar" terminates early,
then "foo" can get I/O error when writing to stdout.

The tdbtool stub did not wait to read anything from stdin when it is
expected to.  This would cause tests to fail randomly under load when
tdbtool process exited early.

Similarly, debug function read from stdin only under certain conditions
(higher debug and when not reading from tty).  Otherwise, exited early.

Thanks to Andrew Bartlett for noticing the problem and Catalyst Cloud
(http://catalyst.net.nz/cloud) for providing resources to test fixes.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Pair-Programmed-With: Martin Schwenke <martin@meltin.net>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Fri Mar 20 16:26:37 CET 2015 on sn-devel-104
2015-03-20 16:26:36 +01:00
Amitay Isaacs
4f82ef4b38 ctdb-scripts: Simplify 00.ctdb event script
Avoid extra which commands.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2015-03-20 13:49:26 +01:00
Martin Schwenke
8f312aef84 ctdb-tests: Add tests for "ctdb reloadips" and "ctdb recover"
Although much of the test infrastructure in recent commits is actually
targeted for "reloadnodes", it is worthwhile adding some tests for
"reloadips" and "recover".  This allows most of the test
infrastructure to be tried out against known good code.

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 Mar 16 09:18:55 CET 2015 on sn-devel-104
2015-03-16 09:18:55 +01:00
Martin Schwenke
a3f39ae7d7 ctdb-tools: Drop a debug message to DEBUG level
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-16 06:41:06 +01:00
Martin Schwenke
3fc205e6d7 ctdb-tests: Add stub for ctdb_client_async_control()
With support for CTDB_CONTROL_RELOAD_PUBLIC_IPS and
CTDB_CONTROL_RELOAD_NODES_FILE for now.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-16 06:41:06 +01:00
Martin Schwenke
d9b46d33f0 ctdb-tests: Add stub for ctdb_ctrl_reload_nodes_file()
ctdb_ctrl_reload_nodes_file_stub() does nothing except print a helpful
message.  That's enough to help test the tool.  It could update the
nodemap but that would not be incredibly useful.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-16 06:41:06 +01:00
Martin Schwenke
5fdd580bb3 ctdb-tests: Add stubs for some CTDB client messaging functions
Stub for ctdb_client_send_message() only implements
CTDB_SRVID_TAKEOVER_RUN and CTDB_SRVID_DISABLE_TAKEOVER_RUNS.  It
assumes srvid_broadcast() is in use and just calls handler to fake
appropriate replies.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-16 06:41:06 +01:00
Martin Schwenke
e1b4cd19a5 ctdb-tests: Test stub fixes
Initialise ctdb->ev in ctdb_cmdline_client_stub().

Add a comment to tevent_context_init_stub() explaining why the ctdb
context is initialised there instead of ctdb_cmdline_client_stub().
This information is in the git log but that doesn't help someone who
is reading the code.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-16 06:41:06 +01:00
Martin Schwenke
65c3c5730c ctdb-tests: Handle deleted nodes when loading fake nodemap
The daemon uses an IP address of "0.0.0.0" when handling deleted
nodes.  Do the same in the tests when loading a fake nodemap.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-16 06:41:06 +01:00
Martin Schwenke
a68df0a06d ctdb-tests: Support CTDB_DEBUGLEVEL in tool tests
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-16 06:41:06 +01:00
Martin Schwenke
dae6a7c4ba ctdb-tests: Add ctdb_ctrl_setrecmode() stub
If recovery mode is set to active then it updates the generation and
immediately sets recovery mode back to normal.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-16 06:41:06 +01:00
Martin Schwenke
38279d7ec1 ctdb-eventscripts: Make 11.natgw stateful
IP addresses and routes are only changed if either the NAT gateway
configuration or the NAT gateway master node has changed.  If running
"ip monitor" this will minimise the amount of noise seen.  It should
also be more lightweight at the expense of managing a couple of state
files.

Add a test to check that configuration changes behave correctly.
Tweak the static route result generation code so that the required
output is sorted.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-16 06:41:06 +01:00
Volker Lendecke
d171d2010a ctdb: Fix CID 1125613 Destination buffer too small
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>

Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Fri Mar 13 19:14:20 CET 2015 on sn-devel-104
2015-03-13 19:14:20 +01:00
Volker Lendecke
8d9bb5c54a ctdb: Introduce a helper var in ctdb_get_script_list
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-03-13 16:39:05 +01:00
Volker Lendecke
c1e8bfb186 ctdb: Fix memleak in ctdb_get_script_list
scandir allocates every name individually, see example code in susv4 or man
scandir

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-03-13 16:39:05 +01:00
Volker Lendecke
a8cc495b96 ctdb: Make for-loop in ctdb_get_script_list more idiomatic
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-03-13 16:39:05 +01:00
Volker Lendecke
b584bdebf9 ctdb: Fix whitespace
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-03-13 16:39:05 +01:00
Volker Lendecke
f724bfb44a ctdb: Fix CID 1288201 Array compared against 0
"helper_prog" is now declared as a static array

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-03-11 16:11:07 +01:00
Volker Lendecke
621bd07842 ctdb: Fix 1125553 Buffer not null terminated
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ira Cooper <ira@samba.org>
2015-03-10 21:48:03 +01:00
Martin Schwenke
b7b508c765 ctdb-daemon: Use statically allocated arrays for helper paths
The use of talloc with a static variable is somewhat confusing.
Statically allocate an array and use ctdb_set_helper() instead.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
2015-03-10 15:29:06 +01:00
Martin Schwenke
89b08c0f0b ctdb-common: New function ctdb_set_helper()
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
2015-03-10 15:29:06 +01:00
Martin Schwenke
f6efe0c5c2 ctdb-tests: Check for readable, not executable, script
Scripts in eventscript unit tests are run under an explicitly
specified shell so they do not need to be executable.  Checking that
the script is executable breaks on scripts that are installed without
the execute bit set, such as disabled eventscripts.

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): Fri Mar  6 04:40:07 CET 2015 on sn-devel-104
2015-03-06 04:40:07 +01:00
Amitay Isaacs
3f97be6d0f ctdb-locking: Back-off from logging every 10 seconds
If ctdb_lock_helper cannot get a lock within 10 seconds, ctdb daemon
logs a message and invokes an external debug script.  This is repeated
every 10 seconds.

In case of a contention or on a loaded system, there can be multiple
ctdb_lock_helper processes waiting to get lock on record(s).  For each
lock request taking longer, ctdb daemon will flood the log every
10 seconds.  Instead of logging aggressively every 10 seconds, relax
logging to every 100s and 1000s if the elapsed time has exceeded 100s
and 1000s respectively.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Michael Adam <obnox@samba.org>

Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Thu Mar  5 12:06:44 CET 2015 on sn-devel-104
2015-03-05 12:06:44 +01:00
Amitay Isaacs
956d1dbfd9 ctdb-tests: Correctly cascade test failures from the end of pipes
Some eventscript unit test failures get lost because _passed=false is
set in the tail of a pipe.  Add a new function test_fail() and call it
when necessary to ensure the value of _passed is set correctly.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Pair-programmed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Martin Schwenke <martin@meltin.net>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Thu Mar  5 07:16:54 CET 2015 on sn-devel-104
2015-03-05 07:16:54 +01:00
Amitay Isaacs
956e51707d ctdb-scripts: Add a 'rm' stub so statd-callout tests work correctly
statd-callout tries to remove global files from /var/lib/nfs/statd and
this causes errors in tests.  Add an rm stub that ignores attempts to
remove these files but invokes /bin/rm for anything else.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Pair-programmed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-03-05 04:46:06 +01:00
Amitay Isaacs
7a10e07770 ctdb-build: Specify absolute path to libsocket-wrapper.so
Specifying a relative path to LD_PRELOAD can fail if any of the test
scripts uses cd to change directory and execute commands.

Adding statd-callout tests breaks autotest since statd-callout does "cd".

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Wed Mar  4 13:11:53 CET 2015 on sn-devel-104
2015-03-04 13:11:53 +01:00
Martin Schwenke
a7dcc187e7 ctdb-tests: Remove the old, confusing INSTALL script
It is not used after switching to waf build.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-04 10:42:27 +01:00
Martin Schwenke
50ddc2c356 ctdb-scripts: Remove unused function nfs_statd_update()
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-04 10:42:27 +01:00
Martin Schwenke
500c6e194b ctdb-scripts: Change statd-callout to be more scalable
Updating ctdb.tdb on each add-client, del-client and each delete
during notify was too ambitious.  Persistent transactions do not
perform well enough to do this.

Revert to having add-client and del-client create touch files.  Each
monitor event calls "statd-callout update" to convert touch files into
ctdb.tdb records.

Update testcases to do the "update" and add an extra test.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-04 10:42:27 +01:00
Martin Schwenke
032441d9a2 ctdb-scripts: Fix a regression in statd-callout
Commit 4638010abb changed from using
gensub() to gsub() in awk.  However, it didn't halve the number of
backslashes in the target strings.  This is necessary because
backslash is used in gensub() target strings to allow substitution of
text matching parenthesised subexpressions.  This is not the case with
gsub().

So, halve the number of backslashes in the target string where gsub()
is used in statd-callout.  This is the only target string broken by
changes made by the above commit

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-04 10:42:27 +01:00
Martin Schwenke
22602f76bc ctdb-tests: Unit tests for statd-callout
With improvements to unit test infrastructure to support.  This
includes linking the real statd-callout into etc-ctdb/ in place of the
placeholder script.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-04 10:42:27 +01:00
Martin Schwenke
d98c7ba382 ctdb-tests: Make setup of public addresses more obvious
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-04 10:42:27 +01:00
Martin Schwenke
7e7c24ca7a ctdb-tests: Extend eventscript unit test infrastructure for other scripts
There's so much infrastructure here that it would be a shame not to
use it for testing things like statd-callout.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-04 10:42:26 +01:00
Martin Schwenke
9317d82c19 ctdb-tests: Support testing scripts that change directory
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-04 10:42:26 +01:00
Martin Schwenke
2aeb518637 ctdb-tests: Extend ctdb stub to support "ip" with and without -X
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-04 10:42:26 +01:00
Martin Schwenke
d057ca04a9 ctdb-tests: Extend ctdb stub to support "ptrans", "pdelete", "catdb"
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-04 10:42:26 +01:00
Amitay Isaacs
04a061e4d1 ctdb-io: Do not use sys_write to write to client sockets
When sending messages to clients, ctdb checks for EAGAIN error code and
schedules next write in the subsequent event loop.  Using sys_write in
these places causes ctdb to loop hard till a client is able to read from
the socket.  With real time scheduling, ctdb daemon spins consuming 100%
of CPU trying to write to the client sockets.  This can be quite harmful
when running under VMs or machines with single CPU.

This regression was introduced when all read/write calls were replaced to
use sys_read/sys_write wrappers (c1558adeaa).

The existing code backs off in case of EAGAIN failures and waits for an
event loop to process the write again.  This should give ctdb clients
a chance to get scheduled and to process the ctdb socket.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Tue Feb 24 12:29:30 CET 2015 on sn-devel-104
2015-02-24 12:29:30 +01:00
Martin Schwenke
dc32f11b87 ctdb-scripts: Improve messages about invalid tunables during "setup"
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): Wed Feb 18 08:03:33 CET 2015 on sn-devel-104
2015-02-18 08:03:33 +01:00
Martin Schwenke
c3706e7fb0 ctdb-tool: Print a warning when setting an obsolete tunable variable
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-02-18 05:34:06 +01:00
Martin Schwenke
54f0c39e5a ctdb-client: Return a value of 1 when setting obsolete tunable variable
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-02-18 05:34:06 +01:00
Martin Schwenke
2c7c35377e ctdb-tests: New tests for 00.ctdb "setup" event - set tunables from config
Unit test infrastructure tweaks to support.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-02-18 05:34:06 +01:00
Martin Schwenke
39686f4505 ctdb-scripts: Fix tunable setup code by making it shell-agnostic
All tunables set in configuration are currently set to 0 on system
where /bin/sh is dash (and perhaps other non-bash shells).  dash puts
single quotes around all values in the output of the "set" builtin
command, whereas bash only puts them around values when something
needs to be quoted.  Tunables always have a simple integer value so
dash will quote them and bash won't.  The setup code currently passes
the raw value, including any quotes to "ctdb setvar ...".  This
command does no error checking on the input, so "'1'" is converted to
0.

Change the code so that the value is determined from the shell
variable and is independent of the "set" output.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-02-18 05:34:06 +01:00
Martin Schwenke
664d62b611 ctdb: Change default debug level to NOTICE (2)
This was true for the daemon until commit
b4589b954e.

Defaulting to ERR in the ctdb CLI tool encourages logging notices at
ERR level, so default to NOTICE instead.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-02-18 05:34:06 +01:00
Volker Lendecke
975b9b0304 ctdb: server_id_get->server_id_fetch
server_id_get with the next patch will be a global parsing function.
I've decided to rename this here in ctdb, as it's only a static function
in ctdb_client.c and apparently not intended for wider use. Please speak
up if you don't like this :-)

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2015-02-13 23:32:07 +01:00
Martin Schwenke
39d2fd330a ctdb-recoverd: Abort when daemon can take recovery lock during recovery
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): Fri Feb 13 09:48:15 CET 2015 on sn-devel-104
2015-02-13 09:48:15 +01:00
Martin Schwenke
432d677489 ctdb-recoverd: Improve error messages on recovery lock coherence fail
When the daemon is able to take the recovery lock during recovery we
might as well guess that the cluster filesystem has a lock coherence
problem and print a more useful message.  This will be more helpful to
those trying out cluster filesystems that don't have lock coherence or
that are difficult to setup.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-02-13 07:19:07 +01:00
Martin Schwenke
48c91407ab ctdb-recoverd: Don't release and re-take the recovery lock
Just continue to hold it, otherwise a broken node might win an
election and grab the lock.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-02-13 07:19:07 +01:00
Martin Schwenke
1d6ed91f55 ctdb-recoverd: Simplify ctdb_recovery_lock()
Have it just silently take or fail to take the lock, except on an
unexpected failure (where it should log an error).

This means that when it is called we need to keep the old behaviour
and explicitly release the lock.  In do_recovery() the lock is
released and a message is printed before attempting to take the lock.
In the daemon sanity check the lock must be released in the error path
if it is actually taken.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-02-13 07:19:07 +01:00
Martin Schwenke
be19a17faf ctdb-recoverd: Remove check_recovery_lock()
This has not done anything useful since commit
b9d8bb23af.  Instead, just check that
the lock is held.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-02-13 07:19:07 +01:00
Martin Schwenke
668ed53662 ctdb-recoverd: Improve logging when recovery lock file is changed
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-02-13 07:19:07 +01:00