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

936 Commits

Author SHA1 Message Date
Martin Schwenke
e66cdd8312 ctdb-killtcp: Store retry interval in killtcp structure
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
93f3cd6650 ctdb-killtcp: Don't count attempts for individual connections
This made sense when connections were individually queued in the
daemon.  However, they're now done in batch so just keep an overall
count.

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
402f3c0460 ctdb-killtcp: Keep track of number of kill attempts and maximum allowed
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
7e5eab139d ctdb-killtcp: Filter out sent packets
When previously killing TCP connections via the daemon there was some
latency due to each kill being sent to the daemon via a separate
control.  This probably meant that when doing a 2-way kill the tickle
ACKs sent to the client end of a connection would not interfere with
listening for the reply ACK from the server end.  Now that there is no
latency, the tickle ACK or RST sent to the client end can be seen as
the reply to the server end tickle ACK, and vice-versa.

To avoid this, throw away packets that look like we sent them.

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
bba31152df ctdb-system: Return window size and RST bit when reading TCP packets
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
d7fa4b76c5 ctdb-killtcp: Clarify a debug message
The end of the connection in parentheses is not the end being killed.

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
cb2fee2c43 ctdb-killtcp: Set debug level via environment variable CTDB_DEBUGLEVEL
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
5492f874d9 ctdb-killtcp: Don't send initial tickle ACK during setup
Since they're being done in batch, just schedule an event to traverse
all the connections.

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
4105ca953e ctdb-killtcp: Drop unnecessary casts
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
7aea3c12fb ctdb-killtcp: Drop check to see if capture socket can be read
The handler won't be called unless there is something to read.

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
2e1e1e8268 ctdb-killtcp: Merge "common" killtcp code into helper
ctdb_killtcp.c is now the only place it is needed.

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
efd371659f ctdb-tools: Drop "ctdb killtcp" command
It is now handled by a standalone helper.

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
1924323af6 ctdb-killtcp: New helper ctdb_killtcp
This will allow killing of TCP connections without daemon involvement.

It looks strange that the common code for daemon and helper is in the
server directory.  Having it in the server directory means less
temporary changes to the build configuration.  This code will move
into the helper itself and will no longer be used by the daemon.

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
d678684695 ctdb-tools: Drop "ctdb rebalancenode"
This was a workaround for trying to ensure public IP addresses are
properly rebalanced after running "ctdb addip" on multiple nodes.
"ctdb reloadips" is a better solution.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-03-10 03:34:19 +01:00
Martin Schwenke
aaa57fbcb3 ctdb-tools: Drop "ctdb rebalanceip"
This is undocumented and is not needed.  It was a workaround for
trying to ensure public IP addresses are properly rebalanced after
running "ctdb addip" on multiple nodes.  "ctdb reloadips" is a better
solution.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-03-10 03:34:19 +01:00
Martin Schwenke
00f7d18304 ctdb: Drop unnecessary defines of TEVENT_DEPRECATED
These have been scattered around the code so that
tevent_loop_allow_nesting() can be called.  However, only the main
daemon and some tests currently use nested event loops.
TEVENT_DEPRECATED is already defined in the places where it is needed.

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 Feb 26 07:11:29 CET 2016 on sn-devel-144
2016-02-26 07:11:29 +01:00
Amitay Isaacs
9f94620a30 ctdb-common: Use documented names for protocol family in socket()
Instead of using PF_*, use AF_*.

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

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2016-02-02 08:42:09 +01:00
Martin Schwenke
df6cca2bc0 ctdb-tools: Drop support for setting and viewing NAT gateway capability
This is no longer used.

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
411ccb98c3 ctdb/tools: Update ctdb CLI tool to call ctdb_natgw
The "natgwlist" command is no longer marked "auto all" and is also
marked "without daemon".  That latter is not strictly true because
ctdb_natgw needs the daemon so a subsequent invocation of "ctdb
nodestatus" will work.  However, "without daemon" is used here because
the top-level "ctdb natgwlist" does not need to open a connection to
the daemon.  It just needs to invoke ctdb_natgw.

Update tests to suit.

It would make sense to make "ctdb natgw" generally call out to
ctdb_natgw, passing all argument.  However, that can be done later.

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
1538fc4585 ctdb-tools: Add standalone ctdb_natgw tool script
This is intended to replace the use of "ctdb natgwlist" in 11.natgw
and provide different views of the NAT gateway status.

It replaces the use of CTDB_NATGW_SLAVE_ONLY=yes with a "slave-only"
keyword in the NAT gateway nodes file.  This means the nodes file must
be consistent on all nodes in a NAT gateway group.

Note that this script is not yet integrated, so there are no behaviour
or documentation changes.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-01-25 07:18:25 +01:00
Amitay Isaacs
27bc80cf6a ctdb-tool: Use new debug level API
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-11-16 00:46:15 +01:00
Amitay Isaacs
3b71d05927 ctdb-tools: Use replace headers instead of system headers
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-11-04 00:47:16 +01:00
Amitay Isaacs
44e611ddcf ctdb-daemon: Rename struct ctdb_control_get_ifaces to ctdb_iface_list_old
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-11-04 00:47:16 +01:00
Amitay Isaacs
ecfaef5031 ctdb-daemon: Rename struct ctdb_control_public_ip_info to ctdb_public_ip_info_old
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-11-04 00:47:16 +01:00
Amitay Isaacs
c4e9d616ae ctdb-daemon: Rename struct ctdb_control_iface_info to ctdb_iface
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-11-04 00:47:15 +01:00
Amitay Isaacs
417077c8a7 ctdb-daemon: Rename struct ctdb_control_transdb to ctdb_transdb
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-11-04 00:47:15 +01:00
Amitay Isaacs
357bc60947 ctdb-daemon: Rename struct ctdb_control_ip_iface to ctdb_addr_info_old
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-11-04 00:47:15 +01:00
Amitay Isaacs
ca481354c0 ctdb-daemon: Rename struct ctdb_control_tcp_tickle_list to ctdb_tickle_list_old
Also remove unnecessary struct ctdb_tcp_wire_array.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-11-04 00:47:15 +01:00
Amitay Isaacs
e34afd8516 ctdb-daemon: Rename struct srvid_request_data to ctdb_disable_message
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-11-04 00:47:15 +01:00
Amitay Isaacs
cf1ac77b3a ctdb-daemon: Rename struct srvid_request to ctdb_srvid_message
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-11-04 00:47:15 +01:00
Amitay Isaacs
d4de4527b0 ctdb-daemon: Rename struct ctdb_ban_time to ctdb_ban_state
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-11-04 00:47:15 +01:00
Amitay Isaacs
92a6ac18ae ctdb-daemon: Rename struct ctdb_tcp_connection to ctdb_connection
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-11-04 00:47:15 +01:00
Amitay Isaacs
699ee0df94 ctdb-daemon: Rename struct ctdb_server_id_list to ctdb_client_id_list_old
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-11-04 00:47:15 +01:00
Amitay Isaacs
d858c210a7 ctdb-daemon: Rename struct ctdb_server_id to ctdb_client_id
This is to avoid clash with samba structure server_id.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-11-04 00:47:15 +01:00
Amitay Isaacs
645cd43200 ctdb-daemon: Rename struct ctdb_dbid_map to ctdb_dbid_map_old
Match struct ctdb_dbid as per protocol/protocol.h

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-11-04 00:47:15 +01:00
Amitay Isaacs
75572bd2a3 ctdb-daemon: Rename struct ctdb_db_statistics to ctdb_db_statistics_old
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-11-04 00:47:14 +01:00
Amitay Isaacs
b45bc4ce4b ctdb-daemon: Rename struct ctdb_statistics_wire to ctdb_statistics_list_old
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-11-04 00:47:14 +01:00
Amitay Isaacs
b99436e425 ctdb-daemon: Rename struct ctdb_rec_data to ctdb_rec_data_old
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-11-04 00:47:14 +01:00
Amitay Isaacs
04eaa077aa ctdb-daemon: Rename struct ctdb_all_public_ips to ctdb_public_ip_list_old
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-11-04 00:47:14 +01:00
Amitay Isaacs
afc5d8a442 ctdb-daemon: Rename struct ctdb_node_map to ctdb_node_map_old
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-11-04 00:47:14 +01:00
Amitay Isaacs
f55889d2c9 ctdb-daemon: Rename enum ctdb_eventscript_call to ctdb_event
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-11-04 00:47:13 +01:00
Amitay Isaacs
e7c9e50916 ctdb-daemon: Rename struct ctdb_scripts_wire to ctdb_script_list_old
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-11-04 00:47:13 +01:00
Amitay Isaacs
4647787773 ctdb-daemon: Separate prototypes for common client/server functions
This groups function prototypes for common client/server functions in
common/common.h and removes them from ctdb_private.h.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-10-30 02:00:27 +01:00
Amitay Isaacs
ded94c426b ctdb-build: Calculate correct version when building from tarball
When building standalone ctdb from git repo, samba_version_file correctly
includes git sha in VERSION string.  When building standalone ctdb from
tarball, samba_version_file puts UNKNOWN in the VERSION string.

Use the packaged include/ctdb_version.h file to set the correct git sha.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-10-30 02:00:27 +01:00
Amitay Isaacs
01c6c90e98 ctdb-daemon: Remove dependency on includes.h
Instead of includes.h, include the required header files explicitly.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-10-30 02:00:27 +01:00
Amitay Isaacs
2fdb332fad ctdb-daemon: Stop using tevent compatibility definitions
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-10-30 02:00:27 +01:00
Amitay Isaacs
7084cb92e2 ctdb-include: Move include/internal/cmdline.h to common/
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-10-30 02:00:27 +01:00
Amitay Isaacs
b900adc55c ctdb-daemon: Separate prototypes for system specific functions
This groups function prototypes for system specific functions in
common/system.h and removes them from ctdb_private.h.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-10-30 02:00:27 +01:00
Amitay Isaacs
af99846ac5 ctdb-tool: Remove repack command
The databases are repacked automatically during vacuuming when the
freelist size grows beyond configured threshold (RepackLimit).

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-10-27 04:15:15 +01:00
Martin Schwenke
8c2048b9d5 ctdb-tools: Support "ctdb ip all" as equivalent to "ctdb ip -n all"
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-10-23 03:43:26 +02:00
Amitay Isaacs
62f1e2579a ctdb-daemon: Replace ctdb_message with srvid abstraction
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-10-07 14:53:28 +02:00
Amitay Isaacs
ba56d852cb ctdb-daemon: Remove ctdb from traverse_callback
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-10-07 14:53:28 +02:00
Amitay Isaacs
4f155e77a8 ctdb-daemon: Rename ctdb_control_wipe_database to ctdb_control_transdb
The same structure is required in new controls for database transactions.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-10-07 14:53:27 +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
56fd37ba0d ctdb-tools: Drop vacuum.log from ctdb_diagnostics
This hasn't existed for a long time.

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
e79877a230 ctdb-tools: Add dbstatistics to ctdb_diagnostics
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Sep  7 10:00:54 CEST 2015 on sn-devel-104
2015-09-07 10:00:54 +02:00
Martin Schwenke
bce6a386d3 ctdb-daemon: Drop struct ctdb_control_killtcp
Just use ctdb_tcp_connection.  It is the same.  There are no external
users.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
2015-09-07 07:01:13 +02:00
Volker Lendecke
9638742799 ctdb: Fix some clang uninitialized errors
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2015-08-19 08:17:23 +02:00
Amitay Isaacs
71b89b2b7a ctdb-tool: Correctly print timed out event scripts output
The timed out error is ignored for certain events (start_recovery,
recoverd, takeip, releaseip).  If these events time out, then the debug
hung script outputs the following:

 3 scripts were executed last releaseip cycle
 00.ctdb              Status:OK    Duration:4.381 Thu Jul 16 23:45:24 2015
 01.reclock           Status:OK    Duration:13.422 Thu Jul 16 23:45:28 2015
 10.external          Status:DISABLED
 10.interface         Status:OK    Duration:-1437083142.208 Thu Jul 16 23:45:42 2015

The endtime for timed out scripts is not set.  Since the status is not
returned as -ETIME for some events, ctdb scriptstatus prints -ve duration.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-07-22 11:56:24 +02:00
Martin Schwenke
b71d18d2dc ctdb-tools: Avoiding printing "(null)" on "ctdb eventscript" error
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-07-14 09:57:17 +02:00
Christof Schmitt
cd55349e9b ctdb: Accept hex format for pdelete and ptrans commands
Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-07-08 02:54:26 +02:00
Christof Schmitt
663db9fbb0 ctdb: Create helper function for optional hex input
Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-07-08 02:54:25 +02:00
Christof Schmitt
cdbc6d92c6 ctdb: Accept the key in hex format for the pstore command
This follows the same pattern as the tstore command, and it allows
specifying key strings with a trailing \0 character.

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Jul  6 23:23:22 CEST 2015 on sn-devel-104
2015-07-06 23:23:22 +02:00
Volker Lendecke
b8ac9853b0 ctdb: Fix the O3 developer build
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-04-21 19:37:16 +02:00
Rajesh Joseph
a689cd5d95 ctdb: Coverity fix for CID 1125625
Memory allocated by ctdb_sys_find_ifname is not
freed by the caller.

Signed-off-by: Rajesh Joseph <rjoseph@redhat.com>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-04-17 14:12:19 +02:00
Martin Schwenke
ffbe0a6def ctdb-tools: Drop the recovery from "reloadnodes"
A recovery is not required: when deleting a node it should already be
disconnected and when adding a node it will also be disconnected.  The
new sanity checks in "reloadnodes" ensure that these assumptions are
met.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-04-07 07:43:13 +02:00
Martin Schwenke
13dc4a9842 ctdb-tool: Update "reloadnodes" to disable recoveries
If a recovery occurs when some nodes have reloaded and others haven't
then the nodemaps with be inconsistent so bad things will happen.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-04-07 07:43:13 +02:00
Martin Schwenke
181658f5bb ctdb-tools: Fix spurious messages about deleted nodes being disconnected
The code was too "clever".  The 4 different cases should be separate.
The "node remains deleted" case doesn't need the IP address comparison
(always 0.0.0.0) or the disconnected check.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-04-07 07:43:12 +02:00
Martin Schwenke
c8918b70b9 ctdb-tools: Use a broadcast to connected nodes for "reloadnodes"
There is no reason to serialise these or even handle remote nodes
first.  Using a broadcast is more efficient and is less code.

Update expected test results to reflect changed order of messages.

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 Mar 23 15:04:00 CET 2015 on sn-devel-104
2015-03-23 15:04:00 +01:00
Martin Schwenke
1cebd75f62 ctdb-tools: Sanity check changes before processing "reloadnodes"
"ctdb reloadnodes" currently does no sanity checking of the nodes
file.  This can cause chaos if a line is deleted from the nodes file
rather than commented out.  It also repeatedly produces a spurious
warning for each deleted node, even if the node was deleted a long
time ago.

Instead compare the nodemap with the contents of the local nodes file
to sanity check before attempting any reloads.  Note that this is
still imperfect if the nodes files are inconsistent across nodes but
it is better.  Also ensure that any nodes that are to be deleted are
already disconnected.  Avoid trying to talk to deleted nodes.

The current implementation is a bit unfortunate when it comes to
deleting nodes.  The most obvious alternative to the above complexity
would be to reloadnodes on the specified node first, then fetch the
node map (in which newly deleted nodes would be marked as such) and
then handle the remote nodes.  However, the implementation of
reloadnodes is asynchronous and it only actions the reload after 1
second.  This is presumably to avoid the recovery master noticing the
inconsistency between nodemaps and triggering a recovery before all
nodes have had their nodemaps updated.

Note that this recovery can still occur if the check is done at an
inconvenient time.  A better long term approach might be to quiesce
the recovery master checks while reloadnodes is in progress.

Update a unit test to reflect the change.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-23 12:23:12 +01:00
Martin Schwenke
16c79eb887 ctdb-tools: Add cross-node file comparison to "reloadnodes"
This compares the nodes file on the current node with that on all
nodes.  If any are different then do not reload nodes.

If any nodes files can't be fetched then do not reload nodes.  This
could be because some nodes are running an older version without this
feature.  This is unsupported: why make a major cluster
reconfiguration while a cluster is half upgraded?

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-23 12:23:12 +01:00
Martin Schwenke
8e12e112f8 ctdb-tools: "reloadnodes" should only run against current node
It should not be possible to specify "-n <othernode>", unless
<othernode> is the current node.  To support this, add new function
assert_current_node_only().

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-23 12:23:12 +01:00
Martin Schwenke
77e879253b ctdb-tools: Remove unused struct pnn_node and function read_pnn_node_file()
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-23 12:23:12 +01:00
Martin Schwenke
3703e8aadd ctdb-tools: Reimplement read_natgw_nodes_file() using ctdb_read_nodes_file()
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-23 12:23:12 +01:00
Martin Schwenke
c5538a464f ctdb-tools: Reimplement read_nodes_file() using ctdb_get_nodes_file()
Update the implementation of "ctdb xpnn" and "ctdb listnodes"
accordingly.  Update associated tests too.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-23 12:23:12 +01:00
Martin Schwenke
a3f39ae7d7 ctdb-tools: Drop a debug message to DEBUG level
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
c3706e7fb0 ctdb-tool: Print a warning when setting an obsolete tunable variable
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
2d480792e7 ctdb-tools: Bracket IP addresses in onnode (for IPv6)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-12-05 21:02:40 +01:00
Martin Schwenke
550fb8ce87 ctdb-tool: Fix "ctdb -Y ifaces" output to have trailing delimiters
In the CTDB CLI tool source code and the documentation example.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-12-05 21:02:40 +01:00
Martin Schwenke
55df9c86c1 ctdb-tools: Update onnode and ctdb-diagnostics to use ctdb -X
Also update onnode unit tests.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-12-05 21:02:40 +01:00
Martin Schwenke
7428f809a7 ctdb-tools: Add -X option for machine parsable output with separator '|'
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-12-05 21:02:39 +01:00
Martin Schwenke
3b90e45bae ctdb-tools: Add -x option to specify delimiter for machine readable output
To support this, update printm() to replace ':' in format string with
options.machineseparator, which is a string but must contain a single
character.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-12-05 21:02:39 +01:00
Martin Schwenke
fbacbb9c78 ctdb-tools: Produce machine readable output with new function printm()
printm() is a printf(3) replacement and must be used to printing any
machine readable output.  It currently just calls vprintf(3).  Later
it will change the field delimiter.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-12-05 21:02:39 +01:00
Amitay Isaacs
a0628e317d ctdb-vacuum: Track time for vacuuming in database statistics
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2014-12-05 14:43:07 +01:00
Amitay Isaacs
a54db687ac ctdb: Rename CTDB_VERSION to CTDB_PROTOCOL
CTDB_VERSION really is the ctdb protocol version.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-10-28 05:42:05 +01:00
Martin Schwenke
a22c8ca056 ctdb-logging: Rework debug level parsing
Put declarations into ctdb_logging.h, factor out some common code,
clean up #includes.

Remove the check so see if the 1st character of the debug level is
'-'.  This is wrong, since it is trying to check for a negative
numeric debug level (which is no longer supported) and would need to
be handled in the else anyway.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-10-28 05:42:04 +01:00
Amitay Isaacs
470af88147 ctdb-tools: Fix heap-use-after-free problem
Found by address sanitizer.

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

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Fri Oct 17 12:56:02 CEST 2014 on sn-devel-104
2014-10-17 12:56:02 +02:00
Martin Schwenke
b544073653 ctdb-logging: Remove log ringbuffer
As far as we know, nobody uses this and it just complicates the
logging subsystem.

Remove all ringbuffer code and documentation.  Update the local
daemons startup code correspondingly.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
2014-10-06 12:34:32 +02:00
Martin Schwenke
acf26089f1 ctdb-util: Rename db_wrap to tdb_wrap and make it a build subsystem
This makes it consistent with Samba, to ease transition.

Update unit test code to link to with tdb_wrap instead of including
db_wrap.c.

There are some potential whitespace fixes in this commit that have
been ignored.  CTDB's lib/tdb_wrap will be deleted after the
transition to Samba's lib/tdb_wrap, so there's no point polishing it
too much.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-09-10 01:36:15 +02:00
Martin Schwenke
6e1568149e ctdb-tools: Move definition of timeval_delta() to tools/ctdb.c
This function is only used in this file.  Samba's lib/util doesn't
have timeval_delta(), so staging a clean transition.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-09-10 01:36:15 +02:00
Martin Schwenke
a4e76b58a5 ctdb-util: Add extra max_size argument to file_lines_load()
This is part of a migration to Samba's lib/util.  CTDB always passes 0
(i.e. no max_size) so use a simple assert() to enforce this, rather
than changing a lot of code that will be discarded anyway.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-09-10 01:36:15 +02:00
Martin Schwenke
c1558adeaa ctdb: Use sys_read() and sys_write() to ensure correct signal interaction
... and avoid compiler warnings in some cases.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-08-21 04:46:13 +02:00
Martin Schwenke
72fa984423 ctdb-tools: Be more helpful when CTDB CLI tool is run on unconfigured node
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-08-21 04:46:13 +02:00
Martin Schwenke
26a02a64cd ctdb-tools: Factor out new function find_node_xpnn() from control_xpnn()
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-08-21 04:46:13 +02:00
Amitay Isaacs
72c6500ee4 ctdb-tools: There is no need for forcing a recovery
This effectively reverts commit 442953c540.
The correct way of telling recovery daemon to trigger a database recovery is
by setting recovery mode to active.  There is no need to freeze databases as
recovery master will do that across the cluster anyway.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2014-07-07 13:29:49 +02:00
Amitay Isaacs
4f6d668cfa ctdb-build: Use CTDB_ETCDIR instead of ETCDIR/ctdb
This avoids hardcoding path components in source.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2014-06-24 07:23:13 +02:00
Martin Schwenke
4dd382296d ctdb-tools-ctdb: Make natgwlist and lvsmaster more resilient
Recent changes have caused these commands to attempt to get
capabilities from all nodes before doing further filtering.  This
means that capabilities are unnecessarily fetched from nodes that are
unlikely to be the master.  If such a node does not answer the control
then many nodes can fail to calculate the master node.  In the case of
natgwlist this will cause "monitor" events to fail resulting in
unhealthy nodes.

Restore the behaviour where capabilities are only fetched for a node
that will be the master if it has the desired flags.

Although this masks a problem where a connected node is not replying,
it can help to avoid an outage in some cases.

Add supporting tests and infrastructure.  Infrastructure just lets a
timeout be faked - just for ctdb_ctrl_getcapabilities_stub() so far.
First test checks that this infrastructure works if the first node
times out in natgwlist.  Second test checks the case worked around by
the above fix - that is, no failure when a node with PNN beyond the
NATGW master can time out.

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 May 29 05:59:37 CEST 2014 on sn-devel-104
2014-05-29 05:59:37 +02:00
Martin Schwenke
c1deb87fb7 ctdb-tools-ctdb: scriptstatus should not count disabled scripts
script_status->num_scripts is used as the count in this message:

  "%d scripts were executed last %s cycle\n"

However, script_status->num_scripts includes disabled scripts, which
are never actually executed.

Instead, count the number of scripts that aren't disabled and make the
message print that.

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 May 28 02:27:48 CEST 2014 on sn-devel-104
2014-05-28 02:27:48 +02:00
Amitay Isaacs
581ee2e4c3 ctdb-tools/ctdb: Unlock records before closing tdb database
Now freeing ctdb_db context will close the tdb database.  So make sure
all the locks are released (by freeing record handles or memory context
from which record handles are allocated) before freeing ctdb_db context.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-04-23 14:49:07 +02:00
Amitay Isaacs
a1e1b81b9c ctdb-tools/ctdb: Detach databases only if all nodes disallow client access
This makes sure that AllowClientDBAttach is set to 0 before detaching any
databases.

If someone enables the tunable between checking of tunable and actual
detaching of databases, then they deserve what they get. :-)

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-04-23 14:49:07 +02:00
Martin Schwenke
ce8ac88b96 ctdb-tools-ctdb: Drop disconnected nodes when filtering by capability
Commit ba69742ccd missed the point of
filtering disconnected nodes while limiting the nodemap to those in
the NAT gateway group.  It was really to avoid trying to fetch
capabilities from disconnected nodes.  This should be explicitly done
in filter_nodemap_by_capabilities(), otherwise "ctdb natgwlist" simply
fails when there is a disconnected node.

Note that the alternate solution where filter_nodemap_by_flags() is
called before filter_nodemap_by_capabilities() would not be not
correct.  Filtering on flags first can produce a "healthier" set of
nodes where none of them have the NAT gateway capability.

Also extend stub for ctdb_ctrl_getcapabilities() to fail when trying
to get capabilities from a disconnected node and add a corresponding
test to confirm that "ctdb natgwlist" is no longer broken.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-04-14 03:52:40 +02:00
Amitay Isaacs
a3fdb56376 ctdb-tools/ctdb: Add ctdb detach command to detach databases
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2014-04-14 03:52:39 +02:00
Martin Schwenke
441e099837 ctdb-tools-ctdb: Parse IP addresses when reading a list from a file
This way this logic is centralised.  It also means that the IP address
comparisons in the NAT gateway code are IPv6 safe.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-03-23 04:20:14 +01:00
Martin Schwenke
fad2b6b074 ctdb-tools-ctdb: Remove redundant filtering of trailing empty lines
There is a check for empty lines in the loop just below.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-03-23 04:20:14 +01:00
Martin Schwenke
555aa06c41 ctdb-tools-ctdb: Use DLIST_ADD_END() to avoid reversing the list
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-03-23 04:20:14 +01:00
Martin Schwenke
91895b33c5 ctdb-tools-ctdb: Factor out function read_pnn_node_file()
Factor it from read_nodes_file().  Use it there and in
read_natgw_nodes_file().

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-03-23 04:20:14 +01:00
Martin Schwenke
9bede49474 ctdb-tools-ctdb: Read NAT gateway nodes from a separate function
Now it gets easier to refactor.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-03-23 04:20:14 +01:00
Martin Schwenke
ba69742ccd ctdb-tools-ctdb: Add and use function filter_nodemap_by_natgw_nodes()
Add another filter function, like the ones for capabilities and flags
to, for filtering by NAT gateway nodes.  This makes the main
natgw_list function more readable.

Note that this drops the early filtering of disconnected nodes, so
they will now be listed in a NAT gateway group.  This makes sense.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-03-23 04:20:14 +01:00
Martin Schwenke
e728a35dc1 ctdb-tools-ctdb: Update LVS commands to use filter_nodemap_by_flags()
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-03-23 04:20:14 +01:00
Martin Schwenke
26c9a591e5 ctdb-tools-ctdb: Update LVS commands to use filter_nodemap_by_capabilities()
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-03-23 04:20:14 +01:00
Martin Schwenke
5fb7e386ac ctdb-tools-ctdb: Fixes for "lvs" and "lvsmaster" commands
The index of the nodes array in nodemap isn't the PNN.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-03-23 04:20:14 +01:00
Martin Schwenke
33b1fcbd70 ctdb-tools-ctdb: Generalise find_natgw() -> filter_nodemap_by_flags()
Instead of just finding the first node that doesn't have any flags in
flag_mask set, change it into a function that filters a nodemap to
exclude nodes with the given flags.

This makes the NATGW code simpler but also provides a function that
can be used in other code.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-03-23 04:20:14 +01:00
Martin Schwenke
798bd58370 ctdb-tools-ctdb: Update natgwlist to filter nodes by NATGW capability
Check capabilities once to build a filtered node list instead of
repeatedly checking capabilities

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-03-23 04:20:14 +01:00
Martin Schwenke
a947cf6c0c ctdb-tools-ctdb: Don't close stderr when running without_daemon commands
It looks like the original without_daemon code still tried to
establish a client connection to the daemon.  Closing stderr looks to
be a cheap way of hiding the errors when this failed.

However, later cleanups avoid the client connection altogether, so do
not close stderr.  Now debug output from without_daemon commands
actually appears.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2014-03-23 04:20:14 +01:00
Amitay Isaacs
35eb6cb521 ctdb-doc: Fix usage string for ctdb readkey/writekey
Signed-off-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Fri Jan 31 07:52:46 CET 2014 on sn-devel-104
2014-01-31 07:52:46 +01:00
Martin Schwenke
0fe178eb3a ctdb-tools/ctdb: Improve error checking when parsing node string
If a node isn't numeric then it is silently converted to 0.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
2013-11-27 18:46:17 +01:00
Amitay Isaacs
d7df54873a ctdb-tools/ctdb: Fix tstore command to generate ltdb header internally
This fixes an alignment discrepancy on 32-bit vs 64-bit platforms.

  sizeof(struct ctdb_ltdb_header) = 20  (32-bit)
                                  = 24  (64-bit)

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Michael Adam <obnox@samba.org>
2013-11-27 18:46:16 +01:00
Martin Schwenke
1dcf01f4a6 ctdb-scripts: Rewrite statd-callout to avoid 10 minute lag
This is naive and assumes no performance problems when updating
persistent DBs.  It also does no error handling.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Michael Adam <obnox@samba.org>
2013-11-27 18:46:16 +01:00
Martin Schwenke
e850cddcc4 ctdb-tools/ctdb: New ptrans command
Also add test.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Michael Adam <obnox@samba.org>
2013-11-27 18:46:16 +01:00
Martin Schwenke
297a4a640d ctdb-onnode: New -i option to stop stdin from being closed
This can be useful for piping data to onnode in certain circumstances.

There are now also enough command-line options that they should
definitely be alphabetically ordered.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
2013-11-27 18:46:16 +01:00
Martin Schwenke
028fe930b6 ctdb-recoverd: Fix backward compatibility for CTDB_SRVID_TAKEOVER_RUN
When running a mixed version cluster, compatibility with older
versions was was broken during recent refactorisation.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Michael Adam <obnox@samba.org>
2013-11-27 18:46:16 +01:00
Amitay Isaacs
b2b348c219 ctdb-tools/ctdb: Fix db commands when dbid is given instead of name
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Michael Adam <obnox@samba.org>
2013-11-27 18:46:15 +01:00
Amitay Isaacs
b8f4887ab5 ctdb-tools/ctdb: Coverity fixes
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Michael Adam <obnox@samba.org>
2013-11-19 17:13:05 +01:00
Martin Schwenke
d9e2411ace tools/ctdb: Fix documentation string for ban command
Ban time of 0 is not supported.

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

(This used to be ctdb commit c072eb1f6488f94f83a6d3a81d88bf29ad866943)
2013-10-29 17:14:55 +11:00
Martin Schwenke
e8de58abd7 tools/onnode: Fix healthy/ok node handling
This bit-rotted a long time ago when the "ThisNode" column was added
to "ctdb -Y status" output.  The fake "ctdb -Y status" output in the
test was never updated to reflect this change.

Instead of making sure that all columns are "0", just check that
they're not "1".  This implicitly ignores "Y" and "N" in this
"ThisNode" column without having to do anything else clever.

Also update associated tests.  The main "ctdb ok" test had a duplicate
opening line for a here document, which was tickled by this change.

This fixes samba bz#8122.

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

onnode test fixup

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

(This used to be ctdb commit 01a46205c3a3d6609dc0b0324319b89667dffa32)
2013-10-29 17:14:55 +11:00
Martin Schwenke
27a6343369 tools/ctdb: CTDB_BASE is the default location of configuration files
Ensure that environment variable CTDB_BASE is set.

Update defaults for nodes and natgw_nodes to use CTDB_BASE.

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

(This used to be ctdb commit 2b6dc0d2799f3563b767622b6f9246450aa4036b)
2013-10-22 15:37:54 +11:00
Amitay Isaacs
c4a80c7a67 tools/ctdb: Remove setdbseqnum command
This command was added to test persistent database recovery with sequence
numbers.  With the new persistent transaction code, sequence numbers get
updated automatically, so there is no need for this command.

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

(This used to be ctdb commit 14bfd22fad1a5fd27eede1be7fccbaed9466e13e)
2013-10-04 15:47:11 +10:00
Martin Schwenke
7a3e2f1627 tools/ctdb: Stop return value from being clobbered in control_lvsmaster()
ret is initialised too early and is clobbered by the call to
ctdb_ctrl_getcapabilities().  Initialising it later means that the
function returns -1 when no LVS master is found.

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

(This used to be ctdb commit 3296559c43e70f755fcf2c06677891e0319c8142)
2013-10-04 15:15:35 +10:00
Amitay Isaacs
2b68d143cb tools/ctdb: Pass memory context for returning nodes in parse_nodestring
Signed-off-by: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit 1585a8e275b0143e5e46311b3d5e9785119f735f)
2013-10-04 15:15:35 +10:00
Amitay Isaacs
03379e332c tools/ctdb: Do not use libctdb for commandline tool
Signed-off-by: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit cd66282c635cf53386d8970b89c895076ea21cbd)
2013-10-04 15:15:34 +10:00
Amitay Isaacs
f165ed1594 tools/ctdb: When printing TDB data as a string, use correct length of the string
Signed-off-by: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit d94a10f93a0925b17458d009e604966666b3d880)
2013-10-04 15:15:27 +10:00
Amitay Isaacs
d3783ae140 tools/ctdb: Remove un-implemented ctdb vacuum command
Signed-off-by: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit 8b238852884004a56f76a1762199c338864d1249)
2013-10-04 15:15:27 +10:00
Martin Schwenke
613313fa52 tool/ltdbtool: -h option does not require an argument
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 9e18f3c173863919587e25d704f66372624ed8ed)
2013-09-25 14:35:46 +10:00
Martin Schwenke
5b2c8ba880 tools/ctdb: Fix help messages for ctdb commands
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 49c87699fad151933a0aefebfee968fc850e6383)
2013-09-25 14:34:55 +10:00
Martin Schwenke
058037d58c tools/ctdb: Ban time of 0 is invalid
Apparently it used to mean a permanent ban but it is unclear if this
was ever supported.

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

(This used to be ctdb commit c8a6e5ce579e2fe320c40268e7e9ddfe68b8cd30)
2013-09-25 14:34:55 +10:00
Martin Schwenke
236b2524de tools/ctdb: Use the standard long timeout when disabling takeover runs
This means that takeover runs will be disabled for about as long as the
reloadips control can take to complete.

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

(This used to be ctdb commit 6d44657a5e5b0df22bab2d487a503dd1c5ba79b4)
2013-09-19 12:56:50 +10:00
Martin Schwenke
5f0d85d4db tools/ctdb: Fix arguments/semantics of rebalance node
There's no reason why specifying a node should be compulsory.  This is
a cluster-wide operation because it is implemented by the recovery
master so multiple nodes should not be specified using -n.  However,
the command should be able to specify multiple nodes so let it have
its own nodestring argument.

This change should be backward compatible with the old requirement of
specifying a single node via -n.

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

(This used to be ctdb commit 0846c00597adb66bba8c9dbf63443d0c2f91a7d1)
2013-09-19 12:54:32 +10:00
Martin Schwenke
c484361076 tools/ctdb: Make rebalancenode more robust
Use a broadcast instead of trying to win the race of determining the
recovery master and then sending the message before the recovery
master changes.

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

(This used to be ctdb commit ac946ee4ad01b1e5cd1006930b9f8a190a0a58ba)
2013-09-19 12:54:32 +10:00
Martin Schwenke
6f1935ea6d tools/ctdb: Reimplement reloadips
This implementation disables takeover runs on all nodes before trying
to reload IPs.  It also takes "all" or the list of PNNs as an argument
to the command instead of to -n.  -n can still be specified with a
single node indicating that node should be considered the current node
- that might be confusing so could be removed.

This implementation does not use CTDB_SRVID_RELOAD_ALL_IPS, so it can
be removed.

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

(This used to be ctdb commit d66a072d9b120c78c47e726e9f29a3c1cfdd87ce)
2013-09-19 12:54:31 +10:00
Martin Schwenke
e79b750e5e tools/ctdb: Add a wait_for_all option to srvid_broadcast()
This will be useful for other SRVIDs.

The error checking in the handler depends on the SRVID responding with
a uint32_t where <0 indicates an error and >=0 is a PNN that
succeeded.

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

(This used to be ctdb commit 52050e1c75b21961dafe2bc410268b44240ab24e)
2013-09-19 12:54:31 +10:00
Martin Schwenke
51db81344e tools/ctdb: Factor out SRVID broadcast code from ipreallocate()
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit a566fb5e70282c4e9f76654b1be4dc80829dced0)
2013-09-19 12:54:30 +10:00
Martin Schwenke
8a6979dac3 tools/ctdb: Change ipreallocate() to use a local done flag
Instead of the current global variable.  This is in anticipation of
abstracting the code.

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

(This used to be ctdb commit c58ee0eddf7ae3283e3ca8bd25575e6e677e1b17)
2013-09-19 12:54:30 +10:00
Martin Schwenke
4c3f8dc3bb recoverd: Make the SRVID request structure generic
No need for a separate one for each SRVID.

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

(This used to be ctdb commit d9c22b04d5aa7938a3965bd3144568664eb772ce)
2013-09-19 12:54:30 +10:00
Martin Schwenke
c870f01160 tools/ctdb: list_of_active_nodes_except_pnn() -> list_of_nodes()
list_of_active_nodes_except_pnn() is only used here and can be removed
if we remove this call.  Less is more...

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

(This used to be ctdb commit d4e206fb818048b7fab4797c877b854bdbb1ab70)
2013-09-11 15:34:58 +10:00
Martin Schwenke
2d31ec2131 tools/ctdb: Fix a memory leak in parse_nodestring()
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 8753a094b97340deb26dd44f6ea345ca0a642a95)
2013-09-11 15:34:51 +10:00
Martin Schwenke
a04fb43708 tools/ctdb_diagnostics: Add output of "ctdb getdbmap"
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit f0d69a9079b7aecc68f1d2d8510702046b618b19)
2013-08-22 17:00:20 +10:00
Martin Schwenke
6c468c94a2 tools/ctdb_diagnostics: Safer temporary file creation
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 406e1cb1fdd17ddd239774d0228e3657b73ae68f)
2013-08-22 17:00:20 +10:00
Martin Schwenke
d1918ba27a tools/ctdb: Make most non-auto-all commands abort if run with -n all
Or if run with -n A,B,...

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

(This used to be ctdb commit b1d8732b5da18ae80aea1df0e66b0b5cdcd919bc)
2013-08-22 17:00:20 +10:00
Martin Schwenke
fd79a86d8f tools/ctdb: Remove more non-essential fetching of PNN from daemon
The useful cases are either CTDB_CURRENT_NODE, in which case
ctdb_get_pnn() does the job, or a PNN, which is... ummm... a PNN!  :-)

This works because parse_nodestring() validates PNNs.

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

(This used to be ctdb commit 7b3f7eea2465efb099a2faf3e42174bc97b13a16)
2013-08-22 17:00:20 +10:00
Martin Schwenke
3402ae9ffb tools/ctdb: Improve auto-all settings for some commands
* ipreallocate is cluster-wide so should not be auto-all

* enablescript, disablescript, getreclock, setreclock, natgwlist can
  all be auto-all without issues

* xpnn, ipiface a local-only so don't work with -n, so might as well
  not be auto-all

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

(This used to be ctdb commit 123a4677528cb46bee1c6dad8a5162eba9880bc1)
2013-08-22 17:00:20 +10:00
Martin Schwenke
73da6c0201 tools/ctdb: Fix message in showban when node is banned
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 5cdad2b8ebd71a5e458c301d00eac00a211feeb3)
2013-08-21 14:02:36 +10:00
Martin Schwenke
b74c232b8a tools/ctdb: Reimplement ban/unban using update_flags_wait_and_ipreallocate()
This has the side effect of making these commands more resilient to
control timeouts.

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

(This used to be ctdb commit 0fe79662e20e347d9e1cb12a42cd356e33572402)
2013-08-21 14:02:36 +10:00
Martin Schwenke
b42b0e4676 tools/ctdb: Factor out common pattern used in disable/enable/stop/continue
Now we will only have one set of bugs.  :-)

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

(This used to be ctdb commit 444521c852749558f39dc6131acce9e47eefd489)
2013-08-21 14:02:36 +10:00
Martin Schwenke
f72f4c362b tools/ctdb: Factor, simplify and improve robustness of ipreallocate code
Having other functions call control_ipreallocate() suggests that the
it might look at the argv/argv arguments that are passed.  This is not
the case.  Change the callers so they call the new ipreallocate()
function instead.

Broadcast CTDB_SRVID_TAKEOVER_RUN to all connected nodes.  Inactive
nodes will ignore it.  This is safe since we only want 1 reply.  If we
didn't get a response, we don't actually care if there's no active
recovery master - just fire, wait, retry, ...

Ignore some failures on the basis that they might be transient, so it
is probably worth retrying.

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

(This used to be ctdb commit 4bf0b1c9d21986eecb7682f935bd6154c65533cc)
2013-08-21 14:02:36 +10:00
Martin Schwenke
db121b4c8f tools/ctdb: Use ctdb_get_pnn() to get PNN of the current node
This has already been stored at connect time and can't fail.

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

(This used to be ctdb commit d8eb2e7fdd7645719370dad4f2faa5c3fffa8249)
2013-08-21 14:02:36 +10:00
Martin Schwenke
4cb3e2cd78 tools/ctdb: Increase default control timeout to 10 seconds
The current 3 second timeout is arbitrary and users trip over it
sometimes.

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

(This used to be ctdb commit b49c4f39666d5b1596213bf41bcdc47ed3c327ae)
2013-08-14 15:57:04 +10:00
Amitay Isaacs
16b519c51b tools/ctdb: Only print the hot records with non-zero hopcount
Signed-off-by: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit 049d9beb3783482490e6273a434ccbad23f85f0a)
2013-07-30 15:34:32 +10:00
Martin Schwenke
200c28fbb2 tools/ctdb: Allow killtcp to read connections from standard input
This will allows eventscripts to send information about multiple tcp
connections to a single "ctdb killtcp" command, saving the overhead of
setting up a client connection per tcp connection.

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

(This used to be ctdb commit af5aa369c266430fe912df0c26116b68bac3572e)
2013-07-29 15:51:03 +10:00
Sumit Bose
67f8a0ed91 Print deleted nodes as well
Signed-off-by: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit 0930a3b806977555509c3228726e2250aef1f971)
2013-07-11 15:16:56 +10:00
Amitay Isaacs
81e6d60f01 tools/ctdb: Fix the format of DB statistics output
Signed-off-by: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit 594c421f90ce132c75fbd985872114e4967f92b5)
2013-07-10 14:33:18 +10:00
Martin Schwenke
442953c540 tools/ctdb: Add "force" option to "recover" command
At the moment there is no easy way to force a recovery when attempting
to reproduce certain classes of bugs.  This option is added without
documentation because it is dangerous until the bugs are fixed!  :-)

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

(This used to be ctdb commit 4f87925a287f612a6ab3b5da1a387a31c7bea28f)
2013-06-28 14:18:00 +10:00
Amitay Isaacs
a4f4e391f0 tools/ctdb: Do not exit prematurely on control timeout if retrying in a loop
This avoids premature exits from "ctdb stop" and "ctdb continue" due to
intermittent control (e.g. getpnn, getnodemap) timeouts.

This needs a proper fix to distinguish between timeout and failure
conditions and take appropriate action.

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

(This used to be ctdb commit c48583fd238496a81ddc46a21892f0b49559036a)
2013-06-20 12:52:00 +10:00
Martin Schwenke
140f0cfd3b ctdbd: Update the get_tunable code to return -EINVAL for unknown tunable
Otherwise callers can't tell the difference between some other failure
(e.g. memory allocation failure) and an unknown tunable.

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

(This used to be ctdb commit 03fd90d41f9cd9b8c42dc6b8b8d46ae19101a544)
2013-05-24 16:04:50 +10:00
Martin Schwenke
6d9667f01c ctdbd: Add new runstate CTDB_RUNSTATE_FIRST_RECOVERY
This adds more serialisation to the startup, ensuring that the
"startup" event runs after everything to do with the first recovery
(including the "recovered" event).

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

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

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

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

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

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

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

(This used to be ctdb commit 4a2effcc455be67ff4a779a59ca81ba584312cd6)
2013-05-24 14:08:07 +10:00
Martin Schwenke
87eb70180a tools/ctdb: New command runstate to print current runstate
Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit bf20c3ab090f75f59097b36186347cedb1c445d4)
2013-05-24 14:08:07 +10:00
Martin Schwenke
c5bcff6724 tools/ctdb: Remove duplicate command definition for "sync"
Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit 9e7b7cd04adc5e66e2ffa4edf463a682aaea379b)
2013-05-24 14:08:06 +10:00
Amitay Isaacs
a0cfc381d3 tools/ctdb: Fix racy ipreallocate code
This code tried to find the recovery master and send an ipreallocate
request to that node.  When a node is stopped, this code asked the
stopped node for recovery master.  Stopped node does not have up-to-date
information on the current recovery master.  So ipreallocate requests
were sent to the wrong node and ignored by that node which is not the
recovery master.

Send ipreallocate request to all active nodes.  That way we guarantee
that the current recovery master will see it and respond to it.

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

(This used to be ctdb commit 0577ce3c68e4febf49a1ef5093e918db9d5ec636)
2013-05-23 16:19:20 +10:00
Amitay Isaacs
6d0c388e5c build: Rename version.h to ctdb_version.h
This avoids clash with version.h from Samba tree.

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

(This used to be ctdb commit d18fcfff674e876abde8d51afec92d9c4a090d2f)
2013-05-23 16:18:23 +10:00
Amitay Isaacs
e062555da0 tools/ltdbtool: Fix handling of -e option
Also, include description of -e option in usage.

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

(This used to be ctdb commit 35264e42ade4676468cf7713fa339c784e932953)
2013-04-08 14:25:34 +10:00
Volker Lendecke
3ffd57f0c9 fix a typo
Reviewed-by: Michael Adam <obnox@samba.org>

(This used to be ctdb commit 98abd344342a011a8599411deae79f94abc09541)
2013-03-12 14:02:08 +01:00
Martin Schwenke
8cd6a67b8b tools/ctdb: delip no longer fails if IP can not be moved
Moving the IP is an optimisation so should not cause failure.

Refactor and simplify the retry-move-IP into new function
try_moveip().

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

(This used to be ctdb commit 5402f85dde045576cbaf64e01c68e28ed52204e8)
2013-02-27 16:01:55 +11:00
Martin Schwenke
fe130ca85b tools/ctdb: Fix a compiler warning
Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit d1ec06d30148e6fd344625a2fbf1c22391bd908a)
2013-02-04 11:22:43 +11:00
Amitay Isaacs
d85e40fbdb tools/ctdb: Add setdbseqnum command to set __db_sequence_number__
Signed-off-by: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit efaac27a9ed52ed0f436c7e194013fd06e8b02b3)
2013-01-09 13:18:34 +11:00
Amitay Isaacs
4ca50c7243 tools/ctdb: Re-factor code to check if db exists given name or id
Most of the commands related to database operations can now use the
common code (db_exists()) to refer to database with either name or id.

In addition to return db_id for db_name, the function returns all the
flags set for the database.

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

(This used to be ctdb commit ca6e7eccc90f2869c220231666bf284798342bce)
2013-01-09 13:18:33 +11:00
Amitay Isaacs
d8a3ec42c1 tools/ctdb: Add pdelete command to delete a record from persistent database
Signed-off-by: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit d23adec89b69e7c6f96c8e1417ef4ca4c9edc57e)
2013-01-09 13:18:33 +11:00
Amitay Isaacs
56ee668a51 tools/ctdb: Do not use function return value as pnn
This fixes the wrong code where same variable 'ret' is used to track the pnn
and the return value of a function call.

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

(This used to be ctdb commit 718233c445cd6627ab3962b6565c2655f1f8efd0)
2012-11-14 11:00:21 +11:00
Amitay Isaacs
b0f90052cb tool/ctdb: Always support ctdb version command, don't make it optional
Signed-off-by: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit f8af7d8de76e68e5c4bde15f832a31ce9107e8c7)
2012-10-30 11:56:00 +11:00
Martin Schwenke
d78ac9c364 tools/ctdb: Merge recoverd log handling into getlog/clearlog
We don't need extra commands for these.

Also, allow a default value of NOTICE for the getlog level.

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

(This used to be ctdb commit 7197e600f46f2d1638f6c45c0149f109ea25a47c)
2012-10-22 12:21:24 +11:00
Martin Schwenke
798b632e03 tools/ctdb: Add log ringbuffer handling for recoverd
This adds commands rdgetlog and rdclearlog

These are analogous to getlog and clearlog but operate on the logs for
the recovery daemon.

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

(This used to be ctdb commit ef55e06192819d840c09b65741bab737223ac34c)
2012-10-22 11:15:36 +11:00
Amitay Isaacs
a00e50e503 ctdbd: Replace lockwait with locking API and remove ctdb_lockwait.c
Signed-off-by: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit 2126795153dacb255e441abcb36ee05107b6282a)
2012-10-20 02:48:44 +11:00
Amitay Isaacs
8d7d9ac8ce tools/ctdb: Display the locking statistics
Signed-off-by: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit e24b5bf283736624b387b0364d7200212bb3054b)
2012-10-20 02:48:44 +11:00
Martin Schwenke
7bf693fc1b tools/ctdb_diagnostics: Add "ctdb listvars" output
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 2d75a04ba9a2e87a0dcb9bf778c58e335af1871c)
2012-10-18 20:05:43 +11:00
Martin Schwenke
c5e24b23cf tools/ctdb: Remove extra header from natgwlist -Y output
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 59520c9785d113ad5063eb5fbe42a9efc7e30076)
2012-10-18 20:05:42 +11:00
Martin Schwenke
1aaaf7e20e tools/ctdb: Free the event context
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit dc2a8c638bd74b9f1dd75339cd2ae2f32ffa18a8)
2012-10-02 17:37:53 +10:00
Martin Schwenke
82922ec305 tools/ctdb: Clean up control_natgw()
* Factor out repeated code into new function find_natgw()
* Support both machine and human readable output
* Use libctdb

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

(This used to be ctdb commit a56ec75edd1705b0539513d396d311f0e80a3bf5)
2012-09-28 17:05:34 +10:00
Martin Schwenke
a7ff393d42 tools/ctdb: Convert some commands over to libctdb
control_getcapabilities(), control_lvs(), control_lvsmaster() updated
to use ctdb_getcapabilities(), ctdb_getnodemap() as appropriate.

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

(This used to be ctdb commit c30ec02615183ecf9b412ad415bf1abd859aec45)
2012-09-28 17:05:34 +10:00
Martin Schwenke
110cb67e2a tools/ctdb: Remove redundant filtering loop in control_natgwlist()
This used to catch trailing blank lines.  However, these are caught
just as effectively by the whitespace filtering in the loop below.

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

(This used to be ctdb commit 7b75a3bb722dc86139b1a07a0100d08c34620b91)
2012-09-28 17:05:34 +10:00
Martin Schwenke
860d757475 tools/ctdb: natgwlist output is either human readable or machine readable
The first line is currently human readable and the rest is machine
readable.  This doesn't make sense.  Do one or the other...

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

(This used to be ctdb commit b29d5bbaa7048291c4b3a39bf12e04f0436f67da)
2012-09-28 17:05:34 +10:00
Martin Schwenke
bd0e34a9fd tools/ctdb: Factor out printing of the machine readable status header
It is already in 2 places and we might use it in another.

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

(This used to be ctdb commit 12a0a7a208d1c8fa8991894200d1dc133f3a2d1a)
2012-09-28 17:05:34 +10:00
Martin Schwenke
1fbeb106e0 tools/ctdb: NAT gateway code should use CTDB_NATGW_NODES
... not NATGW_NODES.

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

(This used to be ctdb commit 2da7730dc06153173778ab14e228960e72ff8a86)
2012-09-28 17:05:34 +10:00
Martin Schwenke
e7c8e0d32d ctdb tool: recmaster command might as well be auto-all
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 076282622fcb2663d378e0c90ed0d9c19f73c005)
2012-07-30 15:43:32 +10:00
Martin Schwenke
f53b4f82f5 tools/onnode: Add -P option to push files to given nodes
A list of files is given rather than a command.  These files are
pushed to the specified nodes.

Quoting is fragile/broken so filenames with spaces won't work - you
win some, you lose some.  :-)

All of the other onnode options should work together with this option.

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

(This used to be ctdb commit aed9b98ddbbf3e81de4f7257a10676565f7d7507)
2012-07-30 15:34:41 +10:00
Amitay Isaacs
23a460602f Remove tevent_loop_allow_nesting()
Signed-off-by: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit 538c68d0e83e14f0000981ee06408b8f0035be37)
2012-07-16 12:12:05 +10:00
Michael Adam
237d4c5c39 ctdb: use correct "persistent" state for ctdb_attach in "ctdb cattdb"
Originally, "ctdb cattdb" attached explicitly as non-persistent, which
is now forbidden for persistent databases by the server.

Pair-Programmed-With: Gregor Beck <gbeck@sernet.de>

(This used to be ctdb commit 85a367005bd669309bb7e532b60d27621110180d)
2012-07-03 14:30:24 +02:00
Ronnie Sahlberg
d21337a0fb Add new command to find which interface is located on
(This used to be ctdb commit f07376309e70f5ccdb7de8453caacc71b451ab48)
2012-06-20 15:11:49 +10:00
Ronnie Sahlberg
59565c05cf STATISTICS: Add tracking of the 10 hottest keys per database measured in hopcount
and add mechanisms to dump it using the ctdb dbstatistics command

(This used to be ctdb commit 8307c70ed98996b430c470e9641a09fdeeb81bd8)
2012-06-13 16:19:18 +10:00
Ronnie Sahlberg
7a1aa560e7 Add new control to reload the public ip address file on a node
Also add a method to use the recovery master/daemon to reload the public ips on all nodes in the cluster.
Reloading the public ips on all node sin the cluster is only suported if all nodes in the cluster are available and healthy.

(This used to be ctdb commit 05603e914f8c12618d7e06943c0f7df207f645b0)
2012-05-01 10:48:08 +10:00
Amitay Isaacs
4392591555 Remove explicit include of lib/tevent/tevent.h.
Signed-off-by: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit 0681014ca5ed2a9b56f63fdace7f894beccf8a9a)
2012-04-13 17:28:14 +10:00
Ronnie Sahlberg
0cc3127beb CTDB: add back the "rebalanceip" command
(This used to be ctdb commit 83aea6488002aa75dd25752fa0d164afb8b4f300)
2012-04-03 13:43:21 +10:00
Ronnie Sahlberg
fa3a06246a STICKY: add prototype code to make records stick to a node to "calm" down if they are found to be very hot and accessed by a lot of clients.
This can improve performance and stop clients from having to chase a rapidly migrating/bouncing record

(This used to be ctdb commit d0d98f7e45e5084b81335b004d50bddc80cdc219)
2012-03-20 17:12:19 +11:00
Ronnie Sahlberg
6a493a0b08 STATISTICS: add per-db hop count statistics
(This used to be ctdb commit 1c976d83b1d7dac6f0ef81306774998e4c8b56a1)
2012-03-20 12:11:55 +11:00
Ronnie Sahlberg
c9f7c981e2 CTDB: change how the hop count buckets are displayed in ctdb statistics
(This used to be ctdb commit 05923a14bc8ae8e3c5cda28ff4e0fb0d473d5f7d)
2012-03-20 11:43:09 +11:00
Ronnie Sahlberg
038c946e80 add max hop count buckets to see how bad hopcounts are
(This used to be ctdb commit 7d3931298e6477d92f43652c3006b0c426cb1307)
2012-03-20 11:20:53 +11:00
Ronnie Sahlberg
b3ddf6901d Merge remote branch 'martins/master'
(This used to be ctdb commit af72f8bc05f78983f9624d81788f9d89af474b11)
2012-03-15 16:09:41 +11:00
Ronnie Sahlberg
ef2bd0b016 When adding ips to nodes, set up a deferred rebalance for the whole node to trigger after 60 seconds in case the normal ipreallocated is not sufficient to trigger rebalance.
(This used to be ctdb commit 4340263b219d75c39f8de22abe3f6f1c1ee63ea2)
2012-02-28 06:56:04 +11:00
Volker Lendecke
5e3b13a32a FreeBSD does not define s6_addr32, only s6_addr
Signed-off-by: Michael Adam <obnox@samba.org>

(This used to be ctdb commit d657af4fb68ce3f7c462856f2934f6bf169e120b)
2012-02-13 16:20:12 +01:00
Martin Schwenke
629553667e ctdb tool: fix thinko in nodestatus command output
If used with -n <nodes> the "current" node needs to change.

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

(This used to be ctdb commit a0340a50c2acd9ccc281faef032a364254f7f95a)
2012-02-13 13:31:18 +11:00
Ronnie Sahlberg
68245eee4e READONLY: allow specifying the db name for setdbreadonly instead of just the hash
(This used to be ctdb commit 3c2117e8e4156e0048fbd2c94546112f0c588522)
2012-02-13 10:27:59 +11:00
Ronnie Sahlberg
73f8be16c6 ReadOnly: add per-database statistics to view how much delegations/revokes we have
(This used to be ctdb commit 751ed46197661eb841042ab6a02855a51dd0b17c)
2012-02-08 15:29:27 +11:00
Ronnie Sahlberg
1eafa68f0f STATISTICS: add total counts for number of delegations and number of revokes
Everytime we give a delegation to another node we count this as one delegation.
If the same record is delegated to several nodes we count one for each node.

Everytime a record has all its delegations revoked we count this as one revoke.

(This used to be ctdb commit b098bcf8007be63889aaed640a951b0eeaa9d191)
2012-02-08 13:42:30 +11:00
Ronnie Sahlberg
b6de9d3d19 Ad test tool to store data and ctdb header into a local tdb file
(This used to be ctdb commit c6433e43ad2481d84e8d9a1ee1c6e29b90423a86)
2012-02-07 12:14:57 +11:00
Ronnie Sahlberg
c3bab541c9 TFETCH add verbose flag to print also the record ltdb heaer
(This used to be ctdb commit 25d797f61c3b5b7090fb662adde6ed9e434e8a61)
2012-02-07 10:53:49 +11:00
Ronnie Sahlberg
daf28e095e CTDB: update tfetch so we can specify a hexadecimal string as key
(This used to be ctdb commit 70d22efdf104db1fc951263cedfbdb95b0b44342)
2012-02-07 10:21:12 +11:00
Martin Schwenke
e2ceae48e3 ctdb tool - free some memory used by popt
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 7339e87019c0ab44522bf160234307472c05dc14)
2012-02-06 16:00:24 +11:00
Martin Schwenke
7a04587e88 ctdb tool - convert control_status() over to use just libctdb()
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit abe9985e503d998cf597933a594b445de8d3cec6)
2012-02-06 16:00:23 +11:00
Martin Schwenke
bfab62dd41 ctdb tool - Fix parse_nodestring() related issues
An old, buggy version of this code was merged.  This fixes it.

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

(This used to be ctdb commit bc4d5d5f0048487776f9f5d9f04a0af2e5d45aac)
2012-02-06 16:00:23 +11:00
Ronnie Sahlberg
e648045499 Merge branch 'master' of ssh://git.samba.org/data/git/ctdb
(This used to be ctdb commit 15d8ae8b0f80f95d7839528b8ac60aa0e2485c77)
2012-01-03 12:40:15 +11:00
Michael Adam
5fdd7fefb8 ctdb-tool: adapt formatting of "listvars" output to lenght of longest name
(This used to be ctdb commit 295168d99183d2d21f27a8ac6825d421fa866b28)
2011-12-23 17:39:10 +01:00
Michael Adam
491c63c2a8 tools/ctdb: allow the "ctdb vacuum" stub to be run without the daemon running.
(This used to be ctdb commit e71afbf731f06a3b89b64220c7fd1b1ea5492d4a)
2011-12-23 17:39:05 +01:00
Michael Adam
d7611212c3 tools/ctdb: remove functionality of "ctdb vacuum", just keeping a stub.
(This used to be ctdb commit 8fc4d5018ee6eee8856634095694d3ad0de5b4ae)
2011-12-23 17:39:05 +01:00
Martin Schwenke
89b01c8e7b Rename struct traverse_state to allow tools C files to be #included.
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 54377ef8b992f92d3a4ece42ee72e37d22cd2de6)
2011-12-08 17:21:24 +11:00
Martin Schwenke
a2095caf91 ctdb tool - remove verify_node() function
parse_nodestring() checks what this used to check.  parse_nodestring()
already has the nodemap.

It was a 50-50 decision to decide whether to update verify_node() to
check against a nodemap that is passed in or to delete it.

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

Conflicts:

	tools/ctdb.c

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

(This used to be ctdb commit 2c1baf5ddd3c2cdd2a3f98b8e208d3a48530d1d1)
2011-12-08 17:21:24 +11:00
Martin Schwenke
d5b1a6a9c6 ctdb tool - new command "ctdb nodestatus [nodestring]"
This is very much like "ctdb status" but actually returns the status
for use in scripts.

This can be used in 2 modes:

* An optional nodestring is passed directly to the command without
  using -n.  In this mode the current node is asked for the status of
  all listed nodes.

* The nodestring is passed via -n.  In this mode the designated nodes
  will be asked for their status.  This is like "ctdb status".

These modes can be mixed.  For example:

  ctdb nodestatus 1,2,3 -n 0

asks node 0 for the status of nodes 1, 2 and 3, returning the bitwise
OR of their statuses.

This version uses the auto_all functionality, so the output isn't
necessarily pretty.  An improved version that does its own -n
processing may appear soon.

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

(This used to be ctdb commit 355685a14be17bf4648788f8a72c54790fe03502)
2011-12-08 17:21:17 +11:00
Martin Schwenke
b646815567 ctdb tool - factor out status printing functions
Create 2 new functions: control_status_1_machine() and
control_status_1_human() that contain chunks of code from
control_status().  We're about to find another purpose for these
functions.

This should be a no-op.

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

(This used to be ctdb commit fade71539482e8276f57ba3c003fe004d8666ce7)
2011-12-08 17:18:19 +11:00
Martin Schwenke
8b74037633 ctdb tool - generalise nodestring parsing for -n
Centralise -n nodestring parsing and add the ability to pass a
comma-separated list of node numbers.  Listing a node that is
disconnected or deleted results in failure, similar to the way passing
a single node currently works.  All of the auto_all commands inherit
this functionality.  For now, the non-auto_all commands do not inherit
this - they need to be individually tweaked.  Therefore, we haven't
updated the documentation to advertise this feature.

Implemented via a new function parse_nodestring() that parses an
optional (pass NULL when not available to indicate "current node")
comma-separated list of node numbers or "all".  parse_nodestring() can
be told to be non-fatal for disconnected/deleted nodes so it can also
be used in other contexts (yes, coming soon).  main() is changed to
call this function.

A new magic PNN value CTDB_MULTICAST is added and along with a
corresponding option.nodes structure member (a talloc-ed array of
PNNs).  This is also populated for "all" as well.

control_status() has new function pretty_print_flags() factored out so
pretty-printed flags can be used in error/debug messages.  New
function is_partially_online() is also factored out - this simplifies
some of the logic.

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

(This used to be ctdb commit 920e3a732eb9e09004edde6cfb3c7db8a004016f)
2011-12-08 17:00:17 +11:00
Martin Schwenke
7f25864db0 ctdb tool - move parsing of nodestring to where it is needed
This puts the parsing and checking logic close together.  This makes
it easy to change the parsing code.  Changed parsing code can now
easily use both old client code and libctdb since both are guaranteed
to be setup.

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

(This used to be ctdb commit 57fb074a65dc56168fc3813b79a5bab4b3727cf3)
2011-12-06 13:59:32 +11:00
Martin Schwenke
dbd452c801 ctdb tool - replace fprintf with DEBUG
It's the only one in the file.

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

(This used to be ctdb commit bf1174ef699b06485b36ee8ae70412be0759e142)
2011-12-06 13:59:32 +11:00
Martin Schwenke
ba6e6f689c ctdb tool - short circuit most of the logic in main for non-daemon commands
This allows all that logic to be hacked a little more easily.

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

(This used to be ctdb commit f93ffeee7b9e9ca5dd116655bdc7f89fc987ed8a)
2011-12-06 13:59:32 +11:00
Martin Schwenke
7e9f998745 ctdb tool - commands that don't use the daemon can't take -n/--node
It just doesn't make sense!

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

(This used to be ctdb commit c4b72683eb046007fbc2e60b4a54bc91faf4cf7e)
2011-12-06 13:59:32 +11:00
Martin Schwenke
5f69ad3c0a ctdb tool - simplify main() by taking most code out of a loop
Most of the action in main() happens inside a for loop and an if
statement.  This causes 2 levels of extra indent for the code and
makes it harder to read.

Instead, the current body of the loop is put below the loop and its
corresponding failure check.

To see how small this change really is, view with "diff -w".  ;-)

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

(This used to be ctdb commit 8527396b7290cfc8378779631e91d2ae09e2a106)
2011-12-06 13:59:32 +11:00
Ronnie Sahlberg
609149bdc8 LibCTDB: Add support for the 'get interfaces' control and update the ctdb tool to use this interface
(This used to be ctdb commit 77dc0c7351071243d9096d3607d7499c82f46ec0)
2011-12-06 13:12:18 +11:00
Ronnie Sahlberg
7d31c64c1c ctdb: use libctdb version of check-srvids call
(This used to be ctdb commit 36105b7283df729946e0a2ed61a696a14221efa6)
2011-11-30 10:00:27 +11:00
Ronnie Sahlberg
5a1e8df451 check_srvids: remove the <pnn> from the commandline so that we only specify the list of <srvids>
Specifying the pnn can be done via '-n <pnn>'

(This used to be ctdb commit e9250775f5a1234f27a1a62caa902d7b86194285)
2011-11-30 09:50:12 +11:00
Volker Lendecke
6f657dadd3 Add "ctdb check_srvid"
(This used to be ctdb commit 92a391a81d0697956b96e96e39bb1b9d13e18097)
2011-11-30 09:02:26 +11:00
Ronnie Sahlberg
3cbff2edd8 LibCTDB: add get persistent db seqnum control
(This used to be ctdb commit 6e96a62494bbb2c7b0682ebf0c2115dd2f44f7af)
2011-11-30 08:48:14 +11:00
Michael Adam
31d62794fe ctdb: add an option --print-recordflags to trigger printing record flags in catdb and dumpdbbackup
This changes the default behaviour to not print record flags.

(This used to be ctdb commit 2d2ce07c51055d9400b22cd3c1fd682597cb921c)
2011-11-29 13:43:35 +01:00
Michael Adam
e6923904e8 ctdb: add an option --print-hash to enable printing of record hashes when dumping dbs
(This used to be ctdb commit efc033c28ade97f9884794256d59a4553e052d5f)
2011-11-29 13:43:34 +01:00
Michael Adam
86cd78efee ctdb: add an option --print-lmaster to enable printing of lmaster in "ctdb catdb"
(This used to be ctdb commit 326f88ef622620cb9e0569c4497bc0e86124beaa)
2011-11-29 13:43:33 +01:00
Michael Adam
dc98c12ac9 ctdb: add an option --print-datasize to only print datasize instead of dumping data in db dumps
Used in catdb, cattdb and dumpdbbackup.

(This used to be ctdb commit dd866116041e71cbf91e7fd91edcc9501634051d)
2011-11-29 13:43:32 +01:00
Michael Adam
1fcc7651f4 ctdb: add an option --print-emptyrecords to enable printing of empty records in dumping databases
this option is used with the commands catdb, cattdb and dumpdbbackup.

(This used to be ctdb commit 6ec68a2e667f66d2b194fe48cb75229a2777842e)
2011-11-29 10:30:24 +01:00
Martin Schwenke
08ebcf6e6a Fix ctdb scriptstatus -n all
This didn't have auto_all set as true.  However, there's no special
code to handle "-n all" and it just fails.  If auto_all works for
status then it might as well work for scriptstatus.

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

(This used to be ctdb commit 3084220e2aac3664511969f10cad206e505150a0)
2011-11-10 15:41:03 +11:00
Mathieu Parent
fa197073cd config can be in /etc/default/ instead of /etc/sysconfig/ (ctdb_gnostics part)
(This used to be ctdb commit b6a9dacefd8f031677702f0fbf6b321beb4c4d54)
2011-11-08 16:32:03 +11:00
Ronnie Sahlberg
afd0b63273 Merge branch 'master' of 10.1.1.27:/shared/ctdb/ctdb-master
(This used to be ctdb commit d772743e9a4d4d40eb95cd8d5178708e77057b79)
2011-11-08 14:01:22 +11:00
Ronnie Sahlberg
0f92fa224c RB_TREE: Add mechanism to abort a traverse
This patch changes the callback signature for traversal
functions to allow a client to abort a traverse before it finishes.
Updates to all callers and examples as well as rb-test tool.

(This used to be ctdb commit 8ab0c63ad36cfbbb1e5fed46a1f4c47b1fdb581f)
2011-11-08 13:40:28 +11:00
Martin Schwenke
2e3febe283 onnode: unset EXTRA_SSH_OPTS when using fakessh
This case was never tested and fakessh obviously won't handle the
extra arguments.

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

(This used to be ctdb commit 02184bd5b9ab94cdf2b9ff92e56a509f92f9e4aa)
2011-10-18 11:51:06 +11:00
Ronnie Sahlberg
24b56c62b1 Merge branch 'master' of ssh://git.samba.org/data/git/ctdb
(This used to be ctdb commit dd9f82dbe2346c7143b0229e3611c402ee8c4025)
2011-10-17 15:08:39 +11:00
Martin Schwenke
71b8015ccf Make ctdb_diagnostics more resilient to uncontactable nodes.
Current behaviour is for onnode to timeout (for about 20s) for each
attempted ssh to a down node.  With 40 or 50 invocations of onnode
this takes a long time.

2 changes to work around this:

* If EXTRA_SSH_OPTS (which is passed to ssh by onnode) does not
  contains a ConnectTimeout= setting then add a setting for a 5 second
  timeout.

* Filter the nodes before starting any diagnosis, taking out any "bad
  nodes" that are uncontactable via onnode.

  In the nodes summary at the beginning of the output, print
  information about any "bad nodes".

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

(This used to be ctdb commit 8c3b6427dbaade87e1a0f5590f0894c2e69b31a3)
2011-10-13 14:27:34 +11:00
Gregor Beck
28a434051c ltdbtool: ignore empty (deleted) records per default.
Add option -e to get the old behaviour and process empty records too.

Signed-off-by: Michael Adam <obnox@samba.org>

(This used to be ctdb commit d9859540c2000864bc6c58be5afe19aa3b1064b2)
2011-10-12 22:38:02 +02:00
Ronnie Sahlberg
8a104331e8 Change the 'This Node' column of the machinereadable output for 'ctdb status -Y' to Y/N instead of 1/0
1/0 is unsuitable since it can be useful to check 'if a column is "1" there is something wrong with that node'

(This used to be ctdb commit b963f5e40b1e73a60363568da88557cad9e58a28)
2011-09-21 15:41:28 +10:00