ctdb.git
12 years agoEventscripts: fix regression in 60.nfs export checking.
Martin Schwenke [Wed, 13 Apr 2011 02:37:42 +0000 (12:37 +1000)]
Eventscripts: fix regression in 60.nfs export checking.

Commit 35a60a63a9b5c7d98dde514ae552239506b691c9 introduced a
regression, reported by "Jonathan Buzzard" <J.Buzzard@dundee.ac.uk>,
as follows:

  Basically the use of sed in the following code snippet does not work
  for long exports where exportfs wraps the host or network onto the
  next line.

         exportfs | grep -v '^#' | grep '^/' |
         sed -e 's/[[:space:]]*[^[:space:]]*$//' |
         ctdb_check_directories

  The result is that the you get lots of blank lines being sent to
  ctdb_check_directories which causes the host to be marked as
  unhealthy and then thrashing sets in of the managed IP's making the
  whole cluster unusable.

This tightens up the sed expression so that it is less likely to
produce a spurious empty line.  It also removes an unnecessary "grep -v".

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoMerge remote branch 'martins/eventscript.10.interface'
Ronnie Sahlberg [Thu, 11 Aug 2011 04:15:22 +0000 (14:15 +1000)]
Merge remote branch 'martins/eventscript.10.interface'

12 years agoMerge remote branch 'martins/eventscript_infrastructure'
Ronnie Sahlberg [Thu, 11 Aug 2011 04:01:02 +0000 (14:01 +1000)]
Merge remote branch 'martins/eventscript_infrastructure'

12 years agoEventscripts: in 60.nfs move statd-notify code to service_reconfigure().
Martin Schwenke [Mon, 23 May 2011 06:00:05 +0000 (16:00 +1000)]
Eventscripts: in 60.nfs move statd-notify code to service_reconfigure().

This means that it now occurs on every reconfigure event.  As a result
the ipreallocated event is removed.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscripts - 60.nfs should define service_reconfigure().
Martin Schwenke [Thu, 11 Aug 2011 03:55:02 +0000 (13:55 +1000)]
Eventscripts - 60.nfs should define service_reconfigure().

Not $service_reconfigure.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoWhen starting and stopping ctdb through the init-script, make sure we first clear...
Ronnie Sahlberg [Thu, 11 Aug 2011 01:45:59 +0000 (11:45 +1000)]
When starting and stopping ctdb through the init-script, make sure we first clear all public ips bvefore we start the daemon, in case they are still hanging around since a previous kill -9   and also make sure we drop them after we have stopped the deamon when shutting down

CQ S1027550

12 years agoEvenscripts: improvements to ctdb_service_check_reconfigure().
Martin Schwenke [Thu, 13 Jan 2011 22:31:56 +0000 (09:31 +1100)]
Evenscripts: improvements to ctdb_service_check_reconfigure().

* Make this function applicable to "ipreallocated" event too.

* Monitor event should not always succeed just because we reconfigure.

  If the service was unhealthy before the reconfigure and we end the
  reconfigure with "exit 0" then we can cause the node's health status
  to flip-flop.

  To avoid this we return the status of the service from the previous
  monitor event.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscripts: 50.samba - only start/stop nmbd if $CTDB_SERVICE_NMB set.
Martin Schwenke [Fri, 27 May 2011 04:37:37 +0000 (14:37 +1000)]
Eventscripts: 50.samba - only start/stop nmbd if $CTDB_SERVICE_NMB set.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscripts: 50.samba needs null service_reconfigure() function.
Martin Schwenke [Mon, 23 May 2011 05:37:09 +0000 (15:37 +1000)]
Eventscripts: 50.samba needs null service_reconfigure() function.

Samba doesn't need to do anything for configuration changes.  It will
notice configuration changes and reload automatically.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscripts: 40.vsftpd service_stop() no longer /dev/null's output.
Martin Schwenke [Thu, 13 Jan 2011 22:42:18 +0000 (09:42 +1100)]
Eventscripts: 40.vsftpd service_stop() no longer /dev/null's output.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscripts: improvements to 41.httpd.
Martin Schwenke [Thu, 13 Jan 2011 22:43:01 +0000 (09:43 +1100)]
Eventscripts: improvements to 41.httpd.

* Reduce the failure counts so that restart attempts happen sooner.

* Use service_start() and service_stop() for the restart.
  ctdb_service_start() resets the failure count, which isn't very
  useful in this context.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscript functions: new function ctdb_check_counter().
Martin Schwenke [Fri, 17 Dec 2010 05:10:56 +0000 (16:10 +1100)]
Eventscript functions: new function ctdb_check_counter().

This should eventually be able to replace ctdb_check_counter_limit()
and ctdb_check_counter_equal(), although it doesn't issue warnings
like the former.

It takes 4 optional arguments:

1. _msg - If "error" then over limit causes an error message and and
   exit 1.  Anything else fails silently but the function returns 1.
   Default is "error".

2. _op - An integer operator supported by test (e.g. -eq, -ge, -gt).
   Default is -ge.

3. _limit - Limit for the counter to be used in comparison.  Default is
   $service_fail_limit.

4. _service_name - Used to identify the counter.  Default is
   $service_name.

For example:

  ctdb_check_counter error -ge 5 foo

will print a message and exit 1 if the counter for foo is >= 5,
whereas

  ctdb_check_counter check -ge 5 foo

will just return 1 if the counter for foo is >= 5, and

  ctdb_counter_check

with print a message and exit 1 if the counter for $service_name is >=
$service_fail_limit.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscripts: remove unused remove_ip() function.
Martin Schwenke [Tue, 28 Jun 2011 04:57:11 +0000 (14:57 +1000)]
Eventscripts: remove unused remove_ip() function.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscripts: startstop_nfs stop no longer redirects output to /dev/null.
Martin Schwenke [Thu, 13 Jan 2011 22:31:05 +0000 (09:31 +1100)]
Eventscripts: startstop_nfs stop no longer redirects output to /dev/null.

When stopping (as opposed to restarting) it is useful to see this
information.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscripts: fix typo in _ctdb_counter_common().
Martin Schwenke [Thu, 13 Jan 2011 22:29:16 +0000 (09:29 +1100)]
Eventscripts: fix typo in _ctdb_counter_common().

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscripts: improve log messages in ctdb_start_stop_service().
Martin Schwenke [Thu, 13 Jan 2011 22:30:21 +0000 (09:30 +1100)]
Eventscripts: improve log messages in ctdb_start_stop_service().

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscript functions: fix counter regression.
Martin Schwenke [Wed, 15 Dec 2010 23:11:33 +0000 (10:11 +1100)]
Eventscript functions: fix counter regression.

d362be7d32079ac1390d67056ce107bfbca2c937 wasn't well thought out.
Subsequent commits depend on ctdb_counter_init() taking an argument,
so this makes those cases work.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscript functions: ctdb_service_check-reconfigure() acts only on monitor.
Martin Schwenke [Wed, 15 Dec 2010 22:50:44 +0000 (09:50 +1100)]
Eventscript functions: ctdb_service_check-reconfigure() acts only on monitor.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscripts: make 50.samba use $service_state_dir.
Martin Schwenke [Fri, 17 Dec 2010 05:29:21 +0000 (16:29 +1100)]
Eventscripts: make 50.samba use $service_state_dir.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEvenscripts: update 60.nfs to use ctdb_service_check_reconfigure.
Martin Schwenke [Wed, 15 Dec 2010 22:45:28 +0000 (09:45 +1100)]
Evenscripts: update 60.nfs to use ctdb_service_check_reconfigure.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEvenscripts: update 60.nfs to use ctdb_setup_service_state_dir.
Martin Schwenke [Wed, 15 Dec 2010 21:57:46 +0000 (08:57 +1100)]
Evenscripts: update 60.nfs to use ctdb_setup_service_state_dir.

The state directory basename becomes "nfs" rather than "statd".  One
line of code i moved from the "startup" event to service_start().

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEvenscripts: update 40.vsftpd to use ctdb_service_check_reconfigure.
Martin Schwenke [Wed, 15 Dec 2010 22:48:25 +0000 (09:48 +1100)]
Evenscripts: update 40.vsftpd to use ctdb_service_check_reconfigure.

To simplify we also remove the reconfigure from the recovered event
because the monitor event will handle this very quickly anyway.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEvenscripts: update 41.httpd to use ctdb_service_check_reconfigure.
Martin Schwenke [Wed, 15 Dec 2010 22:47:10 +0000 (09:47 +1100)]
Evenscripts: update 41.httpd to use ctdb_service_check_reconfigure.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscripts: rejig the reconfigure infrastructure.
Martin Schwenke [Wed, 15 Dec 2010 08:19:21 +0000 (19:19 +1100)]
Eventscripts: rejig the reconfigure infrastructure.

* Add an optional service name argument to existing reconfigure
  functions.

* User function service_reconfigure() instead of variable
  $service_reconfigure to specify how a service is reconfigured.

* New function ctdb_service_check_reconfigure() reconfigures a service
  if it is flagged for reconfigure.

* Remove $service_reconfigure settings from 40.vsftpd and 41.httpd -
  they're the defaults.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscript functions: move flagging of managed services.
Martin Schwenke [Wed, 15 Dec 2010 05:34:00 +0000 (16:34 +1100)]
Eventscript functions: move flagging of managed services.

Move flagging of managed or unmanaged services into
ctdb_service_start() and ctdb_service_stop().  That way services will
be correctly flagged if they are started from the startup and shutdown
events.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscript function: change service_start into a function.
Martin Schwenke [Wed, 10 Aug 2011 23:39:25 +0000 (09:39 +1000)]
Eventscript function: change service_start into a function.

service_start is currently a variable.  This makes passing arguments
hard.  We change it to be a function and put default definitions into
the functions file.

We use a convention that if a service name argument is passed to a
redefined version of service_start() or service_stop() then it will
act unconditionally.  If no argument is passed then it can use
internal logic to decide if services should really be started.  This
is useful when a single eventscript handles multiple services.

This is a cherry-pick of ae38895 that needed to be reset mid-stream.
There is still some breakage following this commit.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscript functions: add optional event name argument to fail count functions.
Martin Schwenke [Tue, 14 Dec 2010 23:48:00 +0000 (10:48 +1100)]
Eventscript functions: add optional event name argument to fail count functions.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscript functions - optimise is_ctdb_managed_service().
Martin Schwenke [Thu, 18 Nov 2010 05:19:45 +0000 (16:19 +1100)]
Eventscript functions - optimise is_ctdb_managed_service().

This function generates a lot of trace when running under "set -x".
This is due to the backward compatibility code.

This adds 3 optimisations:

1. Before invoking the backward compatiblity code,
   is_ctdb_managed_service() returns early if the service is listed in
   $CTDB_MANAGED_SERVICES.

2. ctdb_compat_managed_service() actually now updates
   $CTDB_MANAGED_SERVICES instead of temporary variable $t.

   This means that a subsequent call to is_ctdb_managed_service() will
   short circuit due to optimisation (1).

3. ctdb_compat_managed_service() only adds a service to
   $CTDB_MANAGED_SERVICES if it is the service being checked by
   is_ctdb_managed_service().

   This stops irrelevant services being added to
   $CTDB_MANAGED_SERVICES multiple times by multiple calls to
   is_ctdb_managed_service().

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years ago50.samba eventscript should use is_ctdb_managed_service "winbind".
Martin Schwenke [Thu, 18 Nov 2010 05:03:47 +0000 (16:03 +1100)]
50.samba eventscript should use is_ctdb_managed_service "winbind".

Currently it checks $CTDB_MANAGES_WINBIND directly in several places.
This doesn't work when someone sets $CTDB_MANAGED_SERVICES directly.

This modifies check_ctdb_manages_winbind() so that it return a
condition rather than modifying $CTDB_MANAGES_WINBIND.  This makes
some code more readable.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years ago50.samba eventscript should use is_ctdb_managed_service "samba".
Martin Schwenke [Thu, 18 Nov 2010 03:34:48 +0000 (14:34 +1100)]
50.samba eventscript should use is_ctdb_managed_service "samba".

Currently it checks $CTDB_MANAGES_SAMBA directly.  This doesn't work
when someone sets $CTDB_MANAGED_SERVICES directly.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years ago50.samba eventscript should stop/start services when they become (un)managed.
Martin Schwenke [Thu, 18 Nov 2010 00:04:52 +0000 (11:04 +1100)]
50.samba eventscript should stop/start services when they become (un)managed.

When the value of $CTDB_MANAGES_SAMBA or $CTDB_MANAGES_WINBIND (or
corresponding changes are made to $CTDB_MANAGED_VERSIONS), the
associated service should be started or stopped as necessary.

This add calls to ctdb_start_stop_service() to manage
starting/stopping samba and winbind.

An associated cleanup is made to the initial checks that one of
$CTDB_MANAGES_SAMBA or $CTDB_MANAGES_WINBIND is set, replacing them
with calls to is_ctdb_managed_service().

To handle the winbind cases ctdb_start_stop_service() and
is_ctdb_managed_service() are updated to take an optional service name
parameter.

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

config/events.d/50.samba

Most of this merged elsewhere.  This just removes a check that
this is the monitor event.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoAdd documentation for the new filesystem use monitoring
Ronnie Sahlberg [Thu, 11 Aug 2011 00:07:50 +0000 (10:07 +1000)]
Add documentation for the new filesystem use monitoring

12 years agoAdd new eventscript 40.fs_use that can be used to monitor file system use and flag...
Ronnie Sahlberg [Thu, 11 Aug 2011 00:00:53 +0000 (10:00 +1000)]
Add new eventscript 40.fs_use that can be used to monitor file system use and flag a node unhealthy when they become full

12 years agomake the persistent even longer for lvs to make people even happier
Ronnie Sahlberg [Wed, 10 Aug 2011 23:11:38 +0000 (09:11 +1000)]
make the persistent even longer for lvs to make people even happier

12 years agoincrease the persistent timeout to make people happier
Ronnie Sahlberg [Wed, 10 Aug 2011 21:14:57 +0000 (07:14 +1000)]
increase the persistent timeout to make people happier

12 years agocheck the shares if they are available before we decide to try to restart nfs
Ronnie Sahlberg [Wed, 10 Aug 2011 21:13:28 +0000 (07:13 +1000)]
check the shares if they are available before we decide to try to restart nfs

CQ S1027529

12 years agoEventscripts - fix 10.interface bash incompatibility.
Martin Schwenke [Wed, 10 Aug 2011 06:06:26 +0000 (16:06 +1000)]
Eventscripts - fix 10.interface bash incompatibility.

In dash, this fails gracefully with nothing to stderr:

  t=$(cat /does_not_exist) 2>/dev/null

In bash the error from cat is still printed due to different order of
evaluation.

This works everywhere:

  t=$(cat /does_not_exist 2>/dev/null)

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoMerge remote branch 'martins/eventscript.00.ctdb'
Ronnie Sahlberg [Wed, 10 Aug 2011 05:36:20 +0000 (15:36 +1000)]
Merge remote branch 'martins/eventscript.00.ctdb'

12 years agoMerge branch 'eventscript.20.multipathd' into eventscript.00.ctdb
Martin Schwenke [Wed, 10 Aug 2011 05:32:58 +0000 (15:32 +1000)]
Merge branch 'eventscript.20.multipathd' into eventscript.00.ctdb

12 years agoMerge remote branch 'martins/eventscript.20.multipathd'
Ronnie Sahlberg [Wed, 10 Aug 2011 05:32:24 +0000 (15:32 +1000)]
Merge remote branch 'martins/eventscript.20.multipathd'

12 years agoMerge branch 'eventscript.62.cnfs' into eventscript.20.multipathd
Martin Schwenke [Wed, 10 Aug 2011 05:32:11 +0000 (15:32 +1000)]
Merge branch 'eventscript.62.cnfs' into eventscript.20.multipathd

12 years agoMerge remote branch 'martins/eventscript.62.cnfs'
Ronnie Sahlberg [Wed, 10 Aug 2011 05:31:56 +0000 (15:31 +1000)]
Merge remote branch 'martins/eventscript.62.cnfs'

12 years agoMerge branch 'eventscript.13.per_ip_routing' into eventscript.62.cnfs
Martin Schwenke [Wed, 10 Aug 2011 05:31:13 +0000 (15:31 +1000)]
Merge branch 'eventscript.13.per_ip_routing' into eventscript.62.cnfs

12 years agoMerge remote branch 'martins/eventscript.13.per_ip_routing'
Ronnie Sahlberg [Wed, 10 Aug 2011 05:22:46 +0000 (15:22 +1000)]
Merge remote branch 'martins/eventscript.13.per_ip_routing'

12 years agoMerge remote branch 'martins/eventscript_tests'
Ronnie Sahlberg [Wed, 10 Aug 2011 05:18:16 +0000 (15:18 +1000)]
Merge remote branch 'martins/eventscript_tests'

12 years agoMerge remote branch 'martins/eventscripts_relative'
Ronnie Sahlberg [Wed, 10 Aug 2011 05:15:12 +0000 (15:15 +1000)]
Merge remote branch 'martins/eventscripts_relative'

12 years agoMerge remote branch 'martins/test_suite'
Ronnie Sahlberg [Wed, 10 Aug 2011 05:11:00 +0000 (15:11 +1000)]
Merge remote branch 'martins/test_suite'

12 years agoEvenscripts: update 61.cnfs to use ctdb_setup_service_state_dir.
Martin Schwenke [Wed, 15 Dec 2010 21:48:21 +0000 (08:48 +1100)]
Evenscripts: update 61.cnfs to use ctdb_setup_service_state_dir.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEvenscripts: update 13.per_ip_routing to use ctdb_setup_service_state_dir.
Martin Schwenke [Wed, 15 Dec 2010 21:42:44 +0000 (08:42 +1100)]
Evenscripts: update 13.per_ip_routing to use ctdb_setup_service_state_dir.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEvenscripts: update 20.multipathd to use ctdb_setup_service_state_dir.
Martin Schwenke [Wed, 15 Dec 2010 21:45:28 +0000 (08:45 +1100)]
Evenscripts: update 20.multipathd to use ctdb_setup_service_state_dir.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscripts: fix dangerous rm -rf in 00.ctdb init event.
Martin Schwenke [Fri, 17 Dec 2010 05:23:31 +0000 (16:23 +1100)]
Eventscripts: fix dangerous rm -rf in 00.ctdb init event.

Also remove some unnecessary absolute paths for commands, which were
making the code slightly difficult to read.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscripts: 00.ctdb uses $service_state_dir, neaten update_config_from_tdb().
Martin Schwenke [Fri, 17 Dec 2010 05:21:53 +0000 (16:21 +1100)]
Eventscripts: 00.ctdb uses $service_state_dir, neaten update_config_from_tdb().

This also fixes a bug where update_config_from_tdb() used an incorrect
filename in one place.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years ago00.ctdb eventscript removes all files from $ctdb_active_dir.
Martin Schwenke [Fri, 19 Nov 2010 03:32:28 +0000 (14:32 +1100)]
00.ctdb eventscript removes all files from $ctdb_active_dir.

Without this you can get into a situation where ctdbd can not start.
If the active file for a service exists but the service is not
running, then trying to stop the service may fail, causing the
eventscript to exit from ctdb_start_stop_service().

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoScripts: add note about not using absolute command paths to README.
Martin Schwenke [Tue, 28 Jun 2011 07:29:49 +0000 (17:29 +1000)]
Scripts: add note about not using absolute command paths to README.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoAdd a README to the config/ subdirectory.
Martin Schwenke [Tue, 28 Jun 2011 05:19:34 +0000 (15:19 +1000)]
Add a README to the config/ subdirectory.

This includes a comment about using POSIX Bourne shell, including a
suggestion not to use "local" variables.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscript functions: new function ctdb_setup_service_state_dir().
Martin Schwenke [Tue, 14 Dec 2010 23:49:48 +0000 (10:49 +1100)]
Eventscript functions: new function ctdb_setup_service_state_dir().

To be used by eventscripts to create a per-service directory for their
own state data.  $service_state_dir is set to point to the new
directory.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscript functions: new functions to remember/check if service managed.
Martin Schwenke [Tue, 14 Dec 2010 23:45:17 +0000 (10:45 +1100)]
Eventscript functions: new functions to remember/check if service managed.

This was done ad hoc and was badly named.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoMerge branch 'test_suite' into ronnie_target
Martin Schwenke [Tue, 9 Aug 2011 03:12:08 +0000 (13:12 +1000)]
Merge branch 'test_suite' into ronnie_target

12 years agoMerge branch 'eventscript_tests' into ronnie_target
Martin Schwenke [Tue, 9 Aug 2011 03:11:38 +0000 (13:11 +1000)]
Merge branch 'eventscript_tests' into ronnie_target

12 years agoTest suite: print debug output after cluster (un)healthy flip-flop on restart.
Martin Schwenke [Tue, 12 Oct 2010 05:49:42 +0000 (16:49 +1100)]
Test suite: print debug output after cluster (un)healthy flip-flop on restart.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoAllow proxy_node to be specified for wait_until_node_has_status().
Martin Schwenke [Fri, 11 Feb 2011 04:13:37 +0000 (15:13 +1100)]
Allow proxy_node to be specified for wait_until_node_has_status().

Default to "any"... but allow specification because sometimes it
matters...

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoTest suite: Fix consistency in 26_ctdb_config_check_error_on_unreachable.
Martin Schwenke [Fri, 11 Feb 2011 04:14:46 +0000 (15:14 +1100)]
Test suite: Fix consistency in 26_ctdb_config_check_error_on_unreachable.

The test currently waits until any node thinks that the test node is
disconnected, and then uses node 0 as a proxy for testing.  However,
nodes may notice at different times that a node is disconnected, so
this test can fail unnecessarily.

We force the proxy node for the wait-until-disconnected to be the same
as the proxy node used to launch the actual tests.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoTest suite: Fix consistency in 09_ctdb_ping.sh.
Martin Schwenke [Wed, 16 Feb 2011 20:03:19 +0000 (07:03 +1100)]
Test suite: Fix consistency in 09_ctdb_ping.sh.

Same problem as described in commit
283a85b42d9c0a26acb64d5abcc7f175e31e6e75.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoTest suite: Strip architecture suffix from CTDB RPM package version.
Martin Schwenke [Wed, 13 Apr 2011 06:22:02 +0000 (16:22 +1000)]
Test suite: Strip architecture suffix from CTDB RPM package version.

Later versions of RPM seem to include it but we don't want it.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoTest suite: remove getmonmode test.
Martin Schwenke [Wed, 11 May 2011 05:14:16 +0000 (15:14 +1000)]
Test suite: remove getmonmode test.

This can't be made 100% reliable since the monitor mode can change
underneath us due to some event.  Therefore, the test is useless.

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

tests/simple/20_ctdb_getmonmode.sh

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoTest suite: Try much harder to get a healthy cluster when it is restarted.
Martin Schwenke [Tue, 12 Oct 2010 04:10:43 +0000 (15:10 +1100)]
Test suite: Try much harder to get a healthy cluster when it is restarted.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoTests - Disable the Samba and NFS eventscript tests.
Martin Schwenke [Mon, 8 Aug 2011 06:11:14 +0000 (16:11 +1000)]
Tests - Disable the Samba and NFS eventscript tests.

They're broken and not worth fixing without infrastructure changes so
disable them by taking away the execute bit.  This is somewhat easier
than trying to merge in all the other tests but not these ones.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoTests - Tweak 10.interfaces 802.ad bonding test to work with current code.
Martin Schwenke [Mon, 8 Aug 2011 05:53:28 +0000 (15:53 +1000)]
Tests - Tweak 10.interfaces 802.ad bonding test to work with current code.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoScripts: remove absolute paths from interface_modify.sh.
Martin Schwenke [Tue, 28 Jun 2011 05:17:37 +0000 (15:17 +1000)]
Scripts: remove absolute paths from interface_modify.sh.

The "ip" command is currently run as "/sbin/ip".  This makes it
impossible to replace with a stub in unit testing.  The functions file
controls $PATH, so we don't need absolute paths.

This replaces the absolute paths...

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoScripts: remove absolute paths from interface_modify.sh.
Martin Schwenke [Tue, 28 Jun 2011 05:17:37 +0000 (15:17 +1000)]
Scripts: remove absolute paths from interface_modify.sh.

The "ip" command is currently run as "/sbin/ip".  This makes it
impossible to replace with a stub in unit testing.  The functions file
controls $PATH, so we don't need absolute paths.

This replaces the absolute paths...

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscripts - Remove local variable usage in 10.interfaces.
Martin Schwenke [Mon, 8 Aug 2011 05:44:30 +0000 (15:44 +1000)]
Eventscripts - Remove local variable usage in 10.interfaces.

POSIX sh doesn't have local variables.  Debian's dash doesn't behave
the same way as bash on this contruct:

  local var=`command that produces multiple words`

It only assigns the 1st word and may print an error.

Just remove the use of the "local" keyword in monitor_interfaces() to
solve this.  It isn't actually limiting the scope of any variables
that are used outside the function.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoTests - implement "ctdb -Y ip -v" in stub for eventscript testing.
Martin Schwenke [Mon, 8 Aug 2011 05:42:45 +0000 (15:42 +1000)]
Tests - implement "ctdb -Y ip -v" in stub for eventscript testing.

This is pretty limited but it gets 10.interfaces tests working.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoTests - stub ip program should assume interface name if "dev" not specified.
Martin Schwenke [Mon, 8 Aug 2011 04:45:30 +0000 (14:45 +1000)]
Tests - stub ip program should assume interface name if "dev" not specified.

Currently it fails if you don't use the "dev" keyword.

This makes it behave as expected.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscripts: source a file specified by $CTDB_RC_LOCAL in functions file.
Martin Schwenke [Tue, 28 Jun 2011 05:06:10 +0000 (15:06 +1000)]
Eventscripts: source a file specified by $CTDB_RC_LOCAL in functions file.

Another unit testing hook.  This is easier than dropping files into
rc.local.d/ and then removing them.

The file has to be executable.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoTests: update tests to work with previous commit.
Martin Schwenke [Tue, 5 Jul 2011 07:12:21 +0000 (17:12 +1000)]
Tests: update tests to work with previous commit.

Issues:

* 10.monitor no longer prints a message when there is no
  public_addresses file.

* Extra bonding test added to check workaround for IEEE 802.3ad
  Dynamic link aggregation bonding mode bug.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoTests: eventscripts and onnode tests use stubs/ subdirectory instead of bin/.
Martin Schwenke [Thu, 7 Jul 2011 06:17:52 +0000 (16:17 +1000)]
Tests: eventscripts and onnode tests use stubs/ subdirectory instead of bin/.

This sets up a more useful convention and avoids future .gitignore
problems.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoTests: tweak some samba tests to cope with debug from ctdb_check_tcp_ports().
Martin Schwenke [Tue, 5 Jul 2011 02:54:51 +0000 (12:54 +1000)]
Tests: tweak some samba tests to cope with debug from ctdb_check_tcp_ports().

This is a bit too static.  However, it can fixed up later if it is a
hassle.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoTests: Oops! Add bin directory for eventscript tests.
Martin Schwenke [Tue, 5 Jul 2011 02:53:20 +0000 (12:53 +1000)]
Tests: Oops!  Add bin directory for eventscript tests.

It was matched by .gitignore.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoGit should ignore tests/eventscripts/var.x
Martin Schwenke [Tue, 28 Jun 2011 07:30:45 +0000 (17:30 +1000)]
Git should ignore tests/eventscripts/var.x

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoTests: initial eventscript unit tests.
Martin Schwenke [Tue, 28 Jun 2011 07:29:13 +0000 (17:29 +1000)]
Tests: initial eventscript unit tests.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoMerge remote-tracking branch 'origin/master' into eventscripts_relative
Martin Schwenke [Mon, 8 Aug 2011 03:25:40 +0000 (13:25 +1000)]
Merge remote-tracking branch 'origin/master' into eventscripts_relative

12 years agoEventscript functions - use $CTDB_VARDIR instead of local $ctdb_spool_dir.
Martin Schwenke [Tue, 14 Dec 2010 23:21:39 +0000 (10:21 +1100)]
Eventscript functions - use $CTDB_VARDIR instead of local $ctdb_spool_dir.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoio: Make queue_io_read() safe for reentry
David Disseldorp [Sun, 31 Jul 2011 01:14:54 +0000 (03:14 +0200)]
io: Make queue_io_read() safe for reentry

queue_io_read() may be reentered via the queue callback, recoverd is
particularly guilty of this.

queue_io_read() is not safe for reentry if more than one packet is
received and partial chunks follow - data read off the pipe on re-entry
is assumed to be the start-of-packet four byte length. This leads to a
wrongly aligned stream and the notorious "Invalid packet of length 0"
errors.

This change fixes queue_io_read() to be safe under reentry, only a
single packet is processed per call.

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

12 years agoRemove a log message about setting linkstate for an unknown interface.
Ronnie Sahlberg [Fri, 5 Aug 2011 00:03:34 +0000 (10:03 +1000)]
Remove a log message about setting linkstate for an unknown interface.
sometimes we do want to try to set the linkstate for interfaces that are not in use by public addresses right now (but posisbly by other mechanisms) and these messages just spam the logs

S1026357

12 years agoEventscripts - remove some more absolute paths to commands.
Martin Schwenke [Thu, 4 Aug 2011 07:14:11 +0000 (17:14 +1000)]
Eventscripts - remove some more absolute paths to commands.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoremove log message we dont need
Ronnie Sahlberg [Thu, 4 Aug 2011 03:49:02 +0000 (13:49 +1000)]
remove log message we dont need

S1026492

12 years agoremove a non-error logmessage about persistent databases being healthy, as expected
Ronnie Sahlberg [Thu, 4 Aug 2011 03:47:52 +0000 (13:47 +1000)]
remove a non-error logmessage about persistent databases being healthy, as expected

S1026492

12 years agoremove a log message we dont need about "allow clients to attach to databases"
Ronnie Sahlberg [Thu, 4 Aug 2011 03:46:12 +0000 (13:46 +1000)]
remove a log message we dont need about "allow clients to attach to databases"

S1026492

12 years agoChange the message when we start the daemon to "CTDB starting on node"
Ronnie Sahlberg [Thu, 4 Aug 2011 03:44:25 +0000 (13:44 +1000)]
Change the message when we start the daemon to "CTDB starting on node"

S1026492

12 years agoEventscripts - Rework the use of get_proc() for the bonding checks.
Martin Schwenke [Wed, 3 Aug 2011 10:12:48 +0000 (20:12 +1000)]
Eventscripts - Rework the use of get_proc() for the bonding checks.

Call call_proc(), put the output into a variable and then use it.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscripts: update 60.nfs service() start to use set_proc().
Martin Schwenke [Tue, 28 Jun 2011 05:16:32 +0000 (15:16 +1000)]
Eventscripts: update 60.nfs service() start to use set_proc().

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscripts: update 10.interface to use set_proc() and get_proc().
Martin Schwenke [Tue, 28 Jun 2011 05:36:28 +0000 (15:36 +1000)]
Eventscripts: update 10.interface to use set_proc() and get_proc().

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscripts: use set_proc() in startstop_nfs().
Martin Schwenke [Tue, 28 Jun 2011 04:58:13 +0000 (14:58 +1000)]
Eventscripts: use set_proc() in startstop_nfs().

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscripts: remove unnecessary absolute paths from external commands.
Martin Schwenke [Wed, 13 Apr 2011 02:08:09 +0000 (12:08 +1000)]
Eventscripts: remove unnecessary absolute paths from external commands.

For eventscript unit testing it will be necessary to override external
commands to allow stub implementations to be used.  If absolute paths
aren't used then this can be done using either a fake bin/
subdirectory or by using shell functions.

This removes all of the simple cases of absolute paths.

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

config/ctdb.init
config/events.d/50.samba

        Keep old code but remove absolute paths.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscripts: new functions set_proc() and get_proc().
Martin Schwenke [Tue, 28 Jun 2011 04:54:33 +0000 (14:54 +1000)]
Eventscripts: new functions set_proc() and get_proc().

These provide a thin layer around writing and reading files in /proc.
They can be easily replaced by stubs for unit testing.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscripts: remove ctdb_wait_command() and ctdb_wait_tcp_ports() functions.
Martin Schwenke [Wed, 11 May 2011 05:18:11 +0000 (15:18 +1000)]
Eventscripts: remove ctdb_wait_command() and ctdb_wait_tcp_ports() functions.

These haven't been used for a long time.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoMerge remote branch 'martins/test_suite'
Ronnie Sahlberg [Wed, 3 Aug 2011 06:56:26 +0000 (16:56 +1000)]
Merge remote branch 'martins/test_suite'

12 years agoEventscripts: iptables() should put lock in $CTDB_VARDIR.
Martin Schwenke [Tue, 28 Jun 2011 05:04:58 +0000 (15:04 +1000)]
Eventscripts: iptables() should put lock in $CTDB_VARDIR.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoMake Emacs recognise that the eventscript functions file is a shell script.
Martin Schwenke [Wed, 1 Dec 2010 22:48:02 +0000 (09:48 +1100)]
Make Emacs recognise that the eventscript functions file is a shell script.

Signed-off-by: Martin Schwenke <martin@meltin.net>
12 years agoEventscript functions: add $CTDB_ETCDIR and hook service() functions.
Martin Schwenke [Tue, 7 Jun 2011 05:57:29 +0000 (15:57 +1000)]
Eventscript functions: add $CTDB_ETCDIR and hook service() functions.

* $CTDB_ETCDIR defaults to /etc but can be changed for testing.  All
  hard-coded instances of /etc have been changed to $CTDB_ETCDIR.
  This includes references to /etc/init.d and /etc/sysconfig.

* service() and nice_service() functions now call new function
  _service().  This makes it easier to override these functions (say,
  in rc.local) for testing and call most of the existing functionality
  using _service().

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