ctdb.git
9 years agodoc: Update NEWS ctdb-2.5.5
Amitay Isaacs [Mon, 13 Apr 2015 04:17:12 +0000 (14:17 +1000)]
doc: Update NEWS

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
9 years agoincludes: Remove some unnecessary declarations
Martin Schwenke [Fri, 5 Sep 2014 06:09:34 +0000 (16:09 +1000)]
includes: Remove some unnecessary declarations

To accommodate removing file_lines_load() from here, drop the #ifdef
around the declaration in util.h.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 9726e17e366382776c87a8aaa63884665c604896)

9 years agologging: Move variable debug_extra from debug.*
Martin Schwenke [Sat, 16 Aug 2014 06:17:02 +0000 (16:17 +1000)]
logging: Move variable debug_extra from debug.*

debug_extra is CTDB-specific.  Moving it will help with the
transitions to Samba's updated debug.[ch].

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 8b39141c46458974d5476b2925f2dd5d51d9180d)

9 years agologging: Factor out ctdb_logging.h from includes.h
Martin Schwenke [Tue, 9 Sep 2014 03:52:07 +0000 (13:52 +1000)]
logging: Factor out ctdb_logging.h from includes.h

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 97dc127b81c1923755b59aad6e735aa679af3f64)

9 years agorecoverd: Change include of dlinklist.h to contain directory
Martin Schwenke [Fri, 15 Aug 2014 06:18:05 +0000 (16:18 +1000)]
recoverd: Change include of dlinklist.h to contain directory

This makes it consistent with the rest of the code and avoids problems
when some variant of lib/util isn't in the include path.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 0c0f323bb3e9146dc584a461b225586670fa9c2e)

9 years agotools: Move definition of timeval_delta() to tools/ctdb.c
Martin Schwenke [Fri, 15 Aug 2014 05:53:03 +0000 (15:53 +1000)]
tools: Move definition of timeval_delta() to tools/ctdb.c

This function is only used in this file.  Samba's lib/util doesn't
have timeval_delta(), so staging a clean transition.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 6e1568149ede06d48b91bbc7ecd8c55da3b41a41)

9 years agodaemon: Drop the argument to fault_setup()
Martin Schwenke [Fri, 15 Aug 2014 05:55:20 +0000 (15:55 +1000)]
daemon: Drop the argument to fault_setup()

Samba's version doesn't accept an argument, so this aids a smooth
transition.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit c5c74e47ee672e9e9605c5c4b96733d899b6f9b6)

9 years agoutil: Add extra max_size argument to file_lines_load()
Martin Schwenke [Fri, 15 Aug 2014 06:11:45 +0000 (16:11 +1000)]
util: Add extra max_size argument to file_lines_load()

This is part of a migration to Samba's lib/util.  CTDB always passes 0
(i.e. no max_size) so use a simple assert() to enforce this, rather
than changing a lot of code that will be discarded anyway.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit a4e76b58a5086e1339dea53b72437ed179e6025a)

9 years agocommon: Move hex_decode_talloc() to the lock helper
Martin Schwenke [Wed, 6 Aug 2014 06:36:58 +0000 (16:36 +1000)]
common: Move hex_decode_talloc() to the lock helper

This is the only place it is used.

After migrating to Samba's lib/util, the lock helper can be changed to
use strhex_to_data_blob().

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 94a5e28ffb53a268865666038678e78cbbb39de3)

9 years agocommon: Add some missing #includes
Martin Schwenke [Thu, 4 Sep 2014 03:33:58 +0000 (13:33 +1000)]
common: Add some missing #includes

To avoid warnings when using --enable-developer, which uses
-Wmissing-prototypes.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 751ad4b62561b140b7a33d66e63907411a748501)

9 years agodaemon: Move some inline declarations to header file
Martin Schwenke [Thu, 4 Sep 2014 03:31:15 +0000 (13:31 +1000)]
daemon: Move some inline declarations to header file

To avoid warnings when using --enable-developer, which uses
-Wmissing-prototypes.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit a81dccf7ad8345a1c44dc7a08e2320bd88e1aaa5)

9 years agotests: Add missing declarations caused by #define magic
Martin Schwenke [Thu, 4 Sep 2014 03:30:09 +0000 (13:30 +1000)]
tests: Add missing declarations caused by #define magic

Some declarations get lost because they basically get #define-d away,
so they need to be repeated after the #undef-s.  Also, some functions
are introduced due the #define-s.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 6336b958d61ba6901edbaddac8bc10539c8f30ab)

9 years agotests: Mark some functions as static
Martin Schwenke [Thu, 4 Sep 2014 03:28:34 +0000 (13:28 +1000)]
tests: Mark some functions as static

To avoid warnings when using --enable-developer, which uses
-Wmissing-prototypes.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 6674949317dd4b2c1855571ea378eb6bc3b2e86c)

9 years agoutil: Remove util/strlist.c and references to str_util_*()
Martin Schwenke [Thu, 4 Sep 2014 02:34:46 +0000 (12:34 +1000)]
util: Remove util/strlist.c and references to str_util_*()

They're not used in CTDB.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 5de4a97fe941c27080061480cdd7ed8f60f4438e)

9 years agoFix some "declarations after code" problems
Martin Schwenke [Thu, 4 Sep 2014 01:21:24 +0000 (11:21 +1000)]
Fix some "declarations after code" problems

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit b0f9d3305850bdcce171b53e7bbbc9628a4e3c20)

9 years agoutil: Variables should be declared extern in headers
Martin Schwenke [Thu, 4 Sep 2014 01:20:28 +0000 (11:20 +1000)]
util: Variables should be declared extern in headers

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 1d16555fa0ad562dcd8c4bbffaca454e68bcabbf)

9 years agoChange default debug level to NOTICE (2)
Martin Schwenke [Mon, 9 Feb 2015 01:04:41 +0000 (12:04 +1100)]
Change default debug level to NOTICE (2)

This was true for the daemon until commit
b4589b954e1090a934fafd3f8e3c2cf1ed785c61.

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>
(Imported from commit 664d62b61108657d3011cf0bcbe260533c97676f)

9 years agotests: Check for readable, not executable, script
Martin Schwenke [Fri, 6 Mar 2015 00:36:18 +0000 (11:36 +1100)]
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

(Imported from commit f6efe0c5c2378f477e528ac9c6571a732aa2c49b)

9 years agolocking: Back-off from logging every 10 seconds
Amitay Isaacs [Wed, 4 Mar 2015 04:36:05 +0000 (15:36 +1100)]
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

(Imported from commit 3f97be6d0fc166ccc3c97b7f71a01a4f9adb5ddd)

9 years agotests: Correctly cascade test failures from the end of pipes
Amitay Isaacs [Thu, 5 Mar 2015 02:11:46 +0000 (13:11 +1100)]
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

(Imported from commit 956d1dbfd91615032de337b0d84b40c16657b8c1)

9 years agoscripts: Add a 'rm' stub so statd-callout tests work correctly
Amitay Isaacs [Thu, 5 Mar 2015 02:10:32 +0000 (13:10 +1100)]
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>
(Imported from commit 956e51707d7ddcff060352f54d11ff42bdcc51ef)

9 years agoscripts: Remove unused function nfs_statd_update()
Martin Schwenke [Fri, 13 Feb 2015 04:42:20 +0000 (15:42 +1100)]
scripts: Remove unused function nfs_statd_update()

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 50ddc2c35643389c2f249c6ad4496ab73a1bfc99)

9 years agoscripts: Change statd-callout to be more scalable
Martin Schwenke [Fri, 13 Feb 2015 09:55:43 +0000 (20:55 +1100)]
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>
(Imported from commit 500c6e194babe06b6aead7a053a9442c94db6e38)

9 years agoscripts: Fix a regression in statd-callout
Martin Schwenke [Thu, 26 Feb 2015 04:34:51 +0000 (15:34 +1100)]
scripts: Fix a regression in statd-callout

Commit 4638010abb116aed0c180207aaa11475277aecb7 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>
(Imported from commit 032441d9a2974584cde455e4dbd5cc33fe6a23c2)

9 years agotests: Unit tests for statd-callout
Martin Schwenke [Wed, 4 Mar 2015 00:51:20 +0000 (11:51 +1100)]
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>
(Imported from commit 22602f76bc1ec91e807a8f1cd45ba6fb4c05e622)

9 years agotests: Make setup of public addresses more obvious
Martin Schwenke [Fri, 27 Feb 2015 04:20:56 +0000 (15:20 +1100)]
tests: Make setup of public addresses more obvious

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit d98c7ba382189161c5b8cbbebbdfbe36f1456572)

9 years agotests: Extend eventscript unit test infrastructure for other scripts
Martin Schwenke [Fri, 27 Feb 2015 04:19:04 +0000 (15:19 +1100)]
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>
(Imported from commit 7e7c24ca7a422f2258962216b0184eda8d49827f)

9 years agotests: Support testing scripts that change directory
Martin Schwenke [Fri, 27 Feb 2015 04:17:30 +0000 (15:17 +1100)]
tests: Support testing scripts that change directory

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 9317d82c19a0eb51ff6293d00328a5c36b063a2c)

9 years agotests: Extend ctdb stub to support "ip" with and without -X
Martin Schwenke [Fri, 27 Feb 2015 04:15:18 +0000 (15:15 +1100)]
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>
(Imported from commit 2aeb518637af29da03984470d874b94dfb18e34e)

9 years agotests: Extend ctdb stub to support "ptrans", "pdelete", "catdb"
Martin Schwenke [Fri, 27 Feb 2015 04:13:23 +0000 (15:13 +1100)]
tests: Extend ctdb stub to support "ptrans", "pdelete", "catdb"

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit d057ca04a9eec0f2aa3d792da0a4648e3716685a)

9 years agotest: Remove unused function check_ctdb_logfile()
Martin Schwenke [Tue, 12 Aug 2014 04:29:34 +0000 (14:29 +1000)]
test: Remove unused function check_ctdb_logfile()

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 85cc4efbff601dc25a351ec838de168eb3c7d29a)

9 years agoio: Do not use sys_write to write to client sockets
Amitay Isaacs [Mon, 23 Feb 2015 01:38:11 +0000 (12:38 +1100)]
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 (c1558adeaa980fb4bd6177d36250ec8262e9b9fe).

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

(Imported from commit 04a061e4d19d5bdbd8179fb0fab8b0875eec243e)

9 years agoscripts: Improve messages about invalid tunables during "setup"
Martin Schwenke [Sat, 14 Feb 2015 01:53:08 +0000 (12:53 +1100)]
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

(Imported from commit dc32f11b871a7d4e8ea6fd1d01491d89103decf7)

9 years agotool: Print a warning when setting an obsolete tunable variable
Martin Schwenke [Sun, 8 Feb 2015 23:33:35 +0000 (10:33 +1100)]
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>
(Imported from commit c3706e7fb07bcb35f7d894c4e8e0c12b4a62d0db)

9 years agoclient: Return a value of 1 when setting obsolete tunable variable
Martin Schwenke [Sun, 8 Feb 2015 23:32:47 +0000 (10:32 +1100)]
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>
(Imported from commit 54f0c39e5a33871847aa9fe2c070c7f638f54cc4)

9 years agotests: New tests for 00.ctdb "setup" event - set tunables from config
Martin Schwenke [Sun, 15 Feb 2015 03:39:51 +0000 (14:39 +1100)]
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>
(Imported from commit 2c7c35377e5452e37925b970253b70875a8d7470)

9 years agoscripts: Fix tunable setup code by making it shell-agnostic
Martin Schwenke [Mon, 16 Feb 2015 03:04:09 +0000 (14:04 +1100)]
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>
(Imported from commit 39686f45056d942de5ebe3263a533a99ca17c79e)

9 years agorecoverd: Abort when daemon can take recovery lock during recovery
Martin Schwenke [Tue, 27 Jan 2015 01:55:42 +0000 (12:55 +1100)]
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

(Imported from commit 39d2fd330a60ea590d76213f8cb406a42fa8d680)

9 years agorecoverd: Improve error messages on recovery lock coherence fail
Martin Schwenke [Wed, 17 Dec 2014 09:33:19 +0000 (20:33 +1100)]
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>
(Imported from commit 432d6774891eba30a959cd2d8ee8469d189c7872)

9 years agorecoverd: Don't release and re-take the recovery lock
Martin Schwenke [Tue, 9 Dec 2014 02:51:27 +0000 (13:51 +1100)]
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>
(Imported from commit 48c91407abd5e34463d3a10cb6fce47ec4a0d5f6)

9 years agorecoverd: Simplify ctdb_recovery_lock()
Martin Schwenke [Tue, 9 Dec 2014 03:50:38 +0000 (14:50 +1100)]
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>
(Imported from commit 1d6ed91f5518d462ba368bca03be923428710157)

9 years agorecoverd: Remove check_recovery_lock()
Martin Schwenke [Tue, 9 Dec 2014 03:45:08 +0000 (14:45 +1100)]
recoverd: Remove check_recovery_lock()

This has not done anything useful since commit
b9d8bb23af8abefb2d967e9b4e9d6e60c4a3b520.  Instead, just check that
the lock is held.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit be19a17faf6da97365c425c5b423e9b74f9c9e0c)

9 years agorecoverd: Improve logging when recovery lock file is changed
Martin Schwenke [Tue, 9 Dec 2014 03:09:40 +0000 (14:09 +1100)]
recoverd: Improve logging when recovery lock file is changed

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 668ed5366237b61f0ff618f32555ce29cca5e6f3)

9 years agorecoverd: New function ctdb_recovery_unlock()
Martin Schwenke [Tue, 9 Dec 2014 03:07:20 +0000 (14:07 +1100)]
recoverd: New function ctdb_recovery_unlock()

Unlock the recovery lock file.  This way knowledge of the file
descriptor isn't sprinkled throughout the code.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit db32a2bce54b9618fe247b33d6de81bd5f7a3b62)

9 years agorecoverd: New function ctdb_recovery_have_lock()
Martin Schwenke [Tue, 9 Dec 2014 02:50:22 +0000 (13:50 +1100)]
recoverd: New function ctdb_recovery_have_lock()

True if this recovery daemon holds the lock.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 72701be663ddb265320a022a22130a3437bbf6bc)

9 years agodaemon: Log a warning when setting obsolete tunables
Martin Schwenke [Tue, 9 Dec 2014 02:49:06 +0000 (13:49 +1100)]
daemon: Log a warning when setting obsolete tunables

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 4d3b52f1cec46f66f8d0827bc8f458cd8c86b5a5)

9 years agodaemon: Mark tunable VerifyRecoveryLock as obsolete
Martin Schwenke [Tue, 9 Dec 2014 02:47:42 +0000 (13:47 +1100)]
daemon: Mark tunable VerifyRecoveryLock as obsolete

It is pointless having a recovery lock but not sanity checking that it
is working.  Also, the logic that uses this tunable is confusing.  In
some places the recovery lock is released unnecessarily because the
tunable isn't set.

Simplify the logic by assuming that if a recovery lock is specified
then it should be verified.

Update documentation that references this tunable.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit d110fe231849d76ecb83378c934627dc64b74c72)

9 years agodoc: Improve documentation of the recovery lock
Martin Schwenke [Tue, 3 Feb 2015 03:27:11 +0000 (14:27 +1100)]
doc: Improve documentation of the recovery lock

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit a01744c08ff5b8aca4af99842acfc78a87af9297)

9 years agotests: Add new "ctdb setreclock" test
Martin Schwenke [Mon, 2 Feb 2015 10:21:20 +0000 (21:21 +1100)]
tests: Add new "ctdb setreclock" test

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  4 05:40:55 CET 2015 on sn-devel-104

(Imported from commit 0e89d586b2b7fa6a165a49862d2dce0d13f8b157)

9 years agodaemon: Fix SET_RECLOCK_FILE regression
Martin Schwenke [Wed, 28 Jan 2015 07:51:42 +0000 (18:51 +1100)]
daemon: Fix SET_RECLOCK_FILE regression

If the recovery lock file is unset then this dereferences a NULL
pointer.  The regression is due to commit
6f1ac7af0f87d85402d708231e45a69713bba026.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 5e00673f2d95b6257a05324d2ae068004e29ff85)

9 years agoscripts: Call iptables/ip6tables directly from iptables_wrapper
Martin Schwenke [Tue, 30 Dec 2014 05:04:00 +0000 (16:04 +1100)]
scripts: Call iptables/ip6tables directly from iptables_wrapper

Drops the iptables() and ip6tables() functions and, hence, the
hardcoding of paths /sbin/iptables and /sbin/ip6tables.  The latter
avoids problems on openSUSE where (for example) /usr/sbin/iptables is
used instead.

This means that locking around ip*tables commands is only done when
iptables_wrapper is called directly.  This is fine because the only
conflict is when "releaseip" or "takeip"/"updateip" events are run in
parallel.  The other uses in 11.natgw and 70.iscsi are in events where
there will be no collisions.

Making 11.natgw support IPv6 is unnecessary.  Just put a static IPv6
address on each interface - they're plentiful.

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 Jan 28 08:29:55 CET 2015 on sn-devel-104

(Imported from commit ab51f283e7a7f4fc82a94d39e7bb3a68e8aac554)

9 years agoscripts: Error message, comment and whitespace cleanups
Martin Schwenke [Tue, 30 Dec 2014 06:07:09 +0000 (17:07 +1100)]
scripts: Error message, comment and whitespace cleanups

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 9b67c1fa3748678552400a81172d124e59d5eb79)

9 years agoscripts: iSCSI eventscript should fail when PNN can't be determined
Martin Schwenke [Tue, 30 Dec 2014 06:03:46 +0000 (17:03 +1100)]
scripts: iSCSI eventscript should fail when PNN can't be determined

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 1a5414b6d25ed1b1abdafd8594183b84af33a6fb)

9 years agoscripts: Make 70.iscsi IPv6-aware
Martin Schwenke [Tue, 30 Dec 2014 06:01:21 +0000 (17:01 +1100)]
scripts: Make 70.iscsi IPv6-aware

Block iSCSI port for families of all address the node is configured to
host.

Could just unconditional add blocking using ip6tables instead.
However, this would produce errors when no IPv6 public addresses are
configured and ip6tables is not installed.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit d1bd26e5eb25aee2ce82ef178692a64073a99aa0)

9 years agoimprove helpfulness of debug message when taking reclock fails
Michael Adam [Thu, 8 Jan 2015 23:10:37 +0000 (00:10 +0100)]
improve helpfulness of debug message when taking reclock fails

Print out the errno if the fcntl call.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Richard Sharpe <rsharpe@samba.org>
Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Fri Jan  9 04:25:02 CET 2015 on sn-devel-104

(Imported from commit a59fb322d60b7152110cc0638dd9b76dd259ac15)

9 years agodaemon: Handle out-of-memory when setting recovery lock file
Martin Schwenke [Tue, 9 Dec 2014 02:40:23 +0000 (13:40 +1100)]
daemon: Handle out-of-memory when setting recovery lock file

Log a message when the reclock file actually changes and avoid a
memory allocation when it doesn't change.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
(Imported from commit 6f1ac7af0f87d85402d708231e45a69713bba026)

9 years agoscripts: Don't use the GNU awk gensub() function
Martin Schwenke [Fri, 19 Dec 2014 03:19:32 +0000 (14:19 +1100)]
scripts: Don't use the GNU awk gensub() function

This is a gawk extension and can't be used reliably if just running
"awk".  It is simple enough to switch to using the standard sub() and
gsub() functions.

The alternative is to switch to explicitly running "gawk".  However,
although the eventscripts aren't exactly portable, it is probably
better to move closer to portability than further away.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
(Imported from commit 4638010abb116aed0c180207aaa11475277aecb7)

9 years agoscripts: Try to deal with Ubuntu having /usr/sbin/service
Martin Schwenke [Mon, 1 Dec 2014 01:21:16 +0000 (12:21 +1100)]
scripts: Try to deal with Ubuntu having /usr/sbin/service

Falling back to running the initscript doesn't work because it detects
that upstart is being used and fails.  This was observed when trying
to start winbind on Ubuntu 11.04.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
(Imported from commit a5c5eee7d186d938c5b458cb6dbf0c78cb548b63)

9 years agodaemon: Use correct tdb flags when enabling robust mutex support
Amitay Isaacs [Thu, 11 Dec 2014 02:16:47 +0000 (13:16 +1100)]
daemon: Use correct tdb flags when enabling robust mutex support

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11000

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
(Imported from commit e0bf5dd4566785b41ad1fa0492a9f215639f1685)

9 years agoscripts: Fix bashism in ctdbd_wrapper script
Led [Sun, 14 Dec 2014 19:06:44 +0000 (21:06 +0200)]
scripts: Fix bashism in ctdbd_wrapper script

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11007

Signed-off-by: Oleksandr Chumachenko <ledest@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
(Imported from commit 2c3672f4249a7d3453b7e82ca96b4cd666aae709)

9 years agotests: Fix tickle sniffing for IPv4
Martin Schwenke [Sat, 20 Dec 2014 08:54:13 +0000 (19:54 +1100)]
tests: Fix tickle sniffing for IPv4

tcptickle_sniff_start() assumes that if $dst contains a ': then it
should use the IPv6 sniffing code.  However, $dst is a socket, so has
a trailing ":<port>".

Strip the trailing ":<port>" before checking for ':' as a marker for
an IPv6 address.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
(Imported from commit 82aa6bd2f27775f3fd82931d613379d5d618ef70)

9 years agotests: Need to drop public IPs in kill-failover tests
Martin Schwenke [Wed, 3 Dec 2014 01:10:07 +0000 (12:10 +1100)]
tests: Need to drop public IPs in kill-failover tests

These tests simulate a dead node rather than a CTDB failure, so drop
IP addresses when killing a "node" to avoid problems with duplicates.

To cope with a CTDB failure a watchdog would be needed to ensure that
the public IPs are dropped when CTDB dies.  Let's not do that now.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Fri Dec  5 23:29:39 CET 2014 on sn-devel-104

(Imported from commit a07af1bb56a76d1a7ab856547c801499fc17b21b)

9 years agodaemon: Gratuitous ARP equivalent for IPv6 is neighbor advertisement
Martin Schwenke [Mon, 1 Dec 2014 23:57:12 +0000 (10:57 +1100)]
daemon: Gratuitous ARP equivalent for IPv6 is neighbor advertisement

Not neighbour solicitation.  See:

  https://tools.ietf.org/html/rfc4861#section-4.4

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 7f3f3b15d52c4047cbcb1c3e81f65675c8708f5f)

9 years agotests: More debug on SSH failure
Martin Schwenke [Wed, 3 Dec 2014 01:09:12 +0000 (12:09 +1100)]
tests: More debug on SSH failure

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 3a2c8bb906fac4e2611a28ead6b4290ddc93de54)

9 years agotests: Make tcpdump output more verbose
Martin Schwenke [Mon, 1 Dec 2014 02:30:29 +0000 (13:30 +1100)]
tests: Make tcpdump output more verbose

This helps with debugging.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 49449f66fca52d5044d2e486570562df866adf57)

9 years agotests: Use ip neigh command instead of arp
Martin Schwenke [Sat, 29 Nov 2014 09:01:20 +0000 (20:01 +1100)]
tests: Use ip neigh command instead of arp

Extend select_test_node_and_ips() to set $test_prefix in addition to
$test_ip.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit a7e7d95de9cf09652cef63d65484bbb0faa42e1c)

9 years agotests: Generalise the gratarp and tickle sniffing code for IPv6
Martin Schwenke [Mon, 1 Dec 2014 03:07:57 +0000 (14:07 +1100)]
tests: Generalise the gratarp and tickle sniffing code for IPv6

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

(Imported from commit 0f3d9752c4677b2f3b5ee47a0b8f973b4260ef57)

9 years agotests: Match IPv6 connections in netstat output
Martin Schwenke [Mon, 1 Dec 2014 02:51:47 +0000 (13:51 +1100)]
tests: Match IPv6 connections in netstat output

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 3135a8c62551e09a3abada86335882a91d398747)

9 years agotests: Use ping_wrapper to do relevant ping or ping6
Martin Schwenke [Mon, 1 Dec 2014 02:50:42 +0000 (13:50 +1100)]
tests: Use ping_wrapper to do relevant ping or ping6

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 255705c030135bd54a1f7a7dc40cbf00c2fb39c9)

9 years agotests: Extend regexps to handle IPv6 address matching
Martin Schwenke [Wed, 3 Dec 2014 04:58:20 +0000 (15:58 +1100)]
tests: Extend regexps to handle IPv6 address matching

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 62acf5986f52a3118ed4e3638c5ac8b1f9c0adf8)

9 years agotests: Bracket IP addresses in NFS mounts and scp command (for IPv6)
Martin Schwenke [Wed, 3 Dec 2014 04:57:35 +0000 (15:57 +1100)]
tests: Bracket IP addresses in NFS mounts and scp command (for IPv6)

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 62164ec52fd1082863bf5017a5170f74f18a07c3)

9 years agotests: Try to handle IPv6 addresses for local daemons
Martin Schwenke [Wed, 26 Nov 2014 10:32:22 +0000 (21:32 +1100)]
tests: Try to handle IPv6 addresses for local daemons

If CTDB_USE_IPV6 is set then use IPv6 addresses for nodes and public
IPs.  This can be useful for some simple tests.  However, the node
address actually needs to be on lo so that ctdbd can bind to the port
on that address, so they actually need to be added as root before
running tests, like this:

  for i in $(seq 1 10) ; do ip addr add "fc00:10::${i}/64" dev lo ; done

IPv4 127.0.0.0/8 addresses are somehow magic and only one needs to be
on lo so that many can be bound to.

Also change the IPv4 node addresses to be (slightly) more exotic.

For both IPv4 and IPv6, choose addresses that are compatible with
socket wrapper.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Signed-off-by: Amitay Isaacs <amitay@gmail.com> (socket wrapper fixes)
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net> (socket wrapper fixes)
(Imported from commit d9d07fff34143d251b4987cdb1cff1e8b3384e64)

9 years agotests: Extend regexp to match IPv6 addresses
Martin Schwenke [Wed, 26 Nov 2014 10:31:42 +0000 (21:31 +1100)]
tests: Extend regexp to match IPv6 addresses

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 2a83b74597a3366536e1935e2e8ff23493503117)

9 years agotools: Bracket IP addresses in onnode (for IPv6)
Martin Schwenke [Fri, 28 Nov 2014 10:49:08 +0000 (21:49 +1100)]
tools: Bracket IP addresses in onnode (for IPv6)

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 2d480792e7d0b3f6628186dc77f54b708e315dd1)

9 years agodaemon: Fix IP address comparisons for IPv6 addresses
Amitay Isaacs [Tue, 25 Nov 2014 01:38:23 +0000 (12:38 +1100)]
daemon: Fix IP address comparisons for IPv6 addresses

Before storing node IP address, convert into the correct abbreviated
string form for IPv6 addresses.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
(Imported from commit e3c59d83d0ace9d7421d40d33fe917fb82bb38d8)

9 years agoscripts: Wait until IPv6 addresses are not "tentative"
Martin Schwenke [Fri, 21 Nov 2014 06:33:21 +0000 (17:33 +1100)]
scripts: Wait until IPv6 addresses are not "tentative"

There are a few potential failure modes when adding an IPv6 address.
It takes a little while of duplicate address detection to complete, so
wait for a while.  After a timeout, also need to check to see if
duplicate address detection failed - if it did then actually drop the
IP address.

This really needs some careful thinking.  If CTDB disappears on a node
but the node's IP addresses are still on interfaces then the above
failure mode could cause the takeover nodes to become banned.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit d0b2375c3d754da3cd68e34617ab3edd36e9317b)

9 years agoeventscripts: Specify broadcast optionally to ip addr add
Amitay Isaacs [Thu, 20 Nov 2014 10:58:31 +0000 (21:58 +1100)]
eventscripts: Specify broadcast optionally to ip addr add

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
(Imported from commit d4212bd6a533b4b54b56e376a9246f2396cba253)

9 years agodaemon: Trust vnn->interface for an IP when releasing it
Martin Schwenke [Fri, 21 Nov 2014 03:52:47 +0000 (14:52 +1100)]
daemon: Trust vnn->interface for an IP when releasing it

ctdb_sys_find_ifname() doesn't work for IPv6 addresses so don't use
it.

Trust the eventscript to do sanity checking on the interface.  Current
warnings are replaced with equivalents generated by the eventscript.
The unlikely message:

  Public IP %s is hosted on interface %s but we have no VNN

will be replaced by:

  WARNING: Public IP %s hosted on interface %s but VNN says __none__

which is clear enough.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 108b1be0ee62af7ecb3c775f45c540dd07a527bf)

9 years agoscripts: Make 10.interface IPv6-safe
Martin Schwenke [Fri, 21 Nov 2014 03:46:00 +0000 (14:46 +1100)]
scripts: Make 10.interface IPv6-safe

Add checking to "releaseip" and "updateip" to ensure that the given IP
address is really on the given interface with the given netmask.  If
reality doesn't match the given arguments then believe reality.

Use new function iptables_wrapper() instead of calling iptables()
directly.

Use new function flush_route_cache() instead of doing IPv4-specific
/proc magic.

Remove setting of otherwise unused variable "failed".

Fix a test for which the error message has changed.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 6471541d6d2bc9f2af0ff92b280abbd1d933cf88)

9 years agoscripts: New functions ip6tables() and iptables_wrapper()
Martin Schwenke [Fri, 21 Nov 2014 03:39:43 +0000 (14:39 +1100)]
scripts: New functions ip6tables() and iptables_wrapper()

ip6tables() uses the same lock as iptables().  This is done on
suspicion.

iptables_wrapper() takes 1st argument "inet" or "inet6", and the rest
is passed to the correct iptables variant.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit c314ae0b2af4a902cdd003ec6d663fe5b62b003b)

9 years agoscripts: Add IPv6 addresses support in ip_maskbits_iface()
Martin Schwenke [Fri, 21 Nov 2014 03:37:54 +0000 (14:37 +1100)]
scripts: Add IPv6 addresses support in ip_maskbits_iface()

It also prints a third word, the address family.  This is either
"inet" or "inet6".

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit ed029ae0a1faa56bf882a71d10828e2a90ab0bc7)

9 years agoutils: Update Nagios code to use ctdb -X
Martin Schwenke [Thu, 20 Nov 2014 23:48:25 +0000 (10:48 +1100)]
utils: Update Nagios code to use ctdb -X

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit b41c1bdaa1df92ee6c510ae6749d0524b88ef828)

9 years agodoc: Update examples to use ctdb -X
Martin Schwenke [Thu, 20 Nov 2014 23:47:22 +0000 (10:47 +1100)]
doc: Update examples to use ctdb -X

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 0d61b6137306ee0eab2981e3c213023c332da550)

9 years agotool: Fix "ctdb -Y ifaces" output to have trailing delimiters
Martin Schwenke [Thu, 20 Nov 2014 23:45:57 +0000 (10:45 +1100)]
tool: Fix "ctdb -Y ifaces" output to have trailing delimiters

In the CTDB CLI tool source code and the documentation example.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 550fb8ce877cf980b4fd3be4f964449b369cf61e)

9 years agotests: Update integration tests to use ctdb -X
Martin Schwenke [Thu, 20 Nov 2014 04:03:25 +0000 (15:03 +1100)]
tests: Update integration tests to use ctdb -X

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 2c4de75d8754616891e97222cfb2ec58fdd8eac2)

9 years agotools: Update onnode and ctdb-diagnostics to use ctdb -X
Martin Schwenke [Thu, 20 Nov 2014 03:39:59 +0000 (14:39 +1100)]
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>
(Imported from commit 55df9c86c19e261a2a384ffc4b77c596c84e53a0)

9 years agoscripts: Update eventscripts to use ctdb -X instead of ctdb -Y
Martin Schwenke [Thu, 20 Nov 2014 03:32:46 +0000 (14:32 +1100)]
scripts: Update eventscripts to use ctdb -X instead of ctdb -Y

Also update associated eventscript unit tests and ctdb stub.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 4940f191d37b5deadc8b1edf0cd516674e5d5d64)

9 years agotools: Add -X option for machine parsable output with separator '|'
Martin Schwenke [Wed, 19 Nov 2014 07:19:50 +0000 (18:19 +1100)]
tools: Add -X option for machine parsable output with separator '|'

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 7428f809a76044fcbc98fd5f718e331ce183941d)

9 years agotools: Add -x option to specify delimiter for machine readable output
Martin Schwenke [Wed, 19 Nov 2014 06:15:21 +0000 (17:15 +1100)]
tools: Add -x option to specify delimiter for machine readable output

To support this, update printm() to replace ':' in format string with
options.machineseparator, which is a string but must contain a single
character.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 3b90e45bae555cc4a47fe9958b86628d41084868)

9 years agotools: Produce machine readable output with new function printm()
Martin Schwenke [Wed, 19 Nov 2014 05:35:35 +0000 (16:35 +1100)]
tools: Produce machine readable output with new function printm()

printm() is a printf(3) replacement and must be used to printing any
machine readable output.  It currently just calls vprintf(3).  Later
it will change the field delimiter.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit fbacbb9c7868e22c04980af3602bae59dd5fe34d)

9 years agotests: Make the fake log timestamp string easy to modify
Martin Schwenke [Wed, 24 Sep 2014 07:07:12 +0000 (17:07 +1000)]
tests: Make the fake log timestamp string easy to modify

Use a variable to allow easy change of this string in case future
logging changes modify the timestamp format or do not support
timestamping.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
(Imported from commit 1c8c0be6f97f74169c0b46be4df2245aa631186a)

9 years agotests: Clean up some tests where IP movement is checked
Martin Schwenke [Fri, 12 Sep 2014 03:20:43 +0000 (13:20 +1000)]
tests: Clean up some tests where IP movement is checked

Some of this implements logic that exists in functions.  Some of it is
overly complicated and potentially failure-prone.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 371543207e8955d6665fcec03b261d80cde2401b)

9 years agotests: Remove dependency on log ringbuffer from missing IP test
Martin Schwenke [Fri, 12 Sep 2014 05:21:49 +0000 (15:21 +1000)]
tests: Remove dependency on log ringbuffer from missing IP test

The log ringbuffer will probably be removed.  The test can be
implemented just as reliably by checking IP assignments using "ctdb
ip".

Update wait_until_ips_are_on_node() to print a more useful log
message.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 81a8758b9b24bbb7200be4682016f989b904bda8)

9 years agotests: Make all_ips_on_node() do what it should
Martin Schwenke [Wed, 17 Sep 2014 10:34:39 +0000 (20:34 +1000)]
tests: Make all_ips_on_node() do what it should

The "-n all" is wrong.

Simplify the implementation and tighten up some uses of this function.

_select_test_node_and_ips() can't use this function anymore.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit e3089d7da17e2f25d426005eca0fe55397f2689f)

9 years agotests: Factor out new function get_test_ip_mask_and_iface()
Martin Schwenke [Fri, 12 Sep 2014 03:40:01 +0000 (13:40 +1000)]
tests: Factor out new function get_test_ip_mask_and_iface()

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 81213af32ae17eaae33f9d27c9b7ce63c84ce5df)

9 years agotests: Simplify and rename wait_until_ips_are_on_nodeglob()
Martin Schwenke [Fri, 12 Sep 2014 03:34:51 +0000 (13:34 +1000)]
tests: Simplify and rename wait_until_ips_are_on_nodeglob()

The glob functionality is unsed so simplify the code by removing it.
Rename this function to wait_until_ips_are_on_node().  Update all
calls.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 4b8cfe4847477e3cfdb3f4dd7070226a6604bc38)

9 years agotests: Do not run ip command if running against local daemons
Amitay Isaacs [Tue, 8 Jul 2014 06:31:21 +0000 (16:31 +1000)]
tests: Do not run ip command if running against local daemons

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): Tue Jul  8 12:48:06 CEST 2014 on sn-devel-104

(Imported from commit bf7f2b06e8e36710d0f9bf0684e70538e809dd16)

9 years agoeventscripts: Fix regression in IP add/delete functions
Martin Schwenke [Fri, 14 Mar 2014 02:14:18 +0000 (13:14 +1100)]
eventscripts: Fix regression in IP add/delete functions

Commit 176ae6c704528c021fcc34a41878584f43a00119 caused these functions
to exit on failure.  This is incorrect and broke NAT gateway.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 058e14cdb0b6eb2e999dca599961ae6734105f99)

9 years agotests-eventscripts: Testing support for promote_secondaries
Martin Schwenke [Tue, 28 Jan 2014 05:08:50 +0000 (16:08 +1100)]
tests-eventscripts: Testing support for promote_secondaries

Just enable this behaviour by default in the ip command stub, since
10.interface assumes/sets it.  The rc.local replacement for set_proc()
doesn't do anything...

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit a226015990356ee989c5b9a472581bb3187de894)

9 years agoeventscripts: Deleting IPs should use the promote_secondaries option
Martin Schwenke [Tue, 28 Jan 2014 03:41:25 +0000 (14:41 +1100)]
eventscripts: Deleting IPs should use the promote_secondaries option

If a primary IP address is being deleted from an interface, the
secondaries are remembered and added back after the primary is
deleted.  This is done under a lock shared by the add/del script code.
It is necessary because, by default, Linux deletes secondaries when
the corresponding primary is deleted.

There is a race here between ctdbd and the scripts, since ctdbd
doesn't know about the lock.  If ctdbd receives a release IP control
and the IP address is not on an interface then it is regarded as a
"Redundant release of IP" so no "releaseip" event is generated.  This
can occur if the IP address in question is a secondary that has been
temporarily dropped.  It is more likely if the number of secondaries
is large.

Since Linux 2.6.12 (i.e. 2005) Linux has supported a
promote_secondaries option on interfaces.  This option is currently
undocumented but that will change in Linux 3.14.  With
promote_secondaries enabled the kernel will not drop secondaries but
will promote a corresponding secondary instead.  The kernel does all
necessary locking.

Use promote_secondaries to simplify the code, avoid re-adding
secondaries, avoid re-adding routes and provide improved performance.

This could be done conditionally, with a fallback to legacy
secondary-re-adding code, but no supported Linux distribution is
running a pre-2.6.12 kernel so this is unnecessary.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 176ae6c704528c021fcc34a41878584f43a00119)