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

107 Commits

Author SHA1 Message Date
Martin Schwenke
a1e78cc372 ctdb-scripts: Drop uses of ctdbd_wrapper
The only value this now provides is use of a notification script to
log when start/stop are called.  This was used for debugging strange
start/stop failures, which have not been recently seen.  Also, systemd
does a good job of logging start/stop.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2022-04-06 06:34:37 +00:00
Martin Schwenke
b499775527 ctdb-scripts: Split CTDB configuration loading
loadconfig() currently tries to load the CTDB configuration and also
any system configuration relevant to the current (event) script.

Instead add a new function load_system_config() to load the
distribution-specific system configuration for a component.  Call this
directly in the rare scripts that need the system configuration.

Also call load_system_config when loading the CTDB configuration to
pull in anything from the CTDB system configuration.  This is partly
for backward compatibility but also to get options that can be used
anywhere.

loadconfig() no longer takes an argument.  It simply loads the CTDB
configuration.

Drop support for falling back to /etc/ctdb/sysconfig/ctdb (or
similar).  Surely there's nobody who uses that!

Also, drop the indirection where loadconfig() calls _loadconfig().
This was used years ago as a test hook and is no longer required.

Inexplicably, this change introduces a new shellcheck test failure, so
silence this.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-28 02:57:20 +02:00
Martin Schwenke
0ee7b8a669 ctdb-scripts: Drop CTDB_PIDFILE configuration option
Use environment variables for test-only options.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-19 02:23:17 +01:00
Martin Schwenke
52cdb03c65 ctdb-scripts: Drop PID file argument from wrapper
Use the default compile-time PID file.

Use a CTDB_PIDFILE environment variable when testing.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-09 07:08:25 +01:00
Martin Schwenke
a2c6c98302 ctdb-scripts: Drop init script PID directory backward compatibility
This tries to be backward compatible with very old versions of CTDB,
so don't bother.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-03-09 07:08:24 +01:00
Martin Schwenke
d7f3b1977f ctdb-scripts: Avoid shellcheck warning SC2039 (echo -n)
SC2039: In POSIX sh, echo flags are not supported.

echo -n is well supported but the changes are simple.

Improve some logic, replace some instances with printf.  Who knew
printf was in POSIX?

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Martin Schwenke
b0c1dbfb8f ctdb-scripts: Avoid shellcheck warning SC2015 (A && B || C)
SC2015: Note that A && B || C is not if-then-else. C may run when A is
true.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Martin Schwenke
9255d645f3 ctdb-scripts: Avoid shellcheck warnings SC2046, SC2086 (double-quoting)
SC2046: Quote this to prevent word splitting.
SC2086: Double quote to prevent globbing and word splitting.

Add some quoting where it makes sense.  Use shellcheck directives for
false-positives.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Mathieu Parent
cdf507c4b5 Add missing $remote_fs LSB dependency
(This used to be ctdb commit a0b965bb73777dde7a4abf80c5c4742581bce520)
2013-10-24 16:54:08 +11:00
Martin Schwenke
adbee6ae4e initscript: Simpify initscript and control CTDB via new ctdbd_wrapper
Currently the initscript is very complex.  This makes it hard to read
and hard to add support for new init systems, such as systemd.

Create a wrapper called ctdbd_wrapper to be installed alongside ctdbd.
This is called by the initscript to start and stop ctdbd.  It does the
ctdbd option construct and waits until ctdbd is properly initialised
before it exits.

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

(This used to be ctdb commit e3abc7eebab5cceddc4ce7817890dd5db9be3450)
2013-07-10 15:19:27 +10:00
Amitay Isaacs
ae0afad8ee initscript: Export CTDB_DEBUG_LOCKS variable
Signed-off-by: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit a415a1986900135f889efc25ecaf2761b1dae81a)
2013-07-10 14:33:18 +10:00
Martin Schwenke
6317285c4f scripts: Move TDB checking from initscript to "init" event
It makes sense to do this in the "init" event and make the initscript
less complicated.

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

(This used to be ctdb commit 3bc93f312b8464fbfa2b2c44fffedc591fe5a3e0)
2013-06-20 13:01:10 +10:00
Martin Schwenke
961468146e scripts: Move dropping of all IPs from initscript to "init" event
It makes sense to do this in the "init" event and make the initscript
less complicated.

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

(This used to be ctdb commit 0b77cceb49a30a181063adc7868d42d2851318e8)
2013-06-20 13:01:09 +10:00
Martin Schwenke
a1eb516f0a scripts: drop_all_public_ips() now prints messages to stdout, not log
Change all callers to maintain current behaviour.

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

(This used to be ctdb commit 0b67397ef5419c781a35916575151da7b7e7cc27)
2013-06-20 13:01:09 +10:00
Martin Schwenke
6d9667f01c ctdbd: Add new runstate CTDB_RUNSTATE_FIRST_RECOVERY
This adds more serialisation to the startup, ensuring that the
"startup" event runs after everything to do with the first recovery
(including the "recovered" event).

Given that it now takes longer to get to the "startup" state, the
initscript needs to wait until ctdbd gets to "first_recovery".

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

(This used to be ctdb commit ed6814ff0a59ddbb1c1b3128b505380f60d7aeb7)
2013-05-24 14:08:07 +10:00
Martin Schwenke
b5ebff6931 tools/ctdb: "ctdb runstate" now accepts optional expected run state arguments
If one or more run states are specified then "ctdb runstate" succeeds
only if ctdbd is in one of those run states.

At the moment, if the "setup" event fails then the initscript succeeds
but ctdbd exits almost immediately.  This behaviour isn't very
friendly.

The initscript now waits until ctdbd is in "startup" or "running" run
state via the use of "ctdb runstate startup running", meaning that ctdbd
has successfully passed the "setup" event.

The "setup" event code in 00.ctdb now waits until ctdbd is in the
"setup" run state before proceeding via the use of "ctdb runstate setup".

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

(This used to be ctdb commit 4a2effcc455be67ff4a779a59ca81ba584312cd6)
2013-05-24 14:08:07 +10:00
Martin Schwenke
ff9831f5b1 initscript: If CTDB doesn't become ready, print a message before killing
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit e6b6b793f61556c21e8daf34abf89ee7b388ecfb)
2013-05-22 14:24:21 +10:00
Martin Schwenke
27a5b78c8e initscript: Look for tdbtool/tdbdump using which, not in fixed locations
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit c74cc0442eb90d859eae270b59456d28605817c4)
2013-05-06 15:40:30 +10:00
Martin Schwenke
823edbf6fe scripts: Ensure even external scripts get tagged in logs as "ctdbd"
Our practice is to search logs for "ctdbd:".  We want to make sure we
find everything.

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

(This used to be ctdb commit 5940a2494e9e43a83f2bca098bd04dfc1a8f2e93)
2013-04-22 13:58:36 +10:00
Martin Schwenke
d24077922f initscript: Remove duplicate setting of $ctdbd
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>

(This used to be ctdb commit e7a4b7e35a1e4b826846e2494a3803abb57065ee)
2013-04-18 13:22:12 +10:00
Martin Schwenke
38366b6b53 initscript: Use a PID file to implement the "status" option
Using "ctdb ping" and "ctdb status" is fraught with danger.  These
commands can timeout when ctdbd is running, leading callers to believe
that ctdbd is not running.  Timeouts could be increased but we would
still have to handle potential timeouts.

Everything else in the world implements the "status" option by
checking if the relevant process is running.  This change makes CTDB
do the same thing and uses standard distro functions.

This change is backward compatible in sense that a missing
/var/run/ctdb/ directory means that we don't do a PID file check but
just depend on the distro's checking method.  Therefore, if CTDB was
started with an older version of this script then "service ctdb
status" will still work.

This script does not support changing the value of CTDB_VALGRIND
between calls.  If you start with CTDB_VALGRIND=yes then you need to
check status with the same setting.  CTDB_VALGRIND is a debug
variable, so this is acceptable.

This also adds sourcing of /lib/lsb/init-functions to make the Debian
function status_of_proc() available.

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

(This used to be ctdb commit 687e2eace4f48400cf5029914f62b6ddabb85378)
2013-04-18 13:22:12 +10:00
Martin Schwenke
8c9eedbce3 initscript: export CTDB_EXTERNAL_TRACE
This means it can be set like any other configuration option in the
configuration file, without needing to export it there.

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

(This used to be ctdb commit a0ef73e197dc9147f7718e0813fe803ff0b3d54d)
2013-02-05 16:05:13 +11:00
Martin Schwenke
bc5f0a2b65 ctdbd: Remove command-line option --debug-hung-script
Use an environment variable instead.  This just means that the
initscript exports CTDB_DEBUG_HUNG_SCRIPT and the code checks for the
environment variable.

The justification for this simplification is that more debug options
will be arriving soon and we want to handle them consistently without
needing to add a command-line option for each.  So, the convention
will be to use an environment variable for each debug option.

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

(This used to be ctdb commit 0581f9a84e58764d194f4e04064c2c5b393c348b)
2013-02-05 16:05:13 +11:00
Martin Schwenke
0eb757329e scripts: Move drop_all_public_ips() to the functions file
... so it can be improved and used elsewhere.

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

(This used to be ctdb commit b23c30253cc9eb274b895cac0f8c65245ba0a200)
2013-01-08 15:18:46 +11:00
Martin Schwenke
df7152fe87 Initscript: when checking status, print output of "ctdb ping" if it fails
At the moment the caller has no idea why it thinks CTDB isn't running
and we can't debug failures...

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

(This used to be ctdb commit 776590bf84d221092298346a28d7fc0552a67c9d)
2013-01-07 10:35:38 +11:00
Martin Schwenke
9f6b30a517 scripts: Refactor logging code in initscript and functions file
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 5ee242c949a98bb7397e0f7368b20d44c06fe772)
2012-10-18 20:05:43 +11:00
Martin Schwenke
ad8eb45fe2 initscript: Check that rc.ctdb is executable before running it
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 59a47c0674bacfebc17a1b44f0244727bf2fa7a4)
2012-10-18 20:05:43 +11:00
Amitay Isaacs
ce210f6978 scripts: Remove duplicate code from init script to set tunables
The tunable variables defined in CTDB configuration file are currently
set up from init script as well as part of "setup" event in 00.ctdb
eventscript.  Remove the duplication of this code and set tunable
variables only from setup event.  During the "setup" event, it's possible
that ctdb tool commands can timeout if CTDB daemon is not ready.  To guard
against such eventuality, wait till "ctdb ping" command succeeds before
executing any other ctdb tool commands.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit 632c1b9c1cc2e242376358ce49fd2022b3f27aa2)
2012-10-17 11:32:41 +11:00
Martin Schwenke
e2d4250731 Initscript: Kill any existing ctdbd processes if the ping succeeds
Initialising a new ctdbd will destroy the Unix domain socket so
existing processes will be useless anyway.

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

(This used to be ctdb commit 043ef77086797a703aec436a26a05c56a1bcbf2b)
2012-10-02 17:37:53 +10:00
Martin Schwenke
748c3d7eb6 Initscript: clean up drop_all_public_ips()
This makes the case implicit where $CTDB_PUBLIC_ADDRESSES is unset.
This is OK because that's not an interesting code path.

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

(This used to be ctdb commit 5b2725d1ae052e848c2487cb10c5393a877d118c)
2012-07-26 22:05:43 +10:00
Ronnie Sahlberg
dce5969d12 Debug: When scripts hang, we may need to collect additional data in order to debug why the script hung.
Break this debug and datacollection out into an external script to make it easier to modify what data we need to collect.
For now we only collect a pstree so we can see what part of the script we hung in.

S1037271

(This used to be ctdb commit 6e68797af67bee36f2bad045f94806e7e98f27e9)
2012-05-17 10:29:03 +10:00
Martin Schwenke
a3ee4a900f Initscript - add backup of corrupt non-persistent databases
Corrupt non-persistent databases never get analysed because ctdbd
zeroes them at startup.

Modify the initscript so that corrupt non-persistent databases are
moved aside to a backup.  If the number of backups for a particular
database exceeds $CTDB_MAX_CORRUPT_DB_BACKUPS (default 10) then the
oldest excess backups are garbage collected.

Abstracts from and cleans up the code for checking persistent
databases.

Logging of related messages is done to syslog or a log file as
specified.

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

(This used to be ctdb commit 00cd75595685dae829758abf1a4cb644af7ed50e)
2012-03-28 15:02:07 +11:00
Ronnie Sahlberg
81fb334cff when shutting down ctdb, allow it 30 seconds instead of 10 before will -9 the daemon
(This used to be ctdb commit d8b400d76665f37ffd9de302eedcff9f23807225)
2012-02-21 19:02:36 +11:00
Ronnie Sahlberg
e3b85bba3f Add a hoook to the ctdb initscript that we can call out to for applications that want to
track and produce audit logs when someone runs "service ctdb <something>"

S1033891

(This used to be ctdb commit 4f4fbd4080a3a7226d3b82637f803c4b71217d39)
2012-02-06 12:07:08 +11:00
Ronnie Sahlberg
53b956fee7 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

(This used to be ctdb commit 8de5513b3ad89711da845c7588d35b32e2f2acb6)
2011-08-11 11:48:04 +10:00
Martin Schwenke
75bbc93c0b 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>

(This used to be ctdb commit 05851d50b0078de8bf4691442d718825adca6fe8)
2011-08-03 17:19:15 +10:00
Martin Schwenke
d31fbcab4b Set $CTDB_VARDIR in the functions file.
This will be needed when eventscripts that use it are called
externally.

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

(This used to be ctdb commit ebd53b66b0cc66d9d04830781886234167fc2164)
2011-08-03 16:44:49 +10:00
Michael Adam
c9dc10292e ctdb.init: print a warning when tdbdump is found but tdbtoo or "tdbtool check" is not available
(This used to be ctdb commit afb26e38b617b85cdac14a7cd6dd3c85b8fddbc4)
2011-04-05 13:50:00 +02:00
Michael Adam
faa6d8d7e2 ctdb.init: check for availability of "tdbtool check" and "tdbdump"
Print a warning if neither is available.

(This used to be ctdb commit 4137d2a7d31cdce22847cebfc0239cfe2d8e937c)
2011-04-05 13:43:56 +02:00
Ronnie Sahlberg
dc2f87737d Dont store temporary runtime data in $CTDB_BASE/state
since that will usually be /etc/ctdb/state and storing this under /etc is just
wrong.

Add a new variable CTDB_VARDIR that defaults to /var/ctdb and store the data there instead.

(This used to be ctdb commit 516423c25afa9861d9988096efa8a4a2b12b31b1)
2010-09-03 12:43:28 +10:00
Martin Schwenke
b930c885b3 initscript: wait until we can ping ctdbd before setting tunables.
Currently we do a "sleep 1" after starting and before running
set_ctdb_variables to set the tunables.  This is too arbitrary and
might fail if the system is heavily loaded.  This, for example, could
result in some nodes running with DeterministicIPs and some without,
in which case a different IP allocation algorithm would run depending
on who is the recmaster!

This makes the start function wait until "ctdb ping" succeeds (with 10
second timeout) before trying to run set_ctdb_variables.  If a timeout
occurs then the start function attempts to kill ctdbd before exiting
with a failure.

It also cleans up the status reporting code for Red Hat and SUSE so
that the final status code is reported.  Currently there are cases
where a correct status is prematurely reported before a failure
occurs.

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

(This used to be ctdb commit cdcd05662a30b51caaeeab4ac44138cac2474e0a)
2010-08-05 15:29:40 +10:00
Ronnie Sahlberg
6091dce975 From Sumit Bose <sbose@redhat.com>
Fixes for init script to meet guidelines

(This used to be ctdb commit 9f484404030211df85a215fd2280568a2ec020fb)
2010-02-22 14:06:52 +11:00
Martin Schwenke
02e68340e8 initscript: Remove bash-ism.
Also, change the order of the comparison so it is consistent with
others in the script.

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

(This used to be ctdb commit 44696e15cdb23e7656d3bb0ead54f509495738a7)
2010-01-22 17:13:17 +11:00
Martin Schwenke
44f2605dd6 initscript: handle spaces in option values inserted into $CTDB_OPTIONS.
This puts single quotes around everything and uses eval on the
command-lines that actually start ctdbd.  The eval causes the single
quotes to be interpreted.

The "redhat" init style no longer uses the Red Hat daemon function.
It loses the quoting and re-splits on spaces.  Instead we add an extra
line that uses the success/failure functions to keep things pretty.
Note that this means that we don't respect daemon's
$DAEMON_COREFILE_LIMIT variable but we do our own core file handling
with $CTDB_SUPPRESS_COREFILE anyway.  daemon's core file handling was
probably overriding what we were doing anyway, so this can be regarded
as a bug fix.

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

(This used to be ctdb commit 9a9b36149042d4d8f455959582ec5c882162266a)
2010-01-22 13:19:00 +11:00
Ronnie Sahlberg
a1d60b1511 Make the size of the in memory ringbuffer for keeping the recent log messages
configureable using --log-ringbuf-size=<num-entries>.

Add an entry in the sysconfig file to set this persistently.

(This used to be ctdb commit c79c2da69bc352f509e7fca4b9172a4b7f23c0f8)
2010-01-15 15:38:56 +11:00
Ronnie Sahlberg
4c722fe34c fix a conflict in the merge from rusty
Merge commit 'rusty/ctdb-no-setsched'

Conflicts:

	server/ctdb_vacuum.c

(This used to be ctdb commit b4365045797f520a7914afdb69ebd1a8dacfa0d9)
2009-12-17 08:18:04 +11:00
Rusty Russell
f148735928 Add --valgringing flag instead of --nosetsched
The do_setsched was being tested for whether to mmap tdbs: let's make it
explicit.  We can also happily move the kill-child eventscript hack under
this flag.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> 


(This used to be ctdb commit 2ee86cc1f311d7b7504c7b14d142b9c4f6f4b469)
2009-12-16 20:59:15 +10:30
Stefan Metzmacher
96977cc5c4 config: add CTDB_MAX_PERSISTENT_CHECK_ERRORS option
metze

(This used to be ctdb commit fc5f556d488488040303438aefecb5ae2a8e54bc)
2009-12-16 08:08:33 +01:00
Stefan Metzmacher
0c735f03d4 config: try to use tdbtool <tdb> check instead of tdbdump for persistent db checks
metze

(This used to be ctdb commit 52e6d81f4d8a4035272d9256d01bafb8ed593027)
2009-12-16 08:08:33 +01:00
Martin Schwenke
db25ca69e5 Eventscript argument cleanups and introduction of ctdb_standard_event_handler.
The functions file no longer causes a side-effect by doing a shift.
It also doesn't set a convenience variable for $1.

All eventscripts now explicitly use "$1" in their case statement, as
does the initscript.  The absence of a shift means that the
takeip/releaseip events now explicitly reference $2-$4 rather than
$1-$3.

New function ctdb_standard_event_handler handles the status and
setstatus events, and exits for either of those events.  It is called
via a default case in each eventscript, replacing an explicit status
case where applicable.

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

(This used to be ctdb commit 3d55408cbbb3bb71670b80f3dad5639ea0be5b5b)
2009-12-01 17:43:47 +11:00