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

1053 Commits

Author SHA1 Message Date
Michael Adam
d9a44ae4bf ctdb: use properly configured ctdb in 99.timeout
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-06-11 06:20:14 +02:00
Michael Adam
0b98c64646 ctdb: use properly configured ctdb in 91.lvs
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-06-11 06:20:14 +02:00
Michael Adam
54cd189de3 ctdb: use properly configured ctdb in 70.iscsi
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-06-11 06:20:14 +02:00
Michael Adam
5dea37abd0 ctdb: use properly configured ctdb in 10.interfaces
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-06-11 06:20:14 +02:00
Michael Adam
7805374a09 ctdb: use properly configured ctdb in 13.per_ip_routing
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-06-11 06:20:14 +02:00
Michael Adam
c9da418d7f ctdb: use properly configured ctdb in 10.external
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-06-11 06:20:14 +02:00
Michael Adam
d277e294de ctdb: use properly configured ctdb in 01.reclock
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-06-11 06:20:13 +02:00
Michael Adam
6d2d6a3786 ctdb: use properly configured ctdb in 00.ctdb
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-06-11 06:20:13 +02:00
Michael Adam
09d8fe7293 ctdb: use properly configured ctdb in ctdbd_wrapper
This makes ctdbd_wrapper usable in non-standard installs.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-06-11 06:20:13 +02:00
Michael Adam
c904cb0929 ctdb: use properly configured ctdb in functions
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-06-11 06:20:13 +02:00
Michael Adam
1cc5f8f616 ctdb: set the path to 'ctdb' in 'functions' in CTDB
Allow this to be overridden from the caller.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-06-11 06:20:13 +02:00
Martin Schwenke
48d1fd8299 ctdb-scripts: Add eventscript 06.nfs
This generates takeip-pre and releaseip-pre call-out events.

One use is to put NFS into grace before an IP is assigned to an
interface.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-06-08 10:33:19 +02:00
Martin Schwenke
6096233919 ctdb-scripts: Move NFS callout-related code to functions file
A second NFS eventscript may be required, so make this code available
to it.

The initialisation code can't be evaluated in the functions file
because service_state_dir isn't yet setup, so put it in a function and
call it with other initialisation code.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-06-08 10:33:19 +02:00
Martin Schwenke
6cc4f78891 ctdb-scripts: Simplify ip_maskbits_iface()
This doesn't need to print the family.  Nothing uses it.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-05-26 08:04:29 +02:00
Martin Schwenke
d78bf2ed3e ctdb-scripts: Rename get_iface_ip_maskbits_family() to get_iface_ip_maskbits()
The family is not needed.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-05-26 08:04:29 +02:00
Martin Schwenke
b4878cfc4d ctdb-scripts: New functions ip_block() and ip_unblock()
Block and unblock IP addresses using these new functions.  This makes
the code more readable.

The case statement in each function is very cheap, so there is no need
to prematurely optimise and pass the family.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-05-26 08:04:29 +02:00
Martin Schwenke
02c2958d1d ctdb-scripts: Drop unnecessary detect_init_style() call
CTDB_INIT_STYLE isn't used in this script.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Kai Blin <kai@samba.org>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Fri May 20 21:06:18 CEST 2016 on sn-devel-144
2016-05-20 21:06:17 +02:00
Martin Schwenke
61d38c8556 ctdb-scripts: Support systemctl directly
Some Linux distributions don't have a "service" compatibility command.

To avoid breaking working systems, prefer the "service" compatibility
command just in case it does some extra, unexpected magic.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Kai Blin <kai@samba.org>
2016-05-20 17:33:18 +02:00
Jose A. Rivera
8b59705252 ctdb-scripts: Add config options for use by clustered NFS
Add CTDB_NFS_STATE_FS_TYPE and CTDB_NFS_STATE_MNT config options, show use in
nfs-ganesha-callout. Since the callout script is only an example, we
officially don't have default values for these.

Signed-off-by: Jose A. Rivera <jarrpa@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-05-13 23:37:25 +02:00
Martin Schwenke
46684867b1 ctdb-recovery: Recovery lock setting can now include helper command
The underlying change is to allow the cluster mutex argstring to
optionally contain a helper command.  When the argument string starts
with '!' then the first word is the helper command to run.  This is
now the standard way of changing the helper from the default.

CTDB_CLUSTER_MUTEX_HELPER show now only be used to change the location
of the default helper when testing.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-04-28 09:39:17 +02:00
Martin Schwenke
cdaa82944a ctdb-scripts: Fix incorrect comment
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-04-25 07:10:14 +02:00
Martin Schwenke
84fdc2a562 ctdb-scripts: Improve error messages when using NFS service_check_cmd
When external monitoring is enabled for an NFS service using
service_check_cmd then $ctdb_check_rpc_out is empty because the
internal RPC checking isn't used.  This results in empty log messages
like:

  60.nfs: ERROR:

or:

  60.nfs: WARNING:

Improve this so it at least says:

  60.nfs: ERROR: monitoring service "statd" failed

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-04-25 07:10:14 +02:00
Jose A. Rivera
bf3f22315a ctdb-scripts: Avoid dividing by zero in memory calculation
Don't do a percentage calculation for either memtotal or swaptotal if they
are zero.

Signed-off-by: Jose A. Rivera <jarrpa@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-04-23 23:55:14 +02:00
Martin Schwenke
04fe9e2074 ctdb-scripts: Use ss instead of netstat for finding TCP connections
ss with a filter is much faster than post-processing output from
netstat.  CTDB already has a hard dependency on iproute2 for IP
address handling, so depending on ss is no big deal.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-04-17 13:54:13 +02:00
Martin Schwenke
4a658440e1 ctdb-scripts: Missing NFS thread count file should just produce warning
This currently causes monitor failure.

Log a warning instead.  If there is a transient issue, such as NFS
being restarted in the background, then the thread count file should
be there the next time around so the count can be adjusted if
necessary.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-04-17 13:54:13 +02:00
Martin Schwenke
dfe8de9e4a ctdb-scripts: Simplify "ctdb lvs ..." output
For "master", if there is a master then print the PNN, otherwise print
nothing.

For "list", print the PNN and IP addresses without a colon in between.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-04-15 05:57:18 +02:00
Martin Schwenke
a92394e69c ctdb-scripts: Add monitoring of CTDB_LVS_PUBLIC_IFACE
... and unit tests.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-04-15 05:57:17 +02:00
Martin Schwenke
ce33a7cb1e ctdb-scripts: Call out to ctdb_lvs helper from 91.lvs
To keep this commit comprehensible, 91.lvs and the CTDB CLI tool are
temporarily inconsistent.  The tool will be made consistent in a
subsequent commit.

LVS now uses a configuration file specified by CTDB_LVS_NODES and
supports the same slave-only syntax as CTDB_NATGW_NODES.  LVS also
uses new variable CTDB_LVS_PUBLIC_IFACE instead of
CTDB_PUBLIC_INTERFACE.

Update unit tests and documentation.

Note that the --lvs and --single-public-ip daemon options are no
longer used.  These will be removed and relevant documentation
updated in a subsequent commit.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-04-15 05:57:17 +02:00
Martin Schwenke
b7376861cb ctdb-scripts: Move ctdb_get_ip_address() to functions file
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-04-15 05:57:17 +02:00
Martin Schwenke
7d522794ef ctdb-scripts: LVS eventscript cleanups
Stylistic changes and cleaner code.  No functional changes.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-04-15 05:57:17 +02:00
Martin Schwenke
39cbe07ef0 ctdb-scripts: Drop "recovered" event from 91.lvs
Having both "recovered" and "ipreallocated" means that everything
happens twice when there is a recovery.  No need for that.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-04-15 05:57:17 +02:00
Martin Schwenke
a0ef57fe84 ctdb-scripts: LVS eventscript error redirection improvements
Basic error redirection improvements before writing tests.

Deleting the service during "startup" will usually fail because the
service has never been setup, so redirect output to avoid logging an
error.

Similarly, deleting the service in "ipreallocated" will always fail
the first time, which would cause an error to be logged.  Given the
simplicity of the script, there's no sane way to avoid the error
sometimes and log it if it actually matters.  This could potentially
be tidied up in the future by making 91.lvs stateful, in a similar way
to 11.natgw.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-04-15 05:57:17 +02:00
Martin Schwenke
600211d11b ctdb-scripts: Drop hardcoded /sbin and /proc paths in LVS eventscript
It can now be unit tested.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-04-15 05:57:17 +02:00
Martin Schwenke
6ff9060285 ctdb-scripts: die() should output to stderr
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-04-15 05:57:17 +02:00
Martin Schwenke
83502a79dc ctdb-scripts: Use ctdb_killtcp helper to kill connections
ctdb_killtcp will take up to 5 seconds to kill connections, so don't
wait in a loop.  Just check if there are remaining connections on
completion and log a message either way.

Also add a test stub.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-04-01 04:42:12 +02:00
Martin Schwenke
b417d79930 ctdb-scripts: Add interface argument to kill_tcp_connections()
This will be needed for a rewrite of the connection killing code but
it is not used yet.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-04-01 04:42:11 +02:00
Martin Schwenke
6fa25f9502 ctdb-scripts: Allow configuration file to be overridden
For testing only (so not documented), set CTDBD_CONF.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-03-01 05:43:19 +01:00
Martin Schwenke
0a5cb637d4 ctdb: Install helpers under libexecdir
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-02-12 09:01:14 +01:00
Martin Schwenke
519564bb35 ctdb-scripts: Drop use of "smbcontrol winbindd ip-dropped ..."
This is unnecessary in Samba >= 4.0 because winbindd monitors IP
address itself and no longer needs to be told when they are dropped.
The smbcontrol commands can hang if a node has recovery mode active
because smbcontrol is unable to connect to the registry.  Therefore,
the smbcontrol commands should be removed.

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

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Ralph Boehme <slow@samba.org>

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Wed Feb 10 14:08:17 CET 2016 on sn-devel-144
2016-02-10 14:08:16 +01:00
Martin Schwenke
3b64c27ca6 ctdb-scripts: No longer set the NAT gateway capability
Nothing checks it anymore.

This means that the NAT gateway capability in the daemon is now
unused.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-01-25 07:18:25 +01:00
Martin Schwenke
bae9feacf2 ctdb: Call out to ctdb_natgw helper from 11.natgw
To keep this commit comprehensible, 11.natgw and the CTDB CLI tool are
temporarily inconsistent.  The tool will be made consistent in a
subsequent commit.

ctdb_natgw_slave_only() is reimplemented to check for the option in
the appropriate line in $CTDB_NATGW_NODES.

Update unit tests and documentation.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-01-25 07:18:25 +01:00
Martin Schwenke
7095c9bcd0 ctdb-scripts: New function ctdb_natgw_slave_only()
This allows future changes to be more self-contained.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-01-25 07:18:25 +01:00
Martin Schwenke
638117c01a ctdb-scripts: Move monitoring of CTDB_NATGW_PUBLIC_IFACE to 11.natgw
The NAT gateway code should be self-contained.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-01-25 07:18:25 +01:00
Martin Schwenke
df5845c641 ctdb-scripts: CTDB_PARTIALLY_ONLINE_INTERFACES incompatible with NAT gateway
This has always been the case.  Now it is documented and enforced.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-01-25 07:18:25 +01:00
Martin Schwenke
06901f4aeb ctdb-scripts: Rename variable: fail -> down_interfaces_found
Now its name describes its usage and the code reads better.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-01-25 07:18:24 +01:00
Martin Schwenke
d0f2143fe8 ctdb-scripts: Drop functions mark_up() and mark_down()
Each is now used in only one place and the logic is more obvious
without them.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-01-25 07:18:24 +01:00
Martin Schwenke
85316c0415 ctdb-scripts: Move interface monitoring code to functions file
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-01-25 07:18:24 +01:00
Martin Schwenke
fe64e76aa0 ctdb-scripts: Rename get_real_iface() -> interface_get_real()
Now suitably named for move to functions file.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-01-25 07:18:24 +01:00
Martin Schwenke
6f212aacf8 ctdb-scripts: Refactor function interface_monitor() to monitor one interface
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-01-25 07:18:24 +01:00
Michael Adam
19fffeb75a ctdb-scripts: further untangle logic for success of interface monitoring
Reduces intentation by using early returns.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Thu Jan 14 22:41:29 CET 2016 on sn-devel-144
2016-01-14 22:41:29 +01:00
Martin Schwenke
a7ce00cc03 ctdb-scripts: Use more unique temporary file names
Consider this sequence of events:

1. Instance of script running update_tickles() hangs
2. Script debugging is launched asynchronously
3. New instance of script is launched, creates temporary file(s)
4. Original hung script makes progress before asynchronous script
   debugging kills it, so it removes temporary file(s)
5. New instance of script produces error due to missing files(s)

This is obviously rare.

Use more unique filenames to avoid step (4) removing the file(s)
belonging to other instances of the script.

This requires some extra cleanup to avoid too many temporary files
(which is why unique filenames were not originally usd).  It is
sufficient to remove files modified at least 10 minutes ago.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-12 19:16:18 +01:00
Martin Schwenke
4afe822397 ctdb-scripts: Don't remove temporary files before use
They will be clobbered by the redirect anyway.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-12 19:16:18 +01:00
Martin Schwenke
20838833f3 ctdb-scripts: Superficial clean-ups to 10.interface
Whitespace and indentation improvements.

Remove comments describing events, since the README covers that much
better.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-12 19:16:18 +01:00
Martin Schwenke
c23744c61d ctdb-scripts: Clarify logic for success of interface monitoring
The current code uses so many shell idioms that it is difficult to
follow.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-12 19:16:18 +01:00
Martin Schwenke
d8e4c5a468 ctdb-scripts: Fix regression in updateip code
Regression introduced in commit
6471541d6d.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-12 19:16:17 +01:00
Martin Schwenke
80c0511421 ctdb-docs: Rewrite event script documentation
Move information about TCP connection tracking and resetting into
ctdb.7.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-12-04 09:17:17 +01:00
Martin Schwenke
d7424f97c9 ctdb-scripts: Add exportfs cache to NFS Linux kernel callout
exportfs can hang when, for example, DNS is flakey.  Given that
exports don't change much, it makes sense to cache them.

Don't try to add error handling when exportfs fails but do print a
warning.  Proper error handling can be added separately.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-12-04 09:17:17 +01:00
Martin Schwenke
8fdda6fa96 ctdb-scripts: Drop creation of database directories
These should be created elsewhere.  If not then something is wrong, so
don't hide the problem.

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 Nov 20 04:40:26 CET 2015 on sn-devel-104
2015-11-20 04:40:26 +01:00
Martin Schwenke
d9677894b7 ctdb-scripts: Fix CTDB_DBDIR=tmpfs support
Various scripts (including debug_locks.sh, 00.ctdb, 05.system) need
CTDB_DBDIR to point to the right place... but it doesn't.

Move the rewriting of CTDB_DBDIR to loadconfig() so that it happens
for all scripts.  Have this code set internal variable
CTDB_DBDIR_TMPFS_OPTIONS so that ctdbd_wrapper can do the mount.

This loses the generality that was present in dbdir_tmpfs_start() but
it wasn't being used anyway.  If it is needed in the future then it
will be in the git history.

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 Nov 18 11:51:54 CET 2015 on sn-devel-104
2015-11-18 11:51:54 +01:00
Martin Schwenke
be670ef010 ctdb-scripts: Add support for CTDB_DBDIR in tmpfs
The tmpfs is mounted and unmounted by ctdbd_wrapper.  Format is
CTDB_DBDIR=tmpfs:<tmpfs-options>.  The only default for the tmpfs is
mode=700 - to override, specify a different value in <tmpfs-options>.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>

Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Mon Nov  9 10:58:32 CET 2015 on sn-devel-104
2015-11-09 10:58:32 +01:00
Martin Schwenke
f05c6d32cc ctdb-scripts: Improve CTDB wrapper shutdown code
This will make it easier to run things after CTDB is stopped.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-11-09 07:53:19 +01:00
Mathieu Parent
c315fce17e Fix various spelling errors
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>

Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Fri Nov  6 13:43:45 CET 2015 on sn-devel-104
2015-11-06 13:43:45 +01:00
Martin Schwenke
86111fcdce ctdb-scripts: Fix an incorrect comment
Since commit 84f5528d9b, CTDB will not
remove an existing socket if it can connect to the existing one.
Instead it will fail to start.

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 Oct 28 09:44:37 CET 2015 on sn-devel-104
2015-10-28 09:44:37 +01:00
Martin Schwenke
b9903d72d3 ctdb-scripts: Remove PID file only if it existed
If 2 attempts are made to start CTDB in quick succession then it is
possible for the 2nd attempt to remove a newly created PID file from
the 1st.

If the PID file existed then the PID/SID from ctdbd_is_running() will
be passed to kill_ctdbd().  If the PID file did not exist then there
is no point removing it.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-10-28 06:40:27 +01:00
Martin Schwenke
0ccf842e12 ctdb-scripts: Use "ctdb ip all" instead of "ctdb ip -n all"
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 Oct 23 06:44:45 CEST 2015 on sn-devel-104
2015-10-23 06:44:45 +02:00
Martin Schwenke
6456b06294 ctdb-scripts: Lock debugging should print kernel stack for process in D state
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-10-16 13:35:10 +02:00
Martin Schwenke
b933b91a0b ctdb-scripts: Update important installed files to use build-time defaults
In this case: ctdbd_wrapper, onnode, ctdb_diagnostics, ctdb.sudoers.
Set sensible defaults from configure options.

Update documentation to match, trying to fix up anything that has been
missed before.

The onnode unit tests need a symlink to the functions file.
The simple integration tests need to set CTDB_BASE and also
need symlinks to functions/nodes.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>

fixup

Signed-off-by: Martin Schwenke <martin@meltin.net>
2015-09-15 08:56:21 +02:00
Martin Schwenke
121d1a8571 ctdb-scripts: Rename variable CTDB_ETCDIR to CTDB_SYS_ETCDIR
This variable points to /etc/ by default.

This distinguishes it from the different variable from wscript, which
points to /etc/ctdb/.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-09-15 08:56:21 +02:00
Martin Schwenke
014a1eb540 ctdb-scripts: CTDB_BASE must be set when including functions file
Also fix an unused test to set CTDB_BASE.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-09-15 08:56:21 +02:00
Martin Schwenke
c58d582ffb ctdb-scripts: Factor out possible creation of rt_tables file
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-09-15 08:56:21 +02:00
Martin Schwenke
677467682a ctdb-scripts: Move remaining state files into CTDB_SCRIPT_VARDIR
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-09-15 08:56:21 +02:00
Martin Schwenke
3aa11b175a ctdb-scripts: New internal variable CTDB_SCRIPT_VARDIR
Clearly identifies where all state files from scripts should go and
allows that location to be easily changed.  This patch should not
change any behaviour (outside of eventscript unit tests, where a
clearer location is now used).

CTDB_VARDIR should no longer be overridden.  Continue to set
CTDB_DBDIR and similar to override database location in unit tests.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-09-15 08:56:21 +02:00
Martin Schwenke
d064620f51 ctdb-scripts: Properly set CTDB_VARDIR in scripts at install time
Have wscript do path substitution.

No need to export this and CTDB_ETCDIR here, but test scripts will
still need to do so.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-09-15 08:56:21 +02:00
Martin Schwenke
e7a139bffe ctdb-scripts: Drop internal file-level variables referencing $CTDB_VARDIR
Using $CTDB_VARDIR at file scope is dangerous because it doesn't
respect the configuration.  Uses of these variables are simple so just
drop the variables and use $CTDB_VARDIR inside functions where it is
safe.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-09-15 08:56:20 +02:00
Martin Schwenke
143ec9e4c2 ctdb-scripts: Drop file removal involving $ctdb_managed_dir
This directory has been under $CTDB_VARDIR for a long time, so is
already removed.  The command is also potentially dangerous if
$ctdb_managed_dir is not set.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-09-15 08:56:20 +02:00
Martin Schwenke
353c27deab ctdb-scripts: Drop functions ctdb_checkstatus() and ctdb_setstatus()
They're not used outside of ctdb_standard_event_helper().

As a consequence, make ctdb_standard_event_helper() do nothing.  It is
harder to remove because it is used in many places, perhaps by
external eventscripts where it has been copied from existing scripts.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-09-15 08:56:20 +02:00
Martin Schwenke
8c2948eba5 ctdb-scripts: Drop 62.cnfs eventscript
To get a similar effect just do something like this:

  mmaddcallback ctdb-disable-on-quorumLoss \
    --command /usr/bin/ctdb \
    --event quorumLoss --parms "disable"

  mmaddcallback ctdb-enable-on-quorumReached \
    --command /usr/bin/ctdb \
    --event quorumReached --parms "enable"

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-09-15 08:56:20 +02:00
Martin Schwenke
9d49dfac5f ctdb-scripts: New internal variable CTDB_NFS_CALLOUT_STATE_DIR
60.nfs sets this to a directory where the NFS callout can store state.

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

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Mon Sep 14 08:36:34 CEST 2015 on sn-devel-104
2015-09-14 08:36:34 +02:00
Martin Schwenke
4164d7bf31 ctdb-scripts: Add default filesystem usage warnings
Always check filesystem usage for the database directories.

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): Sat Aug 29 20:08:48 CEST 2015 on sn-devel-104
2015-08-29 20:08:47 +02:00
Martin Schwenke
0f28ccf87a ctdb-scripts: Add default system memory usage warnings
CTDB should warn by default if too much system memory or swap is used.

The tests have also been tweaked.  In particular, the filesystem-only
tests need to initialise the memory information to avoid errors where
meminfo isn't set.

Document the defaults, warning against disabling them.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-08-29 17:06:25 +02:00
Martin Schwenke
2c601f1895 ctdb-scripts: Enable system monitoring eventscript by default
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-08-29 17:06:25 +02:00
Martin Schwenke
b18e4ae0c9 ctdb-scripts: Throttle system resource monitoring warnings
They are only printed when the percentage usage changes.  This should
stop the logs from being filled with warnings.

Add a test for the throttling.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-08-29 17:06:25 +02:00
Martin Schwenke
e6b5163bc1 ctdb-scripts: Don't shutdown CTDB when memory monitoring fails
Marking the node unhealthy should cause Samba processes to close,
possible freeing a stack of memory.  If not, then it is somebody
else's problem.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-08-29 17:06:25 +02:00
Martin Schwenke
b6a0e4b856 ctdb-scripts: New consistent system memory and swap monitoring
New variables CTDB_MONITOR_MEMORY_USAGE and CTDB_MONITOR_SWAP_USAGE.
Both take a pair of <warn_threshold>:<unhealthy_threshold> where each
theshold is specified as a percentage.

This adds a callout to check_thresholds() that is run when the
unhealthy threshold is reached.

Add some combination tests.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-08-29 17:06:25 +02:00
Martin Schwenke
02fa6c3d10 ctdb-scripts: Factor out new function check_thresholds()
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-08-29 17:06:25 +02:00
Martin Schwenke
b7b6e25b3e ctdb-scripts: Memory monitoring uses thresholds expressed as percentages
CTDB_MONITOR_FREE_MEMORY and CTDB_MONITOR_FREE_MEMORY_WARN are now
percentages that specify thresholds of acceptable memory usage.

Memory/swap usage in tests also specified as percentages.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-08-29 17:06:25 +02:00
Martin Schwenke
bd2845d7eb ctdb-scripts: Use MemAvailable if it is in /proc/meminfo
Otherwise calculate, as before.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-08-29 17:06:25 +02:00
Martin Schwenke
99b8ef5121 ctdb-scripts: Only use /proc/meminfo for memory checks, not "free"
No need to use 2 different sources of information for similar checks.
Also, output of free has been changed, whereas /proc/meminfo is a
kernel API, which will not change.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-08-29 17:06:25 +02:00
Martin Schwenke
ab58c7abd9 ctdb-scripts: Move system memory checking to 05.system
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-08-29 17:06:25 +02:00
Martin Schwenke
fa1050690b ctdb-scripts: New configuration variable CTDB_MONITOR_FILESYSTEM_USAGE
This allows both errors (i.e. unhealthy) and warnings for different
thresholds.  It replaces CTDB_CHECK_FS_USE.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-08-29 17:06:25 +02:00
Martin Schwenke
8f713c87c1 ctdb-scripts: Don't fail monitoring if sanity checks fail
Just log some warnings.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-08-29 17:06:25 +02:00
Martin Schwenke
6b4a46e574 ctdb-scripts: Move filesystem monitoring into a function, clean it up
Drop obvious comments.  Use die() for less lines of code.  Use a case
statement to avoid forking unnecessary processes for each filesystem
being checked.  Drop parentheses around percentages in messages.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-08-29 17:06:25 +02:00
Martin Schwenke
47f7d1b1c8 ctdb-scripts: Rename 40.fs_use to 05.system
Will put all the system monitoring in here, simplifying 00.ctdb.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-08-29 17:06:25 +02:00
Martin Schwenke
7d04778c82 ctdb-scripts: Improve error handling for 50.samba testparm failure
Also add tests.  Update testparm stub to fake error and timeout.  Add
timeout stub.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-08-07 05:33:29 +02:00
Martin Schwenke
b0bc4d2cab ctdb-scripts: Move 60.nfs Ganesha callout to doc/examples/
We don't expect to maintain an up-to-date copy.  NFS Ganesha team
might provide patches.

Also move the Ganesha .check file

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-07-21 07:54:09 +02:00
Martin Schwenke
dd88c2ab8c ctdb-scripts: Support RPC checks for tcp6 and udp6
This adds new configuration variable CTDB_RPCINFO_LOCALHOST6.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-07-21 07:54:09 +02:00
Martin Schwenke
b6a3c1decd ctdb-scripts: Implement registration in nfs-linux-kernel-callout
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-07-14 09:57:18 +02:00
Martin Schwenke
fa6f22d7ae ctdb-scripts: Add registration for CTDB_NFS_CALLOUT operations
This is an optimisation to avoid forking the callout for operations
that are not implemented.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-07-14 09:57:18 +02:00
Martin Schwenke
bb7093ab09 ctdb-scripts: Add portmapper NFS .check file
Unhealthy after 1 failed attempt to contact the portmapper.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-07-14 09:57:18 +02:00
Martin Schwenke
a02bdb97f9 ctdb-scripts: Move NFS support functions to 60.nfs
Now that there is only a single NFS eventscript, other eventscripts no
longer need to load all of this.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-07-14 09:57:18 +02:00
Martin Schwenke
a3a443dcf4 ctdb-scripts: Drop configuration variable CTDB_NFS_DUMP_STUCK_THREADS
This is now handled by passing the desired number of threads to the
command specified in the dump_stuck_threads variable in .check files.

Remove unused function nfs_dump_some_threads().

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-07-14 09:57:18 +02:00
Martin Schwenke
f3a4c4f10b ctdb-scripts: Remove unused function startstop_ganesha()
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-07-14 09:57:18 +02:00
Martin Schwenke
6586651508 ctdb-scripts: Remove 60.ganesha, replace with callout for 60.nfs
This isn't a straightforward move of code from 60.ganesha to the
callout.  Simplifications have been made to allow better
interoperation with the new NFS checking logic.

The following configuration variables have been removed:

  CTDB_GANESHA_REC_SUBDIR

    Edit NFS ganesha callout to change this location

  CTDB_NFS_SERVER_MODE, NFS_SERVER_MODE

    Use CTDB_NFS_CALLOUT instead

  CTDB_NFS_SKIP_KNFSD_ALIVE_CHECK, CTDB_SKIP_GANESHA_NFSD_CHECK

    Disable the corresponding .check file instead

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-07-14 09:57:18 +02:00
Martin Schwenke
713ec21750 ctdb-scripts: Extend NFS .check files with service_check_cmd variable
$service_check_cmd specifies a command to run instead of the regular
rpcinfo-based check.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-07-14 09:57:18 +02:00
Martin Schwenke
d332013123 ctdb-scripts: Remove functions startstop_nfs() and startstop_nfslock()
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-07-14 09:57:18 +02:00
Martin Schwenke
9c87d1dd29 ctdb-scripts: Parameterise 60.nfs with $CTDB_NFS_CALLOUT
The goal is to have a single NFS eventscript.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-07-14 09:57:18 +02:00
Martin Schwenke
49c4d1900c ctdb-scripts: Remove old NFS checking code
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-07-14 09:57:18 +02:00
Martin Schwenke
74428e5c14 ctdb-scripts: Switch NFS checks to new style
Note that the 60.ganesha RPC checks need to be identical to those in
the nfs-checks.d/ directory.  This is because the NFS unit test
infrastructure checks output against what should be produced by the
checks in nfs-checks.d/.  This is a minor issue, since one of the aims
of this work is to remove the need for a separate 60.ganesha.

In most cases configuration variable CTDB_NFS_DUMP_STUCK_THREADS is
now ignored.  This is now handled by passing the desired number of
threads to the command specified in the service_debug_cmd variable in
a .check file.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-07-14 09:57:18 +02:00
Martin Schwenke
3161d611bb ctdb-scripts: Add new NFS service checking infrastructure
Provides a new extensible format for .check files, using simple
variables instead of the unwieldy extended test(1) syntax now used.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-07-14 09:57:18 +02:00
Martin Schwenke
dfeb5b84fd ctdb-scripts: Factor out new function ctdb_counter_get()
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-07-14 09:57:18 +02:00
Martin Schwenke
9f4f1c51fc ctdb-scripts: Move "ERROR:" prefix out of ctdb_check_rpc()
There will be warnings in addition to errors.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-07-14 09:57:18 +02:00
Martin Schwenke
1a9687f948 ctdb-scripts: Clean up ctdb_check_rpc()
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-07-14 09:57:17 +02:00
Martin Schwenke
6f3ee81d17 ctdb-scripts: NFS RPC checks should be simple and consistent
Change status, nlockmgr, mountd, rquotad to be unhealthy after 6
rpcinfo check failures and do a verbose restart after every 2
failures.  Change 60.ganesha for consistency, since 60.ganesha tests
are broken and depend on the consistency.

Apart from the consistency aspect, the check infrastructure will soon
be simplified so that it only allows the equivalent of "unhealthy" and
"verbose restart:b" actions.

Update tests to have a corresponding numbers of iterations.  Run 1
extra iteration in most tests to check there are no unexpected
behaviour changes after the designated number of iterations completes.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-07-14 09:57:17 +02:00
Martin Schwenke
bc71251433 ctdb-scripts: Support monitoring of interestingly named VLANs on bonds
VLAN interfaces on bonds with a name other than <iface>.<id>@<iface>
are not currently supported.  That is, where the VLAN name isn't based
on the underlying bond name.  Such VLAN interfaces can be created with
the "ip link" command, as opposed to the "vconfig" command, or by
renaming a VLAN interface.

This is improved by determining the underlying interface name for a
VLAN from the output of "ip link".

No serious attempt is made to support VLANs with '@' in their name,
although this seems to be legal.  Why would you do that?

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-07-14 09:57:16 +02:00
Martin Schwenke
87c5c96b76 ctdb-scripts: Fix regression in VLAN interface support
Commit 6471541d6d broke support for VLAN
interfaces.  Releasing a public IP address depends on
ip_maskbits_iface() and for a VLAN interface this will return an
interface of the form <vlan>@<iface>, which can't be fed back into
"ip" commands.

Update ip_maskbits_iface() to drop the '@' and everything after it.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Reported-by: Jan Schwaratzki <jschwaratzki@ddn.com>
2015-07-14 09:57:16 +02:00
Martin Schwenke
0a65013b9d ctdb-scripts: Use an "if" statement instead of "&&"
If statd-callout is unwanted, so is removed, then this code fails.
Change to an "if" so that it succeeds as intended.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-07-09 06:23:21 +02:00
Martin Schwenke
0c609c9505 ctdb-scripts: Only write to /proc route flush files if they exist
On IPv4-only or IPv6-only systems one of these files will not exist.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-07-01 04:18:29 +02:00
Martin Schwenke
27674c413d ctdb-scripts: Create the directory containing the recovery lock
This will handle the most obvious cases.  It won't handle the case
where the directory is missing and the recovery lock location is
updated at run-time.  However, this is a good improvement.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-07-01 04:18:28 +02:00
Jose A. Rivera
7266c68856 ctdb: Change use of 'which' to 'type' in scripts.
While 'which' is a very common tool, on many distros it is not a requirement
that it be installed. 'type' is a shell built-in specified by the Open Group,
and is found in shells like bash, dash, and ksh across multiple OSes.

Signed-off-by: Jose A. Rivera <jarrpa@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>

Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Fri Jun  5 20:39:47 CEST 2015 on sn-devel-104
2015-06-05 20:39:47 +02:00
Martin Schwenke
3b25face87 ctdb-scripts: New eventscript 10.external
This is an alternative to 10.interface and is installed as disabled by
default.  It should only be used with DisableIPFailover=yes and when
IP failover is being handled externally.  In this mode CTDB can be
informed of public IP address movements using "ctdb moveip".

During the "startup" event, this eventscript currently finds any
public IP addresses configured in $CTDB_PUBLIC_ADDRESSES and tells
CTDB which node they are on using "ctdb moveip".  This allows CTDB to
send ARPs and tickle-ACKs.

Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-05-13 06:42:13 +02:00
Martin Schwenke
0d0512cb65 ctdb-scripts: Drop all public IP addresses from 10.interface
00.ctdb should not know about public IP addresses.

Move related tests to operate on 10.interface.

Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-05-13 06:42:13 +02:00
Martin Schwenke
c927ec928c ctdb-scripts: Drop update of public address configuration from config.tdb
This isn't used or documented anywhere.

2 differing points of view:

* This is a very good idea but it should probably be generalised to
  cover more configuration items.  This would end up like the Samba
  registry configuration and would use a tool to support setting
  configuration values.

* If people really want to update configuration while a node is down
  then they should fix the configuration before bringing up that node.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-05-10 03:22:13 +02:00
Martin Schwenke
e359d826a4 ctdb-scripts: Add alternative network family monitoring for NFS
For example, adding a file called nfs-rpc-checks.d/20.nfsd@udp.check
will cause NFS to be checked on UDP as well, using a separate counter.

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): Thu Apr 30 09:24:12 CEST 2015 on sn-devel-104
2015-04-30 09:24:12 +02:00
Amitay Isaacs
f6af2d96c2 ctdb-scripts: Run tdb checker under timeout command
If tdb database file size grows beyond 4GB, tdbtool/tdbdump can hang
indefinitely.  This will prevent CTDB from starting up.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-04-30 06:45:26 +02:00
Amitay Isaacs
83f3a35645 ctdb-scripts: Add new configuration variable CTDB_MAX_OPEN_FILES
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-04-30 06:45:26 +02:00
Martin Schwenke
0621f07eb4 ctdb-scripts: New configuration variable CTDB_NODE_ADDRESS
Required when automatic address detection can not be used.  This can
be the case when running multiple ctdbd daemons/nodes on the same
physical host (usually for testing), using InfiniBand for the private
network or on Linux when sysctl net.ipv4.ip_nonlocal_bind=1.

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

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Mon Apr 27 06:10:08 CEST 2015 on sn-devel-104
2015-04-27 06:10:08 +02:00
Martin Schwenke
0ae57588eb ctdb-scripts: Simplify a command pipeline
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-04-27 03:32:11 +02:00
Martin Schwenke
1092f9755f ctdb-scripts: Replace uses of "ctdb pnn" with ctdb_get_pnn()
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-04-27 03:32:10 +02:00
Martin Schwenke
09b5e4978a ctdb-scripts: Changed uses of "ctdb xpnn" to ctdb_get_pnn()
"ctdb xpnn" does not work when sysctl net.ipv4.ip_nonlocal_bind=1,
since it determines the node by attempting to bind to each addres in
the nodes file.  The solution is to not use "ctdb xpnn".  After the
initial call, ctdb_get_pnn() will be more efficient that "ctdb xpnn".

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-04-27 03:32:10 +02:00
Martin Schwenke
579dda6858 ctdb-scripts: New function ctdb_get_pnn() does cached retrieval of PNN
This avoids the expense of establishing a client connection to the
daemon just to get the PNN of the current node.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-04-27 03:32:10 +02:00
Amitay Isaacs
14886ed00c ctdb-scripts: Use tcp connection for checking RPC services
It's possible for a RPC service to register only for UDP and not TCP.
Since we assume all the NFS operations are over TCP, always check RPC
services over TCP.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-03-27 06:40:08 +01:00
Martin Schwenke
130202d635 ctdb-scripts: Respect $RPCMOUNTDOPTS when restarting rpc.mountd
$RPCMOUNTDOPTS is ignored when restarting rpc.statd due to the service
being unresponsive.  This variable can be used to increase the number
of rpc.mountd threads when there are a lot of clients reattaching so
ignoring it can mean that only a single rpc.mount thread is started.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-27 06:40:08 +01:00
Amitay Isaacs
1f523a628a ctdb-tests: Avoid early exits in scripts that appear on tail of a pipe
When executing a shell script code "foo | bar", if "bar" terminates early,
then "foo" can get I/O error when writing to stdout.

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

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

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-04 10:42:27 +01:00
Martin Schwenke
dc32f11b87 ctdb-scripts: Improve messages about invalid tunables during "setup"
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Wed Feb 18 08:03:33 CET 2015 on sn-devel-104
2015-02-18 08:03:33 +01:00
Martin Schwenke
39686f4505 ctdb-scripts: Fix tunable setup code by making it shell-agnostic
All tunables set in configuration are currently set to 0 on system
where /bin/sh is dash (and perhaps other non-bash shells).  dash puts
single quotes around all values in the output of the "set" builtin
command, whereas bash only puts them around values when something
needs to be quoted.  Tunables always have a simple integer value so
dash will quote them and bash won't.  The setup code currently passes
the raw value, including any quotes to "ctdb setvar ...".  This
command does no error checking on the input, so "'1'" is converted to
0.

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

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

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

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-02-18 05:34:06 +01:00
Martin Schwenke
ab51f283e7 ctdb-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
2015-01-28 08:29:55 +01:00
Martin Schwenke
9b67c1fa37 ctdb-scripts: Error message, comment and whitespace cleanups
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-01-28 06:01:09 +01:00
Martin Schwenke
1a5414b6d2 ctdb-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>
2015-01-28 06:01:08 +01:00
Martin Schwenke
d1bd26e5eb ctdb-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>
2015-01-28 06:01:08 +01:00
Martin Schwenke
4638010abb ctdb-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>
2015-01-09 02:03:40 +01:00
Martin Schwenke
a5c5eee7d1 ctdb-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>
2015-01-09 02:03:40 +01:00
Led
2c3672f424 ctdb-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>
2015-01-09 02:03:40 +01:00
Martin Schwenke
d0b2375c3d ctdb-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>
2014-12-05 21:02:40 +01:00
Amitay Isaacs
d4212bd6a5 ctdb-eventscripts: Specify broadcast optionally to ip addr add
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2014-12-05 21:02:40 +01:00