The branch, master has been updated via 71080adfe0828e15bf2f4b0bee7d52e06fff3449 (commit) via 1bb814f012cb6ce436f8748b06602e8d6fae8822 (commit) via 999c68948da1492ac4d728c6bf79ad4921d9e840 (commit) via f527ffb55b514b5cb4df3471a0e17ab71307e8a1 (commit) via 1c9dadf02ca649e3f09d9edd778bf13e001aa849 (commit) via dda44d026e0c1b02feb02185b8c200a542be341a (commit) via edc34d01a1ad83b1335c976593a006166b196569 (commit) via 698af79545986cf788686feb06c4677a10eec770 (commit) via 69e240e15488e228c0232fdc8804af778cb4e6fc (commit) via 8f8dc5636436db28ce7d0edd706a4adf2624e71b (commit) via 80f14e590242b14829c6309ee908af0f2d33be1e (commit) via 0446eaa7798fd0ddf8d8f067c56d19892a13a317 (commit) via c490024aba39cf94cbc9f8f41ecb3d336b1c82a8 (commit) via f7de037e3be2e9910bee644dd1e93bae4912a194 (commit) via 20885d592040eb3945524c558b593a1d50a57b43 (commit) via b231aa629b909a7dfd071236c7e730e3cc4a1a54 (commit) via 0a08068f736efe56b4799e1f1f90539d257deb71 (commit) via 47f2843b4db767bcc724d8f972e0c2a850d5826f (commit) via 9e3e6ab3edf0f79d5973eb39ed843d3c369c665d (commit) via 3852c091f5e0ecba06b7131ca04b73a0cd632f23 (commit) via ef6131ecb068f7d8402cc782359509ba54b5adb0 (commit) via a1d424045c53f5b148952eade6161af8248ed4df (commit) via fcf40500c2158dfbe2390fad7bf0614cc575df14 (commit) via 1d02e3c6a7fb5ad5edb21298deba415ba9519f3d (commit) via 6ff9545a0fd58f0728b769c7b36d3b6ab7366321 (commit) via 59a1d54bcc15058f7b69e8596b32b26427a3ae57 (commit) via 9c6fd7d21c99e605e20620c5c6b4e695c02af771 (commit) via e9bdfd43af3ed28a7f69a36e3fb037f252a23869 (commit) via aedff41ee1df0a1a573476844993fa8eda2f34bf (commit) via f19ba38e382034fba769145d0bfc81b2c2941563 (commit) via ea0db472c2ce138c723aa7e633b72ac9d8b8a6a3 (commit) via fb3e123b097d9e36d281c3ab4f3e9a4799fa27bc (commit) via 08eeb788523afe19760b00f40339b702eb193712 (commit) via a779d83a6213e2ba21621f7e090964428f89422d (commit) via 5be904fb1fbd546618d25509b41ab836db62a70a (commit) via 220578bfd3507152b29ba4c28942f9d5e8733886 (commit) via 0564717fcc1e21688ae5dacbd437fd493bcb8853 (commit) via cc5bc1948dcbe8b8b25185260927b94a4b529174 (commit) via 36de7e7fd6dfeed61ef9977b8d5b568f90a9707b (commit) via e8d9c0b251c84d6fdf6ea7d972e5f7d1d0222f9b (commit) via 61000e38d6016e58f67e292393756d0bd5262ae5 (commit) via ef71b8290ae49117d7bcc7166598b77cb64cc8a0 (commit) via 1ccdae79b64b236fc27f4653606429d73c9c3595 (commit) from 392363c04185f47a826fc6ed95038342be2150bf (commit)
http://gitweb.samba.org/?p=ctdb.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 71080adfe0828e15bf2f4b0bee7d52e06fff3449 Merge: 1bb814f012cb6ce436f8748b06602e8d6fae8822 999c68948da1492ac4d728c6bf79ad4921d9e840 Author: Ronnie Sahlberg <ronniesahlb...@gmail.com> Date: Thu Sep 1 08:55:23 2011 +1000 Merge remote branch 'martins/tests' commit 1bb814f012cb6ce436f8748b06602e8d6fae8822 Merge: a779d83a6213e2ba21621f7e090964428f89422d dda44d026e0c1b02feb02185b8c200a542be341a Author: Ronnie Sahlberg <ronniesahlb...@gmail.com> Date: Thu Sep 1 08:52:48 2011 +1000 Merge remote branch 'martins/eventscripts' commit 999c68948da1492ac4d728c6bf79ad4921d9e840 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Aug 31 17:29:14 2011 +1000 Tests - eventscripts - add some multievent tests Running "./run_tests -s simple/* multievent/*" results in a stupid summary. Will need to work on that... Signed-off-by: Martin Schwenke <mar...@meltin.net> commit f527ffb55b514b5cb4df3471a0e17ab71307e8a1 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Aug 31 17:27:05 2011 +1000 Tests - eventscripts - allow "ctdb scriptstatus" output to be primed Signed-off-by: Martin Schwenke <mar...@meltin.net> commit 1c9dadf02ca649e3f09d9edd778bf13e001aa849 Merge: edc34d01a1ad83b1335c976593a006166b196569 dda44d026e0c1b02feb02185b8c200a542be341a Author: Martin Schwenke <mar...@meltin.net> Date: Wed Aug 31 15:38:55 2011 +1000 Merge branch 'eventscripts' into tests commit dda44d026e0c1b02feb02185b8c200a542be341a Author: Martin Schwenke <mar...@meltin.net> Date: Wed Aug 31 15:34:43 2011 +1000 Eventscripts - enhance ctdb_replay_monitor_status() Print useful output and return a suitable exit code. The DISABLED and TIMEDOUT statuses use fake negative return codes, and these can't be faked from the shell. So we map DISABLED to OK and TIMEDOUT to ERROR - this should avoid nearly all surprises. When we do this we add a note to the beginning of the output. The alternative is to "fix" ctdbd to use only codes that can actually be returned by shell scripts. However, the reason for using negative codes is probably to distinguish them from real ones... Signed-off-by: Martin Schwenke <mar...@meltin.net> commit edc34d01a1ad83b1335c976593a006166b196569 Author: Martin Schwenke <mar...@meltin.net> Date: Tue Aug 30 16:27:04 2011 +1000 Tests - eventscripts - ctdb stub - implement scriptstatus, tweaks Signed-off-by: Martin Schwenke <mar...@meltin.net> commit 698af79545986cf788686feb06c4677a10eec770 Author: Martin Schwenke <mar...@meltin.net> Date: Tue Aug 30 16:25:13 2011 +1000 Tests - eventscripts - formatting tweak in simple_test() Signed-off-by: Martin Schwenke <mar...@meltin.net> commit 69e240e15488e228c0232fdc8804af778cb4e6fc Author: Martin Schwenke <mar...@meltin.net> Date: Tue Aug 30 14:21:02 2011 +1000 Tests - eventscripts - new function simple_test_event() Just like simple_test() but 1st arg is the event name. Signed-off-by: Martin Schwenke <mar...@meltin.net> commit 8f8dc5636436db28ce7d0edd706a4adf2624e71b Author: Martin Schwenke <mar...@meltin.net> Date: Tue Aug 30 14:20:38 2011 +1000 Tests - eventscripts - output format tweaks Signed-off-by: Martin Schwenke <mar...@meltin.net> commit 80f14e590242b14829c6309ee908af0f2d33be1e Author: Martin Schwenke <mar...@meltin.net> Date: Tue Aug 30 14:19:09 2011 +1000 Tests - eventscripts - add extra filename format for multi-event tests $event may not be set so we need to test for it. Signed-off-by: Martin Schwenke <mar...@meltin.net> commit 0446eaa7798fd0ddf8d8f067c56d19892a13a317 Author: Martin Schwenke <mar...@meltin.net> Date: Tue Aug 30 14:16:28 2011 +1000 Tests - eventscripts - add die() function and use it Signed-off-by: Martin Schwenke <mar...@meltin.net> commit c490024aba39cf94cbc9f8f41ecb3d336b1c82a8 Author: Martin Schwenke <mar...@meltin.net> Date: Tue Aug 30 13:35:43 2011 +1000 Tests - eventscripts - remove undefined argument in some simple_test calls Signed-off-by: Martin Schwenke <mar...@meltin.net> commit f7de037e3be2e9910bee644dd1e93bae4912a194 Author: Martin Schwenke <mar...@meltin.net> Date: Tue Aug 23 13:53:39 2011 +1000 Tests - evenscripts - add symlink to ctdb.sysconfig Some of the tests expect the default to be CTDB_SERVICE_AUTOSTARTSTOP=yes Signed-off-by: Martin Schwenke <mar...@meltin.net> commit 20885d592040eb3945524c558b593a1d50a57b43 Author: Martin Schwenke <mar...@meltin.net> Date: Tue Aug 23 13:52:42 2011 +1000 Tests - eventscripts - Samba TCP port checking fixes Expect "ctdb checktcpport" to exit with 1 if not implemented. Signed-off-by: Martin Schwenke <mar...@meltin.net> commit b231aa629b909a7dfd071236c7e730e3cc4a1a54 Author: Martin Schwenke <mar...@meltin.net> Date: Mon Aug 22 16:41:01 2011 +1000 Tests - eventscripts - TCP port checking, no working checkers Signed-off-by: Martin Schwenke <mar...@meltin.net> commit 0a08068f736efe56b4799e1f1f90539d257deb71 Author: Martin Schwenke <mar...@meltin.net> Date: Mon Aug 22 16:37:22 2011 +1000 Tests - eventscripts - new Samba TCP port checking test - no nmap This one should fall back to netstat. Signed-off-by: Martin Schwenke <mar...@meltin.net> commit 47f2843b4db767bcc724d8f972e0c2a850d5826f Author: Martin Schwenke <mar...@meltin.net> Date: Mon Aug 22 16:14:55 2011 +1000 Tests - eventscripts - nmap and netstat stubs can pretend they weren't found Signed-off-by: Martin Schwenke <mar...@meltin.net> commit 9e3e6ab3edf0f79d5973eb39ed843d3c369c665d Author: Martin Schwenke <mar...@meltin.net> Date: Mon Aug 22 16:10:44 2011 +1000 Tests - eventscripts - new Samba tests to test TCP port checking Signed-off-by: Martin Schwenke <mar...@meltin.net> commit 3852c091f5e0ecba06b7131ca04b73a0cd632f23 Author: Martin Schwenke <mar...@meltin.net> Date: Mon Aug 22 16:06:16 2011 +1000 Tests - eventscripts - add a new ctdb_not_implemented() function This allowed a single ctdb command to be defined as not-implemented and provided the associated output from the ctdb stub in $ctdb_not_implemented. Signed-off-by: Martin Schwenke <mar...@meltin.net> commit ef6131ecb068f7d8402cc782359509ba54b5adb0 Author: Martin Schwenke <mar...@meltin.net> Date: Mon Aug 22 16:00:52 2011 +1000 Tests - eventscripts - new function setup_nmap_output_filter() Signed-off-by: Martin Schwenke <mar...@meltin.net> commit a1d424045c53f5b148952eade6161af8248ed4df Author: Martin Schwenke <mar...@meltin.net> Date: Mon Aug 22 16:07:36 2011 +1000 Tests - eventscripts - add some output filtering This allows $OUT_FILTER to be set to one or more sed commands to filter eventscript output. This allows expected output to be generalised. Signed-off-by: Martin Schwenke <mar...@meltin.net> commit fcf40500c2158dfbe2390fad7bf0614cc575df14 Author: Martin Schwenke <mar...@meltin.net> Date: Mon Aug 22 15:59:20 2011 +1000 Tests - eventscripts - ctdb default default level is 0. Signed-off-by: Martin Schwenke <mar...@meltin.net> commit 1d02e3c6a7fb5ad5edb21298deba415ba9519f3d Author: Martin Schwenke <mar...@meltin.net> Date: Mon Aug 22 15:58:23 2011 +1000 Tests - eventscripts - add output for "not implemented" in ctdb stub Signed-off-by: Martin Schwenke <mar...@meltin.net> commit 6ff9545a0fd58f0728b769c7b36d3b6ab7366321 Author: Martin Schwenke <mar...@meltin.net> Date: Mon Aug 22 15:56:57 2011 +1000 Tests - eventscripts - add an nmap stub Signed-off-by: Martin Schwenke <mar...@meltin.net> commit 59a1d54bcc15058f7b69e8596b32b26427a3ae57 Author: Martin Schwenke <mar...@meltin.net> Date: Fri Aug 19 16:51:08 2011 +1000 Tests - eventscripts - stop timeouts waiting for backgrounded testparm Not sleeping at all speeds up the tests. However, it can also cause timeouts. Therefore, every time sleep is run we force the stub to do a short 0.1s sleep instead of whatever is specified. This should be enough to avoid races. Signed-off-by: Martin Schwenke <mar...@meltin.net> commit 9c6fd7d21c99e605e20620c5c6b4e695c02af771 Author: Martin Schwenke <mar...@meltin.net> Date: Fri Aug 19 13:54:49 2011 +1000 Tests - add getdebug and checktcpport to ctdb eventscripts stub Signed-off-by: Martin Schwenke <mar...@meltin.net> commit e9bdfd43af3ed28a7f69a36e3fb037f252a23869 Author: Martin Schwenke <mar...@meltin.net> Date: Fri Aug 19 13:54:20 2011 +1000 Tests - add hooks to simulate ctdb commands that aren't implemented Signed-off-by: Martin Schwenke <mar...@meltin.net> commit aedff41ee1df0a1a573476844993fa8eda2f34bf Author: Martin Schwenke <mar...@meltin.net> Date: Fri Aug 19 13:53:05 2011 +1000 Tests - add eventscripts testing stub for sleep command. Signed-off-by: Martin Schwenke <mar...@meltin.net> commit f19ba38e382034fba769145d0bfc81b2c2941563 Author: Martin Schwenke <mar...@meltin.net> Date: Fri Aug 19 11:35:38 2011 +1000 Tests - Change variable used to fake listening TCP ports. Change from $FAKE_NETSTAT_TCP_LISTEN to $FAKE_TCP_LISTEN. Signed-off-by: Martin Schwenke <mar...@meltin.net> commit ea0db472c2ce138c723aa7e633b72ac9d8b8a6a3 Author: Martin Schwenke <mar...@meltin.net> Date: Fri Aug 19 11:24:56 2011 +1000 Tests - new NFS share checking tests Signed-off-by: Martin Schwenke <mar...@meltin.net> commit fb3e123b097d9e36d281c3ab4f3e9a4799fa27bc Author: Martin Schwenke <mar...@meltin.net> Date: Fri Aug 19 11:22:51 2011 +1000 Tests - eventscripts exportfs stub should splits lines The real exportfs splits lines longer than 15 characters. The stub should do that too... Signed-off-by: Martin Schwenke <mar...@meltin.net> commit 08eeb788523afe19760b00f40339b702eb193712 Author: Martin Schwenke <mar...@meltin.net> Date: Fri Aug 19 11:21:33 2011 +1000 Tests - add -T (trace) option to eventscripts run_test.sh Signed-off-by: Martin Schwenke <mar...@meltin.net> commit a779d83a6213e2ba21621f7e090964428f89422d Author: Martin Schwenke <mar...@meltin.net> Date: Tue Aug 30 16:37:04 2011 +1000 Tools - fix "ctdb scriptstatus -Y" output Lines in machine readable output always start with a colon (':'). Signed-off-by: Martin Schwenke <mar...@meltin.net> commit 5be904fb1fbd546618d25509b41ab836db62a70a Author: Martin Schwenke <mar...@meltin.net> Date: Tue Aug 30 16:31:17 2011 +1000 Eventscripts - use ctdb scriptstatus -Y when replaying status Signed-off-by: Martin Schwenke <mar...@meltin.net> commit 220578bfd3507152b29ba4c28942f9d5e8733886 Author: Martin Schwenke <mar...@meltin.net> Date: Mon May 16 14:23:28 2011 +1000 Eventscripts: add a synchronous synthetic reconfigure event. In the current code services can only be reconfigured asynchronously. This means that configuration file changes can be made, an asychronous reconfigure event can be triggered, and it always succeeds. Some time later when a service is actually reconfigured then a failure may be seen This adds a synthetic reconfigure event that reconfigures a service synchronously so that any failure is reported on exit. ctdb_service_check_reconfigure() is essentially reimplemented. If a reconfigure event is in flight and an ipreallocated or monitor event occurs then any scheduled asynchronous reconfigure is deferred until the next monitor cycle. This is to avoid reconfigures trampling on each other. In this case a monitor event will also replay the previous status to try to avoid exposing any temporary instability. If a reconfigure event collides with another reconfigure event it will exit with status 2, indicating that the reconfigure should be retried. The reconfigure event is implemented using a subprocess to control the exit from the synthetic event. As before, if a monitor event causes a scheduled synchronous reconfigure to occure then it will replay the previous status for the service, given that a reconfigure can cause temporary instability. Signed-off-by: Martin Schwenke <mar...@meltin.net> commit 0564717fcc1e21688ae5dacbd437fd493bcb8853 Author: Martin Schwenke <mar...@meltin.net> Date: Tue Aug 23 16:43:53 2011 +1000 Eventscripts - call ctdb_check_args() in 00.ctdb This is the first eventscript. Sanity check as early as possible and everyone benefits. Signed-off-by: Martin Schwenke <mar...@meltin.net> commit cc5bc1948dcbe8b8b25185260927b94a4b529174 Author: Martin Schwenke <mar...@meltin.net> Date: Tue Aug 23 16:36:19 2011 +1000 Eventscripts - call ctdb_check_args() instead of doing hand checking Signed-off-by: Martin Schwenke <mar...@meltin.net> commit 36de7e7fd6dfeed61ef9977b8d5b568f90a9707b Author: Martin Schwenke <mar...@meltin.net> Date: Tue Aug 23 16:32:34 2011 +1000 Eventscripts - new function ctdb_check_args() Pass this "$@" to do common eventscript argument checking. For regular use putting this in 00.ctdb would be enough. However, for developer testing it can be useful to call this in other eventscripts. For example, 10.interfaces and 13.per_ip_routing currently check these by hand. Signed-off-by: Martin Schwenke <mar...@meltin.net> commit e8d9c0b251c84d6fdf6ea7d972e5f7d1d0222f9b Author: Martin Schwenke <mar...@meltin.net> Date: Fri Aug 19 14:20:58 2011 +1000 Eventscripts - ctdb_check_tcp_ports() bug fix. Signed-off-by: Martin Schwenke <mar...@meltin.net> commit 61000e38d6016e58f67e292393756d0bd5262ae5 Author: Martin Schwenke <mar...@meltin.net> Date: Fri Aug 19 13:55:55 2011 +1000 Eventscripts - fix debugging buglet in ctdb_check_tcp_ports_ctdb() Signed-off-by: Martin Schwenke <mar...@meltin.net> commit ef71b8290ae49117d7bcc7166598b77cb64cc8a0 Author: Martin Schwenke <mar...@meltin.net> Date: Mon Aug 8 13:13:59 2011 +1000 Eventscripts: New configuration variable CTDB_SERVICE_AUTOSTARTSTOP. Some of the current auto-start/stop logic is broken, particularly for Samba. Fixing it is non-trivial. If $CTDB_SERVICE_AUTOSTARTSTOP is "yes" then auto-start/stop services when told to newly manage or no longer manage them. This defaults to "yes". However, if using a canned configuration file that doesn't set $CTDB_SERVICE_AUTOSTARTSTOP then this stops the auto-start-stop logic from working. Therefore, this works around CQ S1026685 - on the system in question another daemon controls service auto-start/stop and CTDB just gets in the way. Signed-off-by: Martin Schwenke <mar...@meltin.net> commit 1ccdae79b64b236fc27f4653606429d73c9c3595 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Aug 17 17:42:07 2011 +1000 Eventscripts - in 60.nfs uniquify the share check directory list There are sites that have multiple entries for the same export. This optimises the share check in this case. Signed-off-by: Martin Schwenke <mar...@meltin.net> ----------------------------------------------------------------------- Summary of changes: config/ctdb.sysconfig | 4 + config/events.d/00.ctdb | 2 + config/events.d/10.interface | 16 +-- config/events.d/13.per_ip_routing | 15 +-- config/events.d/60.nfs | 1 + config/functions | 166 +++++++++++++++++--- tests/eventscripts/common.sh | 136 ++++++++++++---- tests/eventscripts/etc/sysconfig/ctdb | 1 + tests/eventscripts/multievent/10.interface.001.sh | 14 ++ tests/eventscripts/multievent/60.nfs.001.sh | 21 +++ tests/eventscripts/multievent/60.nfs.002.sh | 25 +++ tests/eventscripts/multievent/60.nfs.003.sh | 27 +++ tests/eventscripts/multievent/60.nfs.004.sh | 27 +++ tests/eventscripts/multievent/60.nfs.005.sh | 27 +++ tests/eventscripts/multievent/60.nfs.006.sh | 21 +++ tests/eventscripts/run_tests.sh | 6 + tests/eventscripts/simple/40.vsftpd.monitor.001.sh | 2 +- tests/eventscripts/simple/41.httpd.monitor.001.sh | 2 +- tests/eventscripts/simple/50.samba.monitor.107.sh | 18 ++ tests/eventscripts/simple/50.samba.monitor.108.sh | 15 ++ tests/eventscripts/simple/50.samba.monitor.109.sh | 30 ++++ tests/eventscripts/simple/50.samba.monitor.110.sh | 33 ++++ tests/eventscripts/simple/50.samba.monitor.111.sh | 20 +++ tests/eventscripts/simple/60.nfs.monitor.161.sh | 13 ++ tests/eventscripts/simple/60.nfs.monitor.162.sh | 14 ++ tests/eventscripts/stubs/ctdb | 81 +++++++++-- tests/eventscripts/stubs/exportfs | 8 +- tests/eventscripts/stubs/netstat | 11 +- tests/eventscripts/stubs/nmap | 75 +++++++++ tests/eventscripts/stubs/sleep | 9 + tools/ctdb.c | 2 +- 31 files changed, 744 insertions(+), 98 deletions(-) create mode 120000 tests/eventscripts/etc/sysconfig/ctdb create mode 100755 tests/eventscripts/multievent/10.interface.001.sh create mode 100755 tests/eventscripts/multievent/60.nfs.001.sh create mode 100755 tests/eventscripts/multievent/60.nfs.002.sh create mode 100755 tests/eventscripts/multievent/60.nfs.003.sh create mode 100755 tests/eventscripts/multievent/60.nfs.004.sh create mode 100755 tests/eventscripts/multievent/60.nfs.005.sh create mode 100755 tests/eventscripts/multievent/60.nfs.006.sh create mode 100755 tests/eventscripts/simple/50.samba.monitor.107.sh create mode 100755 tests/eventscripts/simple/50.samba.monitor.108.sh create mode 100755 tests/eventscripts/simple/50.samba.monitor.109.sh create mode 100755 tests/eventscripts/simple/50.samba.monitor.110.sh create mode 100755 tests/eventscripts/simple/50.samba.monitor.111.sh create mode 100755 tests/eventscripts/simple/60.nfs.monitor.161.sh create mode 100755 tests/eventscripts/simple/60.nfs.monitor.162.sh create mode 100755 tests/eventscripts/stubs/nmap create mode 100755 tests/eventscripts/stubs/sleep Changeset truncated at 500 lines: diff --git a/config/ctdb.sysconfig b/config/ctdb.sysconfig index 5115094..163a0dd 100644 --- a/config/ctdb.sysconfig +++ b/config/ctdb.sysconfig @@ -295,6 +295,10 @@ CTDB_DEBUGLEVEL=ERR # above 90% # CTDB_CHECK_FS_USE="/:90 /var:90" +# Should CTDB automatically start and stop services when it is told to +# newly manage or no longer manage them? +CTDB_SERVICE_AUTOSTARTSTOP=yes + # # # set any default tuning options for ctdb diff --git a/config/events.d/00.ctdb b/config/events.d/00.ctdb index 321ba9c..2a48afb 100755 --- a/config/events.d/00.ctdb +++ b/config/events.d/00.ctdb @@ -35,6 +35,8 @@ update_config_from_tdb() { fi } +ctdb_check_args "$@" + case "$1" in init) # make sure we have a blank state directory for the scripts to work with diff --git a/config/events.d/10.interface b/config/events.d/10.interface index f75e6af..356ee08 100755 --- a/config/events.d/10.interface +++ b/config/events.d/10.interface @@ -129,6 +129,8 @@ monitor_interfaces() return 1 } +ctdb_check_args "$@" + case "$1" in ############################# # called when ctdbd starts up @@ -158,10 +160,6 @@ case "$1" in ################################################ # called when ctdbd wants to claim an IP address takeip) - if [ $# != 4 ]; then - echo "ERROR: must supply interface, IP and maskbits" - exit 1 - fi iface=$2 ip=$3 maskbits=$4 @@ -181,11 +179,6 @@ case "$1" in ################################################## # called when ctdbd wants to release an IP address releaseip) - if [ $# != 4 ]; then - echo "ERROR: must supply interface, IP and maskbits" - exit 1 - fi - # releasing an IP is a bit more complex than it seems. Once the IP # is released, any open tcp connections to that IP on this host will end # up being stuck. Some of them (such as NFS connections) will be unkillable @@ -220,11 +213,6 @@ case "$1" in ################################################## # called when ctdbd wants to update an IP address updateip) - if [ $# != 5 ]; then - echo "ERROR: must supply old interface, new interface, IP and maskbits" - exit 1 - fi - # moving an IP is a bit more complex than it seems. # First we drop all traffic on the old interface. # Then we try to add the ip to the new interface and before diff --git a/config/events.d/13.per_ip_routing b/config/events.d/13.per_ip_routing index ff4dbdb..d8a0644 100755 --- a/config/events.d/13.per_ip_routing +++ b/config/events.d/13.per_ip_routing @@ -326,6 +326,8 @@ setup_per_ip_routing() return $?; } +ctdb_check_args "$@" + case "$1" in ############################# # called when ctdbd starts up @@ -368,10 +370,6 @@ case "$1" in ################################################ # called when ctdbd wants to claim an IP address takeip) - if [ $# != 4 ]; then - echo "must supply interface, IP and maskbits" - exit 1 - fi iface=$2 ip=$3 maskbits=$4 @@ -410,10 +408,6 @@ case "$1" in ################################################ # called when ctdbd wants to claim an IP address updateip) - if [ $# != 5 ]; then - echo "must supply old interface, new interface, IP and maskbits" - exit 1 - fi oiface=$2 niface=$3 ip=$4 @@ -455,11 +449,6 @@ case "$1" in ################################################## # called when ctdbd wants to release an IP address releaseip) - if [ $# != 4 ]; then - echo "must supply interface, IP and maskbits" - exit 1 - fi - iface=$2 ip=$3 maskbits=$4 diff --git a/config/events.d/60.nfs b/config/events.d/60.nfs index 87a91df..e8ac61f 100755 --- a/config/events.d/60.nfs +++ b/config/events.d/60.nfs @@ -70,6 +70,7 @@ case "$1" in [ "$CTDB_NFS_SKIP_SHARE_CHECK" = "yes" ] || { exportfs -v | grep '^/' | sed -r -e 's@[[:space:]]+[^[:space:]()]+\([^[:space:]()]+\)$@@' | + sort -u | ctdb_check_directories } || exit $? diff --git a/config/functions b/config/functions index f656903..5ca7d8e 100755 --- a/config/functions +++ b/config/functions @@ -83,6 +83,26 @@ debug () } ############################################################## +# check number of args for different events +ctdb_check_args () +{ + case "$1" in + takeip|releaseip) + if [ $# != 4 ]; then + echo "ERROR: must supply interface, IP and maskbits" + exit 1 + fi + ;; + updateip) + if [ $# != 5 ]; then + echo "ERROR: must supply old interface, new interface, IP and maskbits" + exit 1 + fi + ;; + esac +} + +############################################################## # determine on what type of system (init style) we are running detect_init_style() { # only do detection if not already set: @@ -358,6 +378,7 @@ ctdb_check_tcp_ports() ctdb_check_tcp_ports_$_c "$@" case "$?" in 0) + _ctdb_check_tcp_common rm -f "$_ctdb_service_started_file" return 0 ;; @@ -466,7 +487,8 @@ ctdb_check_tcp_ports_ctdb () for _p ; do # process each function argument (port) _cmd="ctdb checktcpport $_p" _out=$($_cmd 2>&1) - case "$?" in + _ret=$? + case "$_ret" in 0) ctdb_check_tcp_ports_debug="\"$_cmd\" was able to bind to port" return 1 @@ -476,7 +498,7 @@ ctdb_check_tcp_ports_ctdb () continue ;; *) - ctdb_check_tcp_ports_debug="$_cmd (exited with $?) with output: + ctdb_check_tcp_ports_debug="$_cmd (exited with $_ret) with output: $_out" # assume not implemented return 127 @@ -992,7 +1014,7 @@ ctdb_service_unset_reconfigure () ctdb_service_reconfigure () { - echo "Reconfiguring service \"$service_name\"..." + echo "Reconfiguring service \"$@\"..." ctdb_service_unset_reconfigure "$@" service_reconfigure "$@" || return $? ctdb_counter_init "$@" @@ -1004,28 +1026,129 @@ service_reconfigure () service "${1:-$service_name}" restart } -ctdb_service_check_reconfigure () +ctdb_reconfigure_try_lock () { - # Only do this for certain events. - case "$event_name" in - monitor|ipreallocated) : ;; - *) return 0 + + _ctdb_service_reconfigure_common "$@" + _lock="${_d}/reconfigure_lock" + touch "$_lock" + + ( + flock 0 + # This is overkill but will work if we need to extend this to + # allow certain events to run multiple times in parallel + # (e.g. takeip) and write multiple PIDs to the file. + read _locker_event + if [ -n "$_locker_event" ] ; then + while read _pid ; do + if [ -n "$_pid" -a "$_pid" != $$ ] && \ + kill -0 "$_pid" 2>/dev/null ; then + exit 1 + fi + done + fi + + printf "%s\n%s\n" "$event_name" $$ >"$_lock" + exit 0 + ) <"$_lock" +} + +ctdb_replay_monitor_status () +{ + echo "Replaying previous status for this script due to reconfigure..." + # Leading colon (':') is missing in some versions... + _out=$(ctdb scriptstatus -Y | grep -E "^:?monitor:${script_name}:") + # Output looks like this: + # :monitor:60.nfs:1:ERROR:1314764004.030861:1314764004.035514:foo bar: + # This is the cheapest way of getting fields in the middle. + set -- $(IFS=":" ; echo $_out) + _code="$3" + _status="$4" + # The error output field can include colons so we'll try to + # preserve them. The weak checking at the beginning tries to make + # this work for both broken (no leading ':') and fixed output. + _out="${_out%:}" + _err_out="${_out#*monitor:${script_name}:*:*:*:*:}" + case "$_status" in + OK) : ;; # Do nothing special. + TIMEDOUT) + # Recast this as an error, since we can't exit with the + # correct negative number. + _code=1 + _err_out="[Replay of TIMEDOUT scriptstatus - note incorrect return code.] ${_err_out}" + ;; + DISABLED) + # Recast this as an OK, since we can't exit with the + # correct negative number. + _code=0 + _err_out="[Replay of DISABLED scriptstatus - note incorrect return code.] ${_err_out}" + ;; + *) : ;; # Must be ERROR, do nothing special. esac + echo "$_err_out" + exit $_code +} - if ctdb_service_needs_reconfigure "$@" ; then - ctdb_service_reconfigure "$@" +ctdb_service_check_reconfigure () +{ + [ -n "$1" ] || set -- "$service_name" - # Fall through to non-monitor events. - [ "$event_name" = "monitor" ] || return 0 + # We only care about some events in this function. For others we + # return now. + case "$event_name" in + monitor|ipreallocated|reconfigure) : ;; + *) return 0 ;; + esac - # We don't want to proceed with the rest of the monitor event - # here, so we exit. However, if we exit 0 then, if the - # service was previously broken, we might return a false - # positive. So we simply retrieve the status of this script - # from the previous monitor loop and exit with that status. - ctdb scriptstatus | \ - grep -q -E "^${script_name}[[:space:]]+Status:OK[[:space:]]" - exit $? + if ctdb_reconfigure_try_lock "$@" ; then + # No events covered by this function are running, so proceed + # with gay abandon. + case "$event_name" in + reconfigure) + (ctdb_service_reconfigure "$@") + exit $? + ;; + ipreallocated) + if ctdb_service_needs_reconfigure "$@" ; then + ctdb_service_reconfigure "$@" + fi + ;; + monitor) + if ctdb_service_needs_reconfigure "$@" ; then + ctdb_service_reconfigure "$@" + # Given that the reconfigure might not have + # resulted in the service being stable yet, we + # replay the previous status since that's the best + # information we have. + ctdb_replay_monitor_status + fi + ;; + esac + else + # Somebody else is running an event we don't want to collide + # with. We proceed with caution. + case "$event_name" in + reconfigure) + # Tell whoever called us to retry. + exit 2 + ;; + ipreallocated) + # Defer any scheduled reconfigure and just run the + # rest of the ipreallocated event, as per the + # eventscript. There's an assumption here that the + # event doesn't depend on any scheduled reconfigure. + # This is true in the current code. + return 0 + ;; + monitor) + # There is most likely a reconfigure in progress so + # the service is possibly unstable. As above, we + # defer any scheduled reconfigured. We also replay + # the previous monitor status since that's the best + # information we have. + ctdb_replay_monitor_status + ;; + esac fi } @@ -1072,6 +1195,9 @@ is_ctdb_managed_service () ctdb_start_stop_service () { + # Do nothing unless configured to... + [ "$CTDB_SERVICE_AUTOSTARTSTOP" = "yes" ] || return 0 + _service_name="${1:-${service_name}}" [ "$event_name" = "monitor" ] || return 0 diff --git a/tests/eventscripts/common.sh b/tests/eventscripts/common.sh index ab7abb9..9003b39 100644 --- a/tests/eventscripts/common.sh +++ b/tests/eventscripts/common.sh @@ -1,5 +1,8 @@ # Hey Emacs, this is a -*- shell-script -*- !!! :-) +# Print a message and exit. +die () { echo "$@" >&2 ; exit 1 ; } + # Augment PATH with relevant stubs/ directories. We do this by actually # setting PATH, and also by setting $EVENTSCRIPTS_PATH and then # prepending that to $PATH in rc.local to avoid the PATH reset in @@ -30,8 +33,7 @@ if [ -d "${EVENTSCRIPTS_TESTCASE_DIR}/etc" ] ; then elif [ -d "${EVENTSCRIPTS_TESTS_DIR}/etc" ] ; then CTDB_ETCDIR="${EVENTSCRIPTS_TESTS_DIR}/etc" else - echo "Unable to set \$CTDB_ETCDIR" >&2 - exit 1 + die "Unable to set \$CTDB_ETCDIR" fi export CTDB_ETCDIR @@ -42,8 +44,7 @@ elif [ -d "${EVENTSCRIPTS_TESTCASE_DIR}/etc/ctdb" ] ; then elif [ -d "${EVENTSCRIPTS_TESTS_DIR}/etc-ctdb" ] ; then CTDB_BASE="${EVENTSCRIPTS_TESTS_DIR}/etc-ctdb" else - echo "Unable to set \$CTDB_BASE" >&2 - exit 1 + die "Unable to set \$CTDB_BASE" fi export CTDB_BASE @@ -109,7 +110,7 @@ tcp_port_down () { for _i ; do debug "Marking TCP port \"${_i}\" as not listening" - FAKE_NETSTAT_TCP_LISTEN=$(echo "$FAKE_NETSTAT_TCP_LISTEN" | sed -r -e "s@[[:space:]]*[\.0-9]+:${_i}@@g") + FAKE_TCP_LISTEN=$(echo "$FAKE_TCP_LISTEN" | sed -r -e "s@[[:space:]]*[\.0-9]+:${_i}@@g") done } @@ -177,6 +178,11 @@ ethtool_interfaces_up () done } +setup_nmap_output_filter () +{ + OUT_FILTER="-e 's@^(DEBUG: # Nmap 5.21 scan initiated) .+ (as:)@\1 DATE \2@' -e 's@^(DEBUG: # Nmap done at) .+ (--)@\1 DATE \2@'" +} + ###################################################################### # CTDB fakery @@ -232,6 +238,10 @@ setup_ctdb () export FAKE_CTDB_NODES_DOWN="$EVENTSCRIPTS_TESTS_VAR_DIR/nodes-down" mkdir -p "$FAKE_CTDB_NODES_DOWN" rm -f "$FAKE_CTDB_NODES_DOWN"/* + + export FAKE_CTDB_SCRIPTSTATUS="$EVENTSCRIPTS_TESTS_VAR_DIR/scriptstatus" + mkdir -p "$FAKE_CTDB_SCRIPTSTATUS" + rm -f "$FAKE_CTDB_SCRIPTSTATUS"/* } @@ -280,6 +290,25 @@ ctdb_get_1_public_address () echo "${_addrs%% *}" | sed -r -e 's#(.*)/(.*)@(.*)#\3 \1 \2#g' } +ctdb_not_implemented () +{ + export CTDB_NOT_IMPLEMENTED="$1" + ctdb_not_implemented="\ +DEBUG: ctdb: command \"$1\" not implemented in stub" +} + +ctdb_fake_scriptstatus () +{ + _code="$1" + _status="$2" + _err_out="$3" + + _d1=$(date '+%s.%N') + _d2=$(date '+%s.%N') + + echo "$_code $_status $_err_out" >"$FAKE_CTDB_SCRIPTSTATUS/$script" +} + ###################################################################### # Samba fakery @@ -303,8 +332,13 @@ setup_samba () export CTDB_SAMBA_SKIP_SHARE_CHECK="no" export CTDB_MANAGED_SERVICES="foo samba winbind bar" - export FAKE_NETSTAT_TCP_LISTEN="0.0.0.0:445 0.0.0.0:139" + export FAKE_TCP_LISTEN="0.0.0.0:445 0.0.0.0:139" export FAKE_WBINFO_FAIL="no" + + # Some things in 50.samba are backgrounded and waited for. If + # we don't sleep at all then timeouts can happen. This avoids + # that... :-) + export FAKE_SLEEP_FORCE=0.1 else debug "Marking Samba services as down, not listening and not managed by CTDB" # Get into known state. @@ -321,7 +355,7 @@ setup_samba () unset CTDB_MANAGES_SAMBA unset CTDB_MANAGES_WINBIND - export FAKE_NETSTAT_TCP_LISTEN="" + export FAKE_TCP_LISTEN="" export FAKE_WBINFO_FAIL="yes" fi @@ -403,9 +437,7 @@ rpc_services_up () rquotad) _t="1:2" ;; nlockmgr) _t="3:4" ;; status) _t="1:1" ;; - *) - echo "Internal error - unsupported RPC service \"${_i}\"" - exit 1 + *) die "Internal error - unsupported RPC service \"${_i}\"" ;; esac FAKE_RPCINFO_SERVICES="${FAKE_RPCINFO_SERVICES}${FAKE_RPCINFO_SERVICES:+ }${_i}:${_t}" @@ -533,8 +565,7 @@ Starting nfslock: OK" setup_vsftpd () { if [ "$1" != "down" ] ; then - echo "setup_vsftpd up not implemented!!!" - exit 1 + die "setup_vsftpd up not implemented!!!" else debug "Setting up VSFTPD environment: service down, not managed by CTDB" @@ -553,8 +584,7 @@ setup_vsftpd () setup_httpd () { if [ "$1" != "down" ] ; then - echo "setup_httpd up not implemented!!!" -- CTDB repository