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

9257 Commits

Author SHA1 Message Date
Martin Schwenke
fe97d04f18 ctdb-tests: Use ctdb_read_nodes() in the fake ctdbd
Remove unused copy of ctdb_read_nodes_file().

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-07-23 11:37:34 +00:00
Martin Schwenke
3d52258d8a ctdb-tools: Use ctdb_read_nodes() in the ctdb tool
Remove unused copy of ctdb_read_nodes_file().

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-07-23 11:37:34 +00:00
Martin Schwenke
45da2281aa ctdb-conf: Add a common node address handling module
These functions are intended to be used in ctdbd, the ctdb tool and
fake_ctdbd, replacing the different copies in each place.

ctdb_read_nodes() will replace ctdb_read_nodes_file().  The name
change is intentional - in future the location may be something other
than a simple filename.

The static copies of ctdb_read_nodes_file() and node_map_add() are
slightly sanitised versions of those in tools/ctdb.c, with a call to
ctdb_parse_node_address().  A bit more care is taken in node_map_add()
to avoid undefined behaviour if talloc_realloc() fails.

ctdb_parse_node_address() will replace ctdb_parse_address().  There is
an obvious argument change, since the ctdb context argument was
unused.  It can only fail on an invalid node address, so return a
bool.  This function might be changed later to allow the input address
string to include an optional port.

Where to put this module isn't entirely clear.  It could go in common,
so be part of ctdb-util.  However, if it later needs
ctdb-conf (e.g. to allow the node list location to be configurable)
then there would be a direct cyclic dependency.  This is configuration
handling, so conf/ seems sane.  However, I didn't want to put it into
the ctdb-conf target, since some code might need to parse a nodes list
but not need to parse ctdb.conf.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-07-23 11:37:34 +00:00
Martin Schwenke
79c5f451c8 ctdb-protocol: Move definition of CTDB_PORT to protocol
Users of CTDB_PORT will all pick up the new definition.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-07-23 11:37:34 +00:00
Martin Schwenke
67e49d3e54 ctdb-build: Remove unused dependencies on ctdb-util
Since commit ba8f8ef33c.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-07-23 11:37:34 +00:00
Martin Schwenke
8ba8fef8ac ctdb-tests: Correctly handle adding a deleted node at the end
The current fake_ctdbd code for reloading the nodes file overruns the
allocation when adding a deleted node at the end.  This is a very
unlikely case, but it might as well work.

Check the size of the internal node map when marking a node deleted.
Also, update the code that adds a node to correctly set the deleted
flag when appropriate.

The included test case tests this.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Guenther Deschner <gd@samba.org>

Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Wed Jul 17 00:06:53 UTC 2024 on atb-devel-224
2024-07-17 00:06:53 +00:00
Martin Schwenke
340563633c ctdb-tests: Add more reloadnodes unit tests
There are no existing tests to exercise node IP address change
detection.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
2024-07-16 23:05:35 +00:00
Björn Baumbach
056dd415dd ctdb-failover: omit "restrict" optimization keyword
Fails with some compilers with

error: expected ';', ',' or ')' before 'lineptr'

Signed-off-by: Björn Baumbach <bb@sernet.de>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Martin Schwenke <martin@meltin.net>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Tue Jul  2 23:52:37 UTC 2024 on atb-devel-224
2024-07-02 23:52:37 +00:00
Anoop C S
6ba69da8d3 ctdb/wscript: Remove long pending unsupported option
It has been a while since --with-libcephfs option was dropped. Therefore
stop advertising it through waf scripts.

Signed-off-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Jul  2 09:13:20 UTC 2024 on atb-devel-224
2024-07-02 09:13:20 +00:00
Xavi Hernandez
60550fbe18 Fix starvation of pending writes in CTDB queues
CTDB uses a queue to receive requests and send answers. It works
asynchronously using the tevent framework. However there was an issue
that gave priority to the receiving side so, when a request was
processed and the answer posted to the queue, if another incoming
request arrived, it was served before sending the previous answer.

This scenario could repeat for long periods of time if the frequency of
incoming requests was high enough.

Eventually, a small time gap between incoming request gave a chance to
process the pending output queue, sending many answers in a burst.

This patch makes sure that both queues (input and output) are processed
if the event contains the appropriate flag.

Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Jul  1 09:17:43 UTC 2024 on atb-devel-224
2024-07-01 09:17:43 +00:00
Martin Schwenke
11c4b25331 ctdb-conf: Rename config loading to not be daemon-specific
We might end up using it elsewhere.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-06-28 18:43:52 +05:30
Martin Schwenke
cf25243421 ctdb-conf: Move conf.[ch] to conf/ subdirectory
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-06-28 18:43:52 +05:30
Martin Schwenke
52e5e92693 ctdb-conf: Move all conf files to new conf/ subdirectory
Leave common/conf.[ch] where they are to make this commit
comprehensible.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-06-28 18:43:52 +05:30
Martin Schwenke
415f9f0745 ctdb-failover: Split statd_callout add-client/del-client
rpc.statd is single-threaded and runs its HA callout synchronously. If
it is too slow then latency accumulates and rpc.statd's backlog grows.

Running a pair of add-client/del-client events with the current code
averages ~0.030s in my test environment.  This mean that 1000 clients
reclaiming locks after failover can easily cause 10s of latency.  This
could cause rpc.statd to become unresponsive, resulting in a time out
for an rpcinfo-based health check of the status service.

Split the add-client/del-client events out to a standalone
statd_callout executable, written in C, to be used as the HA callout
for rpc.statd.  All other functions move to statd_callout_helper.
Now, running a pair of add-client/del-client events in my test
environment averages only ~0.002s.  This seems less likely to cause
latency problems.

The standalone statd_callout executable needs to read a configuration
file, which is generated by statd_callout_helper from the "startup"
event.  It also needs access to a list of currently assigned public
IPs.

For backward compatibility, during installation a symlink is created
from $CTDB_BASE/statd-callout to the new statd_callout, which is
installed in the helper directory.

Testing this as part of the eventscript unit tests starts to become
even more of a hack than it used to be.  However, the dependency on
stubs and the corresponding setup of fake state makes it hard to move
this elsewhere.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Tue Jun 25 04:24:57 UTC 2024 on atb-devel-224
2024-06-25 04:24:57 +00:00
Martin Schwenke
089aec2885 ctdb-doc: Drop unnecessary, broken attempt at rpc.statd stack trace
There is a typo here, since there will be no process called "status".
Instead of fixing it, drop this because rpc.statd isn't the focus of
this monitoring check and when systemd is init rpc.statd isn't
restarted with nfs-ganesha.  It stays running, so a confusing stack
trace for rpc.statd is always logged.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2024-06-25 03:16:37 +00:00
Martin Schwenke
707e0ef55b ctdb-scripts: Fail monitoring after 1 x NFS-Ganesha not running
If ganesha.nfsd is gone then a node can't provide an NFS service, so
should be marked unhealthy.  A later restart may bring it back to
health.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2024-06-25 03:16:37 +00:00
Martin Schwenke
4766d4568b ctdb-doc: Add example for NFS-Ganesha RPC checking
This one does an rpcinfo check, along with statistics mitigation.  It
can be used in combination with the existing 20.nfs_ganesha.check.

The equivalent kernel NFS file only restarts every 10 failures.  This
one can be a little more proactive given that false positives are less
likely with the statistics mitigation.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2024-06-25 03:16:37 +00:00
Martin Schwenke
d96078e263 ctdb-scripts: Implement NFS statistics retrieval for NFS-Ganesha
Simplicity is preferred here over absolute correctness.  If the
ganesha_stats command exits with an error or times out then no output
is produced so, implicitly, the statistics do not change.  Also, the
statistics always change at startup.  However, it is likely that the
statistics change when NFS makes progress and do not change when NFS
does not make progress.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2024-06-25 03:16:37 +00:00
Martin Schwenke
5b7d17d44d ctdb-scripts: Add service_stats_command variable to NFS checks
When monitoring an RPC service, the rpcinfo command might time out
even though the service is making progress.  In this case, it is just
slow, so counting the timeout as a failure and potentially restarting
the service will not help.  The problem is determining if a service is
making progress.

Add a new NFS checks service_stats_command.  This command is intended
to run a statistics command.  The output is naively compared using
cmp(1).  If the output changes then rpcinfo failures are converted to
successes.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2024-06-25 03:16:37 +00:00
Günther Deschner
35f6c3f3d4 ctdb/docs: Include ceph rados namespace support in man page
Document the new optional argument to specify the namespace to be
associated with RADOS objects in a pool.

Pair-Programmed-With: Anoop C S <anoopcs@samba.org>
Signed-off-by: Günther Deschner <gd@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>

Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Fri Jun 14 07:42:25 UTC 2024 on atb-devel-224
2024-06-14 07:42:25 +00:00
Günther Deschner
d8c52995f6 ctdb/ceph: Add optional namespace support for mutex helper
RADOS objects within a pool can be associated to a namespace for
logical separation. librados already provides an API to configure
such a namespace with respect to a context. Make use of it as an
optional argument to the helper binary.

Pair-Programmed-With: Anoop C S <anoopcs@samba.org>
Signed-off-by: Günther Deschner <gd@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
2024-06-14 06:40:37 +00:00
Martin Schwenke
e9eb581043 ctdb-scripts: Protect against races when starting grace period
While the PID check is worth it in relevant cases, NFS-Ganesha still
might go away after the check.  Unfortunately, neither grace command
fails an indicative exit code, so invent one by checking error
messages.  This can then be converted to success by the caller.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Thu May 30 12:50:01 UTC 2024 on atb-devel-224
2024-05-30 12:50:01 +00:00
Martin Schwenke
911117c79a ctdb-scripts: Check NFS-Ganesha is running before attempting grace
If monitoring has failed because it isn't running, then don't fail
"startipreallocate" or "relaseip" by trying to go into grace.

Don't check this for "takeip".  In that case NFS-Ganesha had better be
running.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-05-30 11:42:30 +00:00
Martin Schwenke
27c53880c2 ctdb-scripts: Improve service PID check
No need to grovel around in /proc.  ps will happily tell us the
command.

Factor out the actual check into a separate function that can be used
elsewhere.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-05-30 11:42:30 +00:00
Martin Schwenke
bc10704aec ctdb-scripts: Improve NFS-Ganesha export path extraction
Path values do not need to have quotes.  The current code fails if
there aren't any.

Instead, implement a 2 stage parser using 2 sed commands.  See
comments in the code for details.

Regexps are POSIX basic regular expressions, apart from \<WORD\> (used
to ensure WORD is on word boundaries, and the 'i' flag for case
insensitivity.  The latter is supported in FreeBSD sed.

This code successfully parses Path values out of the following
monstrosity:

path = "/foo/bar1;a";
   Path = /foo/bar2;
Something = false;
Pseudo = "/foo/bar3x" ; Path = "/foo/bar3; y" ; Access_type = RO;
Pseudo = "/foo/bar4x" ; path=/foo/bar4; Access_type = RO;
Pseudo = "/foo/barNONONO" ; not_Path=/foo/barNONONO; Access_type = RO;
   Path = /foo/bar5
Pseudo = "/foo/bar6x Path=foo" ; Path=/foo/bar6; Access_type = RO

This is probably the best that can be done within a shell script.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-05-30 11:42:30 +00:00
Martin Schwenke
944d9d308d ctdb-scripts: Add script option CTDB_NFS_EXPORTS_FILE
Exports may be contained in an include file rather than the top-level
ganesha.conf.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-05-30 11:42:30 +00:00
Martin Schwenke
1be5b1df1b ctdb-scripts: Fix usage message
An IP address is passed to these actions.

Reported-by: Arnab Tah <atah@ddn.com>
Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-05-30 11:42:30 +00:00
Martin Schwenke
2a3d7c0971 ctdb-scripts: Change NFS-Ganesha PID file location
This is the current default.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-05-30 11:42:30 +00:00
Martin Schwenke
a534f71347 ctdb-scripts: Quote variable expansions
Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-05-30 11:42:30 +00:00
Martin Schwenke
6ffb73bb55 ctdb-scripts: Reformat with "shfmt -w -p -i 0 -fn"
Best reviewed with "git show -w".

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-05-30 11:42:30 +00:00
Martin Schwenke
991d21d075 ctdb-scripts: No longer run statd-callout under sudo
This simplifies and removes a bad hack.  Also, in my test environment,
it also drops the average time take to run an add-client/del-client
pair from ~0.055s to ~0.030s.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-05-30 11:42:30 +00:00
Martin Schwenke
ecb9545b3f ctdb-scripts: Use find_statd_sm_dir() in one more place
Take advantage of new function find_statd_sm_dir() when clearing the
local system statd state directory, so it uses the correct directory
when running on a non-RH distro.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-05-30 11:42:30 +00:00
Martin Schwenke
50b3cebeb3 ctdb-scripts: Set ownership of statd-callout state directory
For add-client and del-client, statd-callout is called by rpc.statd,
which runs as rpcuser, statd or some other non-root system user.  This
means that add-client and del-client can't write in the statd-callout
state directory if it is only writable by root.  rpc.statd must be
able to write to its own local system statd state directory, so find
this directory and use it as a reference to set the ownership of
CTDB's statd-callout state directory.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-05-30 11:42:30 +00:00
Martin Schwenke
608557c6ce ctdb-scripts: Avoid connecting to ctdbd in add-client/del-client
rpc.statd runs statd-callout as a non-root user, which is currently
hacked around using some sudo logic that fails to work in some
contexts (e.g. in a container).

Use $CTDB_MY_PUBLIC_IPS_CACHE to access the node's currently assigned
public IPs, for add-client/del-client.  This avoids connecting to
ctdbd when called from rpc.statd.

Also, use $CTDB_MY_PUBLIC_IPS_CACHE in other places where it makes
sense.

Connections to ctdbd are still made in the "notify" action, but this
is always run as root.

In the test code, set the PNN after public addresses setup so that the
cache of assigned IPs correctly initialised.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-05-30 11:42:30 +00:00
Martin Schwenke
5a4209b713 ctdb-tests: Default PNN is 0
This is called in a couple of places without an argument, so give it a
default.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-05-30 11:42:30 +00:00
Martin Schwenke
ed3f041c30 ctdb-scripts: Add caching function for public IPs
This is way more complicated than I would like but, as per the
comment, this is due to complexities in the way public IPs work.  The
main consumer will be statd-callout, which will then be able to run as
a non-root user.

Also generate the cache file in test code, whenever the PNN is set.
However, this can cause "ctdb ip" to generate a fake IP layout before
public IPs are setup.  So, have the "ctdb ip" stub generate the IP
layout every time it is run to avoid it being stale.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-05-30 11:42:30 +00:00
Martin Schwenke
558cf280b2 ctdb-scripts: Move state directory creation to "startup" action
Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-05-30 11:42:30 +00:00
Martin Schwenke
d02fb20d79 ctdb-scripts: Avoid globally changing to queue directory
Add new variables statd_callout_state_dir and statd_callout_queue_dir
- the latter is for files queued by add-client/del-client.

Use $statd_callout_queue_dir to avoid a global cd to the queue
directory near the top of the script.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-05-30 11:42:30 +00:00
Martin Schwenke
b90d72c7b8 ctdb-scripts: Move ctdb.tdb attach to statd-callout
All of the other uses of ctdb.tdb are in statd-callout.

New variable statd_callout_db makes it easy to change the database
name in future, perhaps even allowing it to be configurable.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-05-30 11:42:30 +00:00
Martin Schwenke
c912e406c1 ctdb-scripts: Reformat with shfmt -w -p -i 0 -fn
Tweak some lines to avoid overflowing 80 columns.

Best viewed with "git show -w".

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-05-30 11:42:30 +00:00
Martin Schwenke
7b24cc032e ctdb-scripts: Improve documentation
Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-05-30 11:42:30 +00:00
Martin Schwenke
5176b43da7 ctdb-scripts: Avoid ShellCheck warning SC2162
SC2162 read without -r will mangle backslashes.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-05-30 11:42:30 +00:00
Martin Schwenke
5401522380 ctdb-scripts: Reformat with "shfmt -w -p -i 0 -fn"
Best reviewed with "git show -w".

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-05-30 11:42:30 +00:00
Jo Sutton
82224fca78 ctdb: Report errors from getline()
Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2024-04-24 05:16:29 +00:00
Jo Sutton
f9309c221b ctdb: Ensure ‘ret’ is always initialized
This avoids a compilation error:

../../ctdb/protocol/protocol_util.c: In function ‘ctdb_connection_list_read’:
../../ctdb/protocol/protocol_util.c:787:9: error: ‘ret’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  787 |  return ret;
      |         ^~~

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2024-04-24 05:16:29 +00:00
Martin Schwenke
0159c48e89 ctdb-scripts: Do not de-duplicate the interfaces list
Using xargs with sort -u to de-duplicate this list was my idea and
causes a couple of things to go wrong.  The use of xargs causes
double-quotes to be lost.  The resulting $public_ifaces value also
contains newlines.  The newlines could be removed with an additional
xargs at the end of the pipeline... but that would add an extra level
of quote stripping.

I have unsuccessfully tried to find an alternative, but still elegant,
command pipeline that de-duplicates the list, while maintaining
quoting.

So, just drop the de-duplication.

This might make interface_ifindex_exists_with_options() slightly less
efficient.  However, that function walks the whole list, only
terminating early when a match is found on both interface and options,
so at least it will be correct.

Include an extra testcase.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Thu Apr 18 09:08:34 UTC 2024 on atb-devel-224
2024-04-18 09:08:34 +00:00
Volker Lendecke
7e621b1b53 ctdb: Modernize a few DEBUGs
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Wed Apr 17 00:54:55 UTC 2024 on atb-devel-224
2024-04-17 00:54:55 +00:00
Volker Lendecke
73e806c559 ctdb: Remove common/line.[ch]
This was an implementation of getline(3), use that instead.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
2024-04-16 23:51:45 +00:00
Volker Lendecke
ba8f8ef33c ctdb: Use stdio's getline() in ctdb_connection_list_read()
This is the only user of common/line.[ch], which can go next.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
2024-04-16 23:51:45 +00:00
Volker Lendecke
0baae61e42 lib: Give lib/util/util_file.c its own header file
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
2024-04-16 23:51:45 +00:00
Vinit Agnihotri
f42c5802fa ctdb-scripts: Add options to generate smb.conf interfaces include file
Signed-off-by: Vinit Agnihotri <vagnihotri@ddn.com>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-04-16 23:51:45 +00:00
Vinit Agnihotri
56eeb058d2 ctdb-scripts: Rename and relocate function get_all_interfaces()
get_all_interfaces() functions gets all names for all public interfaces.
However name is misleading. Thus renamed it to get_public_ifaces() and
moved it under functions.

Signed-off-by: Vinit Agnihotri <vagnihotri@ddn.com>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-04-16 23:51:45 +00:00
Volker Lendecke
a3e186b617 lib: Remove timeval_until()
We have the same function in tevent, no need to duplicate code.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-03-22 05:03:35 +00:00
Volker Lendecke
78208d4fe4 ctdb: Remove an unnecessary cast
nl->srvid is uint64_t, as is the srvid parameter of ctdb_daemon_send_message()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Wed Mar 13 08:43:16 UTC 2024 on atb-devel-224
2024-03-13 08:43:16 +00:00
Vinit Agnihotri
6005de8cb3 ctdb-scripts: Remove usage of releaseip-pre, takeip-pre pseudo-events
These were generated by 06.nfs.script.

Signed-off-by: Vinit Agnihotri <vagnihotri@ddn.com>
Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Wed Mar  6 07:09:06 UTC 2024 on atb-devel-224
2024-03-06 07:09:06 +00:00
Vinit Agnihotri
2de2d5dd20 ctdb-scripts: Remove unnecessary 06.nfs.script
Signed-off-by: Vinit Agnihotri <vagnihotri@ddn.com>
Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-03-06 06:05:38 +00:00
Vinit Agnihotri
e3294e5526 ctdb-doc: Put NFS in grace on startipreallocate
Signed-off-by: Vinit Agnihotri <vagnihotri@ddn.com>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-03-06 06:05:38 +00:00
Vinit Agnihotri
34c76ffec5 ctdb-doc: Factor out grace period function
Signed-off-by: Vinit Agnihotri <vagnihotri@ddn.com>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-03-06 06:05:38 +00:00
Vinit Agnihotri
9631e3569d ctdb-client: Remove unused function
Signed-off-by: Vinit Agnihotri <vagnihotri@ddn.com>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-03-06 06:05:38 +00:00
Vinit Agnihotri
a4e492f728 ctdb-scripts: Add handling for startipreallocate
Signed-off-by: Vinit Agnihotri <vagnihotri@ddn.com>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-03-06 06:05:38 +00:00
Vinit Agnihotri
7dacbcd0ec ctdb: send a CTDB_SRVID_START_IPREALLOCATE message after CTDB_EVENT_START_IPREALLOCATE
Event scripts run the "start_ipreallocate" hook in order to notice
that some ip addresses in the cluster potentially changed.

CTDB_SRVID_START_IPREALLOCATE gives C code a chance to get notified as well
once the event scripts are finished.

Signed-off-by: Vinit Agnihotri <vagnihotri@ddn.com>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-03-06 06:05:38 +00:00
Vinit Agnihotri
2483a2ae20 ctdb-takeover: Use CTDB_CONTROL_START_IPREALLOCATE
Signed-off-by: Vinit Agnihotri <vagnihotri@ddn.com>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-03-06 06:05:38 +00:00
Vinit Agnihotri
b7cc56d22d ctdb-server: Implement CTDB_CONTROL_START_IPREALLOCATE
Trigger a "startipreallocate" event, but only if in RUNNING runstate.
"startipreallocate" is intended to allow an NFS server to be put into
grace on all nodes before any locks are released as part of releaseip
during failover.  If node A is leader and initiates a takeover run
then node B may be connected/active but may not have completed
startup.  In this case, the attempt to put NFS-Ganesha into grace on
node B will fail, startipreallocate will fail, and the node will be
banned.

Signed-off-by: Vinit Agnihotri <vagnihotri@ddn.com>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-03-06 06:05:38 +00:00
Vinit Agnihotri
9a20dfe97a ctdb-protocol: Add new control CTDB_CONTROL_START_IPREALLOCATE
Signed-off-by: Vinit Agnihotri <vagnihotri@ddn.com>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-03-06 06:05:38 +00:00
Vinit Agnihotri
d97e642ba8 ctdb-daemon: Implement startipreallocate event
Signed-off-by: Vinit Agnihotri <vagnihotri@ddn.com>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-03-06 06:05:38 +00:00
Vinit Agnihotri
786adccaa9 ctdb-protocol: Add new event startipreallocate
A new event is needed for NFS lock reclaim to ensure all nodes are in
grace before any locks are released. This event must take place before
releaseip.

Signed-off-by: Vinit Agnihotri <vagnihotri@ddn.com>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-03-06 06:05:38 +00:00
Martin Schwenke
ed67e65057 ctdb-common: Remove old runstate/string translation functions
The canonical versions are in protocol utils.

These were unused apart from some stray forward declarations in
tools/ctdb.c and a single call in ctdb_set_runstate(), where
ctdb_runstate_to_string() can be used instead.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-03-06 06:05:38 +00:00
Martin Schwenke
318d526a0d ctdb-common: Remove unused variable ctdb_eventscript_call_names.
Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-03-06 06:05:38 +00:00
Martin Schwenke
9f68656b47 ctdb-daemon: Use ctdb_event_to_string()
ctdb_eventscript_call_names() will be dropped so the mapping between
events and strings is only maintained in one place.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-03-06 06:05:38 +00:00
Martin Schwenke
667265b685 ctdb-tests: Limit red-black tree test to 5s of random inserts
rb_test_001.sh runs for 60s even though rb_tree.c is almost never
modified.  This generally extends test time by an unreasonable amount
of time.

Add an optional timeout (in seconds) argument to rb_test, defaulting
to 60, and pass 5 from rb_test_001.sh.  If anyone ever significantly
updates rb_tree.c then they can run rb_test directly with its default
60s timeout... or for as long as they like.

Reported-by: Volker Lendecke <vl@samba.org>
Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Thu Feb 29 13:20:40 UTC 2024 on atb-devel-224
2024-02-29 13:20:40 +00:00
Martin Schwenke
dd9b11acbc ctdb-protocol: Add missing push support for new controls
CTDB_CONTROL_TCP_CLIENT_DISCONNECTED and
CTDB_CONTROL_TCP_CLIENT_PASSED were added in commits
c6602b686b and
037e8e449d.  They were missing test
support for the packet push/pull.  While adding the testing (for
completeness, before adding another new control) I noticed that the
push functionality was absent.  This adds that, along with the test
support.

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

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Feb 19 10:21:48 UTC 2024 on atb-devel-224
2024-02-19 10:21:48 +00:00
Stefan Metzmacher
f1f68108cc ctdb/events: add 47.samba-dcerpcd.script
If someone wants to enable the witness service
samba-dcerpcd needs to be started as standalone service

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
2024-02-13 20:02:31 +00:00
Stefan Metzmacher
ff8f778e39 ctdb/events: use 'service "$CTDB_SERVICE_NMB" status' in 48.netbios.script
We can easily monitor if the service is running at all,
that better than no monitoring at all...

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
2024-02-13 20:02:31 +00:00
Stefan Metzmacher
62654f0aeb ctdb: add comments to "addip"/"delip" when CTDB_{CONTROL,EVENT,SRVID}_IPREALLOCATED happens
"addip"/"delip" are different from "moveip" so they don't need to
call ipreallocate() nor send_ipreallocated_control_to_nodes().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2024-01-04 11:39:36 +00:00
Stefan Metzmacher
589ebabc95 ctdb: let "moveip" end with CTDB_CONTROL_IPREALLOCATED to all connected nodes
This matches the behavior of takeover_send/recv() from
ctdb_takeover_helper.c.

It means we consistently call the ipreallocated event scripts
and also send CTDB_SRVID_IPREALLOCATED after moving ips.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2024-01-04 11:39:36 +00:00
Stefan Metzmacher
2c6b455bd7 ctdb: remove unused ctdb_message_disable_ip_check()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2024-01-04 11:39:36 +00:00
Stefan Metzmacher
cad1969b17 ctdb: let "moveip" also use disable_takeover_runs()
That makes the behavior more consistent compared to a takeover run
started from the within ctdbd.

The behavior is the same but ctdb_message_disable_ip_check() used
a legacy code path and the next commits will also touch some
of the moveip logic...

The logic and comments are copied from control_reloadips().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2024-01-04 11:39:36 +00:00
Stefan Metzmacher
b1d0d5d514 ctdb: send a CTDB_SRVID_IPREALLOCATED message after CTDB_EVENT_IPREALLOCATED
Event scripts run the "ipreallocated" hook in order to notice that some ip addresses
in the cluster potentially changed.

CTDB_SRVID_IPREALLOCATED gives C code a chance to get notified as well once the event
scripts are finished.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2024-01-04 11:39:36 +00:00
Martin Schwenke
4b7329f158 ctdb-server: Drop unnecessary copy of destination address
Modernise debug while touching the code.

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

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Fri Dec 15 12:09:21 UTC 2023 on atb-devel-224
2023-12-15 12:09:21 +00:00
Martin Schwenke
8fc3872557 ctdb-daemon: Use ctdb_connection_to_buf() to simplify
The one case that is no longer handled specially is when the
destination address is IPv4 loopback.  This may previously have been
used to avoid flooding the logs when testing.  However, that seems
unnecessary - if testing with 127.0.0.1 then make it a public address.

Modernise debug while touching the code.

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

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-12-15 11:06:34 +00:00
Stefan Metzmacher
037e8e449d ctdb: add/implement CTDB_CONTROL_TCP_CLIENT_PASSED
With multichannel a tcp connection is registered first with
a temporary smbd process, that calls CTDB_CONTROL_TCP_CLIENT
first and then passes the tcp connection to the longterm smbd
that already handles all connections belonging to the specific
client_guid. That smbd process calls CTDB_CONTROL_TCP_CLIENT
again, but the 'tickle' information is already there.
When the temporary smbd process exists/disconnects from ctdb
or calls CTDB_CONTROL_TCP_CLIENT_DISCONNECTED, the 'tickle'
information is removed, while the longterm smbd process
still serves the tcp connection.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2023-12-15 11:06:34 +00:00
Stefan Metzmacher
c6602b686b ctdb: add/implement CTDB_CONTROL_TCP_CLIENT_DISCONNECTED
With multichannel a ctdb connection from smbd may hold multiple
tcp connections, which can be disconnected before the smbd
process terminates the whole ctdb connection, so we a
way to remove undo 'CTDB_CONTROL_TCP_CLIENT' again.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2023-12-15 11:06:34 +00:00
Stefan Metzmacher
8395fd369d ctdb: add ctdb_connection_same() helper
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2023-12-15 11:06:34 +00:00
Stefan Metzmacher
5f52d140f7 ctdb: make use of ctdb_canonicalize_ip_inplace() in ctdb_control_tcp_client()
We could also remove the src_addr and dest_addr helper variables
completely, but that would be too much for this commit.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2023-12-15 11:06:34 +00:00
Stefan Metzmacher
f2d9c012fc ctdb: add ctdb_canonicalize_ip_inplace() helper
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2023-12-15 11:06:34 +00:00
Stefan Metzmacher
92badd3bdd ctdb: remove unused ctdb->client_ip_list and print debug on ctdb_tcp_list instead
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15523

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2023-12-15 11:06:34 +00:00
Joseph Sutton
cec6c7e233 ctdb: Fix code spelling
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-12-08 02:28:33 +00:00
Joseph Sutton
265e3699ac ctdb: Remove trailing whitespace
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-12-08 02:28:33 +00:00
Martin Schwenke
9313731e96 ctdb-scripts: Update detect_init_style to use /etc/os-release
/etc/os-release is quite universal.  It can be found on most Linux
distros and on FreeBSD.

Attempt to use /etc/os-release to detect Red Hat, SUSE and Debian
based distros.  If /etc/os-release exists but distro is unknown then
$ID is printed as the detected distro, which will probably result in
sub-optimal behaviour, but when tracing it will at least indicate that
a new distro needs to be handled.

The only way to handle missing /etc/os-release is to set
CTDB_INIT_STYLE - see ctdb.sysconfig(5) for details.

The event script unit tests are updated to use /etc/os-release so
the new logic is exercised.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Mon Oct 30 09:19:11 UTC 2023 on atb-devel-224
2023-10-30 09:19:11 +00:00
Joseph Sutton
e3bc4d4ae0 docs-xml: Fix documentation
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-10-25 22:23:37 +00:00
Volker Lendecke
a6b66661c7 ctdb: Add "home_nodes" file to deterministic IP allocation
With a file "home_nodes" next to "public_addresses" you can assign
public IPs to specific nodes when using the deterministic allocation
algorithm. Whenever the "home node" is up, the IP address will be
assigned to that node, independent of any other deterministic
calculation. The line

192.168.21.254 2

in the file "home_nodes" assigns the IP address to node 2. Only when
node 2 is not able to host IP addresses, 192.168.21.254 undergoes the
normal deterministic IP allocation algorithm.

Signed-off-by: Volker Lendecke <vl@samba.org>

add home_nodes
Reviewed-by: Ralph Boehme <slow@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Oct 10 14:17:19 UTC 2023 on atb-devel-224
2023-10-10 14:17:19 +00:00
Volker Lendecke
ea9cbbd830 ctdb: setup $CTDB_BASE for deterministic ip alloc tests
ipalloc_deterministic() will require it in the next patch

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2023-10-10 13:14:31 +00:00
Volker Lendecke
23ccb1c0ca ctdb: Align variable signedness
ipalloc_state->num_nodes is uint32_t
Reviewed-by: Ralph Boehme <slow@samba.org>
2023-10-10 13:14:31 +00:00
Volker Lendecke
ce3243d7b2 ctdb: Reduce indentation in get_tunable_values()
Use an early return tvals; review with "git sh -b".

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2023-10-10 13:14:31 +00:00
Volker Lendecke
58ec800928 ctdb: Fix whitespace
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2023-10-10 13:14:31 +00:00
Martin Schwenke
3ee348a966 ctdb-scripts: Convert 40.vsftpd to use threshold-based fail counting
This effectively provides simple testing for the threshold-based
approach.

Add new script option CTDB_VSFTPD_MONITOR_THRESHOLDS.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Tue Oct  3 04:53:38 UTC 2023 on atb-devel-224
2023-10-03 04:53:38 +00:00
Martin Schwenke
8303c3a534 ctdb-scripts: Implement failcount handling with thresholds
This can be used for simple failure counting, without restarts, as
used in the 40.vsftpd event script.  That case will subsequently be
converted and this functionality can also be used elsewhere.

Add documentation to ctdb-script.options(5) to allow parameters that
use this to be more easily described.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2023-10-03 03:53:35 +00:00
Martin Schwenke
4981984dd4 ctdb-scripts: Avoid errors for uninitialised counters
Uninitialised counters are treated as 0, but still produce an error.

The redirect to stderr needs to come before the redirect for a missing
counter file.

The seemingly saner alternative of moving it outside the subshell
works when dash is /bin/sh (e.g. on Debian) but does not work when
bash is /bin/sh (e.g. on Fedora).

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2023-10-03 03:53:35 +00:00
Martin Schwenke
7c468d9d28 ctdb-doc: Add some subsection names in description
A subsequent commit will add a new section, which looks out of place
without these new sections.

Best reviewed with "git show -w".

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2023-10-03 03:53:35 +00:00
Martin Schwenke
749bc56876 ctdb-doc: Update CTDB manual pages to UTF-8
This will allow Unicode characters to be used, resulting in more
readable source files.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2023-10-03 03:53:35 +00:00
Martin Schwenke
8b9f464420 ctdb-daemon: Call setproctitle_init()
Commit 19c82c19c0 changed the behaviour
of prctl_set_comment() so it now calls setproctitle(3bsd) by default.

In some Linux distributions (e.g. Rocky Linux 8.8), this results in
messages like this spamming the logs:

  ctdbd: setproctitle not initialized, please either call setproctitle_init() or link against libbsd-ctor.

Most Samba daemons seem to call setproctitle_init(), so do it here.

In the longer term CTDB should also switch to using lib/util's
process_set_title(), like the rest of Samba, for more flexible process
names.

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

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Ralph Boehme <slow@samba.org>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Thu Sep 21 00:46:50 UTC 2023 on atb-devel-224
2023-09-21 00:46:50 +00:00
Joseph Sutton
c62491473a ctdb: Fix code spelling
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-09-11 02:42:41 +00:00
Martin Schwenke
dc7b48c404 ctdb-common: Set immediate mode for pcap capture
Fix a problem where ctdb_killtcp (almost always) fails to capture
packets with --enable-pcap and libpcap ≥ 1.9.1.  The problem is due to
a gradual change in libpcap semantics when using
pcap_get_selectable_fd(3PCAP) to get a file descriptor and then using
that file descriptor in non-blocking mode.

pcap_set_immediate_mode(3PCAP) says:

  pcap_set_immediate_mode() sets whether immediate mode should be set
  on a capture handle when the handle is activated.  In immediate
  mode, packets are always delivered as soon as they arrive, with no
  buffering.

and

  On Linux, with previous releases of libpcap, capture devices are
  always in immediate mode; however, in 1.5.0 and later, they are, by
  default, not in immediate mode, so if pcap_set_immediate_mode() is
  available, it should be used.

However, it wasn't until libpcap commit
2ade7676101366983bd4f86bc039ffd25da8c126 (before libpcap 1.9.1) that
it became a requirement to use pcap_set_immediate_mode(), even with a
timeout of 0.

More explanation in this libpcap issue comment:

  https://github.com/the-tcpdump-group/libpcap/issues/860#issuecomment-541204548

Do a configure check for pcap_set_immediate_mode() even though it has
existed for 10 years.  It is easy enough.

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

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Tue Aug 15 10:53:52 UTC 2023 on atb-devel-224
2023-08-15 10:53:52 +00:00
Martin Schwenke
ffc2ae616d ctdb-common: Replace pcap_open_live() by lower level calls
A subsequent commit will insert an additional call before
pcap_activate().

This sequence of calls is taken from the source for pcap_open_live(),
so there should be no change in behaviour.

Given the defaults set by pcap_create_common(), it would be possible
to omit the calls to pcap_set_promisc() and pcap_set_timeout().
However, those defaults don't seem to be well documented, so continue
to explicitly set everything that was set before.

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

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2023-08-15 09:49:38 +00:00
Martin Schwenke
d87041d896 ctdb-common: Improve error handling
Factor out a failure label, which will get more use in subsequent
commits, and only set private_data when success is certain.

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

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2023-08-15 09:49:38 +00:00
Joseph Sutton
9769b594f4 ctdb: Add missing newline to logging message
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-08-08 04:39:37 +00:00
Joseph Sutton
a8085b3dd5 ctdb: Add missing newlines to logging messages
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-08-08 04:39:36 +00:00
Martin Schwenke
f87f02f6f9 ctdb-doc: Fix documentation for ctdb event status
Behaviour was changed, documentation wasn't.

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

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Mon Aug  7 09:43:33 UTC 2023 on atb-devel-224
2023-08-07 09:43:33 +00:00
Martin Schwenke
f01a179abc ctdb-tools: Fix CID 1539212 - signed/unsigned issue
>>>     CID 1539212:  Control flow issues  (NO_EFFECT)
>>>     This greater-than-or-equal-to-zero comparison of an unsigned value is always true. "p >= 0UL".
216     		while (p >= 0 && output[p] == '\n') {

This is a real problem in the unlikely event that the output contains
only newlines.

Fix the issue by using a pointer and add a test to cover this case.

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

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2023-08-07 08:43:39 +00:00
Martin Schwenke
7920d2ff62 ctdb-tools: Improve printing of multi-line event script output
Multi-line output currently prints like this:

  OUTPUT: aaa
bbb
ccc

This is less beautiful than it could be.

Instead, print multi-line output with no inlining and each line
indented:

  OUTPUT:
    aaa
    bbb
    ccc

However, continue to inline single line output:

  OUTPUT: foo

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2023-07-28 10:48:33 +00:00
Martin Schwenke
e3c0b72c34 ctdb-tools: Always print script output in event status
When event scripts succeed they generally produce no output.  However,
when a script succeeds and produces output, such output almost
certainly contains warnings.  So, always print script output.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2023-07-28 10:48:33 +00:00
Martin Schwenke
6e4c7ae9a2 ctdb-tests: Log to stderr in statd-callout tests
Errors logged when testing statd-callout don't currently go anywhere.
This is because arguments to the hacked version of script_log() are
ignored.

Remove the hack and configure logging to stderr.

This could go in the local statd-callout.sh setup script.  However,
make it available for other script tests.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Wed Jul 19 09:57:37 UTC 2023 on atb-devel-224
2023-07-19 09:57:37 +00:00
Martin Schwenke
ef15a34d5d ctdb-scripts: Support script logging to stderr
Logging in statd-callout tests is currently useless.  This will
provide a way of seeing errors in those tests.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2023-07-19 09:01:33 +00:00
Martin Schwenke
0ac9413735 ctdb-scripts: Avoid ShellCheck warning SC2162
SC2162 read without -r will mangle backslashes.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2023-07-19 09:01:33 +00:00
Martin Schwenke
59c5010b6e ctdb-scripts: Reformat with "shfmt -w -p -i 0 -fn"
Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2023-07-19 09:01:33 +00:00
Martin Schwenke
2e2d81b92a ctdb-recoverd: CID 1509028 - Use of 32-bit time_t (Y2K38_SAFETY)
usecs is going to be passed as a uint32_t.  There is no need to
calculate it as a time_t.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2023-07-19 09:01:33 +00:00
Martin Schwenke
862fc5770c ctdb: Do not use egrep
On some platforms, egrep prints a deprecation warning to stderr:

  egrep: warning: egrep is obsolescent; using grep -E

Use grep -E instead.

This is nice and simple, so no use splitting this commit into 2
separate commits for each of tools and test.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2023-07-19 09:01:33 +00:00
Martin Schwenke
4deb178eb3 ctdb-doc: Correct bit-rotted documenation
Loading tunables is now done in ctdbd, so find another example for the
"setup" event.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2023-07-19 09:01:33 +00:00
Martin Schwenke
dbbede407f ctdb-utils: Drop unused scsi_io.c source file
It will be in the git history if we ever decide to use SCSI persistent
reservations as a cluster lock.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2023-07-19 09:01:33 +00:00
Martin Schwenke
61dfc8bc06 ctdb-server: Avoid logging a count of 0 resent calls
This fixes a little thinko in commit
80de84d36e, where this was overlooked.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Mon Jul 10 15:15:06 UTC 2023 on atb-devel-224
2023-07-10 15:15:06 +00:00
Martin Schwenke
60bf6f68e1 ctdb-tools: Switch tickle ACK sending message to INFO level
DEBUG level logging in ctdb_killtcp is very noisy.  The most important
messages when debugging are those for tickle ACKs and TCP RSTs.  TCP
RSTs are already logged at INFO level, so promote tickle ACKs to INFO
level too.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2023-07-10 14:21:30 +00:00
Martin Schwenke
6dac1da9cd ctdb-tools: Fix a typo in a log message
Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reported-by: Ulrich Sibiller <ulrich.sibiller@atos.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2023-07-10 14:21:30 +00:00
Martin Schwenke
51d0445a7d ctdb-logging: Really make NOTICE the default debug level
NOTICE level debug messages in common/run_event.c are not logged by
default.

Currently eventd ends up using ERROR, since this is specified as
LOGGING_LOG_LEVEL_DEFAULT.  It doesn't inherit the debug level from
ctdbd and only uses NOTICE level when interactive.

Change the real logging default to NOTICE and use it everywhere.

Followups might be:

* Remove the default_log_level argument to logging_conf_init()
* Kick eventd to update debug level when "ctdb setdebug" is used

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2023-07-10 14:21:30 +00:00
Martin Schwenke
d2940694c6 ctdb-tests: Run ShellCheck on event-script unit test support scripts
Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Wed Jul  5 12:16:57 UTC 2023 on atb-devel-224
2023-07-05 12:16:56 +00:00
Martin Schwenke
b2026e92d6 ctdb-tests: Avoid ShellCheck warnings
These are all trivial, so handle them in bulk.

* Change code to avoid (approximately sorted by frequency):

  SC2004 $/${} is unnecessary on arithmetic variables.
  SC2086 Double quote to prevent globbing and word splitting.
  SC2162 read without -r will mangle backslashes.
  SC2254 Quote expansions in case patterns to match literally rather than as a glob.
  SC2154 (warning): <variable> is referenced but not assigned.
  SC3037 (warning): In POSIX sh, echo flags are undefined.
  SC2016 (info): Expressions don't expand in single quotes, use double quotes for that.
  SC2069 (warning): To redirect stdout+stderr, 2>&1 must be last (or use '{ cmd > file; } 2>&1' to clarify).
  SC2124 (warning): Assigning an array to a string! Assign as array, or use * instead of @ to concatenate.
  SC2166 (warning): Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
  SC2223 (info): This default assignment may cause DoS due to globbing. Quote it.

* Locally disable checks:

  SC2034 (warning): <variable> appears unused. Verify use (or export if used externally).
  SC2086 (info): Double quote to prevent globbing and word splitting. [once]
  SC2120 (warning): <function> references arguments, but none are ever passed.
  SC2317 (info): Command appears to be unreachable. Check usage (or ignore if invoked indirectly).

While touching reads for SC2162, switch unused variables to "_"
instead of "_x", which seems to be preferred by ShellCheck.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
2023-07-05 11:18:37 +00:00
Martin Schwenke
a45a76fd19 ctdb-tests: Avoid ShellCheck warning SC2059
SC2059 (info): Don't use variables in the printf format string. Use printf '..%s..' "$foo".

Move the format string to the function and just parameterise the share
type.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
2023-07-05 11:18:37 +00:00
Martin Schwenke
58a117d3d5 ctdb-tests: Avoid ShellCheck warnings SC2046, SC2005
In ./tests/UNIT/eventscripts/scripts/local.sh line 328:
	echo $(ctdb ifaces -X | awk -F'|' 'FNR > 1 {print $2}')
             ^-- SC2046 (warning): Quote this to prevent word splitting.
             ^-- SC2005 (style): Useless echo? Instead of 'echo $(cmd)', just use 'cmd'.

Use xargs to get output on 1 line.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
2023-07-05 11:18:37 +00:00
Martin Schwenke
1190c91090 ctdb-tests: Drop unreachable code
This generates ShellCheck warnings:

In ./tests/UNIT/eventscripts/scripts/60.nfs.sh line 412:
			if [ -n "$service_check_cmd" ]; then
                                 ^----------------^ SC2031 (info): service_check_cmd was modified in a subshell. That change might be lost.

In ./tests/UNIT/eventscripts/scripts/60.nfs.sh line 413:
				if eval "$service_check_cmd"; then
                                         ^----------------^ SC2031 (info): service_check_cmd was modified in a subshell. That change might be lost.

service_check_cmd will never be set here because it is only set in a
sub-shell in rpc_set_service_failure_response().

This reverts some of commit 713ec21750.

If testcases requiring use of service_check_cmd are later added then
this will need to be redone properly.  This would probably start by
renaming this function nfs_iterate_rpc_test().

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
2023-07-05 11:18:37 +00:00
Martin Schwenke
cbda1a78dc ctdb-tests: Reformat with "shfmt -w -p -i 0 -fn"
Best reviewed with "git show -w".

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
2023-07-05 11:18:37 +00:00
Martin Schwenke
7813c979ed ctdb-tests: Drop unused test code for tunables
This is unused since loading tunables was moved to ctdbd.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
2023-07-05 11:18:37 +00:00
Martin Schwenke
92f1747448 ctdb-tests: Avoid ShellCheck warning SC2086
SC2086 Double quote to prevent globbing and word splitting.

Apparently ShellCheck is more picky about some of these than it used
to be.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
2023-07-05 11:18:37 +00:00
Martin Schwenke
37105addec ctdb-scripts: Avoid ShellCheck warnings SC2317, SC2086
New in ShellCheck 0.9.0:

  SC2317 (info): Command appears to be unreachable. Check usage (or ignore if invoked indirectly).

Also:

  SC2086 (info): Double quote to prevent globbing and word splitting.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
2023-07-05 11:18:37 +00:00
Martin Schwenke
aeb5b0adfa ctdb-tools: Avoid ShellCheck warning SC2317
New in ShellCheck 0.9.0:

  SC2317 (info): Command appears to be unreachable. Check usage (or ignore if invoked indirectly).

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
2023-07-05 11:18:37 +00:00
Christof Schmitt
4dccf5afa4 ctdb-recovery: Use correct struct ban_node_state type for state
If this codepath is hit, ctdb aborts with:

ctdb/server/ctdb_recovery_helper.c:2687: Type mismatch: name[struct ban_node_state] expected[struct node_ban_state]")
    at ../../lib/talloc/talloc.c:505

Fix this by using the correct type.

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Wed May  3 08:04:09 UTC 2023 on atb-devel-224
2023-05-03 08:04:09 +00:00
Joseph Sutton
440c3e8697 ctdb:tool: Remove unnecessary strlen()
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
2023-04-12 13:52:31 +00:00
Andreas Schneider
8f18fadd31 ctdb: Fix code spelling
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-04-11 09:06:35 +00:00
Andrew Bartlett
83fe7a0316 lib/util: Add "debug syslog format = always", which logs to stdout in syslog style
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-04-06 12:51:30 +00:00
Andreas Schneider
409ede2d1f ctdb:doc: Fix code spelling
Best reviewed with: `git show --word-diff`.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-04-04 07:31:36 +00:00
Andreas Schneider
d964700a19 ctdb:utils: Fix code spelling
Best reviewed with: `git show --word-diff`

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>

Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Mar 24 07:57:37 UTC 2023 on atb-devel-224
2023-03-24 07:57:37 +00:00
Andreas Schneider
8ccd915587 ctdb:utils: Remove trailing whitespaces in scsi_io.c
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
2023-03-24 07:01:31 +00:00
Andreas Schneider
88ee870e67 ctdb:tool: Fix code spelling
Best reviewed with: `git show --word-diff`

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
2023-03-24 07:01:31 +00:00
Andreas Schneider
9a37aa3969 ctdb:tests: Fix code spelling
Best reviewed with: `git show --word-diff`

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
2023-03-24 07:01:31 +00:00
Andreas Schneider
7aeed61dc5 ctdb:tcp: Fix code spelling
Best reviewed with: `git show --word-diff`

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
2023-03-24 07:01:31 +00:00
Andreas Schneider
7749df4992 ctdb:server: Fix code spelling
Best reviewed with: `git show --word-diff`

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
2023-03-24 07:01:31 +00:00
Andreas Schneider
19f418b68f ctdb:server: Remove trailing whitespaces in ctdb_server.c
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
2023-03-24 07:01:31 +00:00
Andreas Schneider
59af504999 ctdb:server: Remove trailing whitespaces in ctdb_recover.c
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
2023-03-24 07:01:31 +00:00
Andreas Schneider
200bc1f937 ctdb:include: Fix code spelling
Best reviewed with: `git show --word-diff`

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
2023-03-24 07:01:31 +00:00
Andreas Schneider
44bde7a788 ctdb:include: Remove trailing whitespaces in ctdb_protocol.h
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
2023-03-24 07:01:31 +00:00
Andreas Schneider
2e10481dac ctdb:common: Fix code spelling
Best reviewed with: `git show --word-diff`

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
2023-03-24 07:01:31 +00:00
Andreas Schneider
6d7d82938b ctdb:client: Fix code spelling
Best reviewed with: `git show --word-diff`

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
2023-03-24 07:01:31 +00:00