summaryrefslogtreecommitdiff
path: root/ctdb
AgeCommit message (Collapse)AuthorFilesLines
2026-04-17ctdb-scripts: Support interface altnamesMartin Schwenke2-14/+30
This avoids generating a warning like: WARNING: Public IP <ip> hosted on interface <iface> but VNN says <altname> every time a public IP is removed from an interface that is configured via an altname. The new check will nearly always be successful because the IP will be on the expected interface during releaseip/updateip. The original check is now used as a backup when the IP is not on the expected interface. To allow the mask bits check to cover both cases, the original check and the associated interface check needs to be inside the else clause. Update the unit test to reflect the change. Best reviewed with "git show -w" or similar. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: John Mulligan <jmulligan@redhat.com> Autobuild-User(master): Martin Schwenke <martins@samba.org> Autobuild-Date(master): Fri Apr 17 00:11:50 UTC 2026 on atb-devel-224
2026-04-16ctdb-tests: Add addip/releaseip altname unit testMartin Schwenke1-0/+21
This shows that a warning is generated whenever an IP address is removed using an altname. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: John Mulligan <jmulligan@redhat.com>
2026-04-16ctdb-tests: Implement altname property for ip link/addrMartin Schwenke1-0/+54
Only implemented for these commands. I don't even want to think about doing this for ip route right now. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: John Mulligan <jmulligan@redhat.com>
2026-04-16ctdb-scripts: Rename/reimplement get_iface_ip_maskbits()Martin Schwenke1-8/+10
Reimplement to set prefix instead of maskbits. Rename to get_ip_prefix_iface(). Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: John Mulligan <jmulligan@redhat.com>
2026-04-16ctdb-scripts: Add function ip_prefix_iface()Martin Schwenke2-10/+13
Reimplement ip_maskbits_iface() using the ip -brief option. Do less parsing, no longer extract maskbits but return whole prefix. Retain ip_maskbits_iface() for backward compatibility in case custom event scripts are using it. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: John Mulligan <jmulligan@redhat.com>
2026-04-16ctdb-tests: Implement -brief option for ip addr show stubMartin Schwenke1-12/+36
Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: John Mulligan <jmulligan@redhat.com>
2026-04-16ctdb-tests: Fix a typo in "ip link show" stub outputMartin Schwenke1-1/+1
Status is different to state and should not be repeated. For example: eth0 UP aa:bb:cc:dd:ee:ff <BROADCAST,MULTICAST,UP,LOWER_UP> Clearly nothing looks at this field but it should be correct. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: John Mulligan <jmulligan@redhat.com>
2026-04-16ctdb-scripts: Drop full address prefix lengthsMartin Schwenke1-7/+3
ip addr assumes these defaults anyway. They are just noise. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: John Mulligan <jmulligan@redhat.com>
2026-04-16ctdb-scripts: Add an extra variable to help reviewersMartin Schwenke1-3/+9
Using $_bcast to determine if the address is an IPv6 one is lazy. It causes anyone reading the code (including the original author) to have to go back and confirm that the condition makes sense. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: John Mulligan <jmulligan@redhat.com>
2026-04-16ctdb-scripts: Add function ip_addr_add()Martin Schwenke2-11/+20
For consistency with new ip_addr_del(). Update all callers of add_ip_to_iface() to use this function instead. Retain add_ip_to_iface() for backward compatibility in case custom event scripts are using it. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: John Mulligan <jmulligan@redhat.com>
2026-04-16ctdb-scripts: Add function ip_addr_del()Martin Schwenke3-12/+22
Using a prefix is more natural because it matches "ip addr ..." usage. It should also allow for less parsing. Update all callers of delete_ip_from_iface() to use this function instead. Retain delete_ip_from_iface() for backward compatibility in case custom event scripts are using it. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: John Mulligan <jmulligan@redhat.com>
2026-04-16ctdb-scripts: Only warn when removing an unassigned public IPMartin Schwenke2-14/+15
get_iface_ip_maskbits() now sets iface="" when the IP is unassigned, allowing dependent code to be conditional. Currently, ctdb_takeover.c:ctdb_control_release_ip() ensures no releaseip event is triggered if the public address is not on the node. So, no change of behaviour for releaseip. The previous attempt at making updateip behave more like takeip when the IP isn't currently assigned caused commands with missing mask bits to be run. Avoid this. Best reviewed with "git show -w" or similar. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: John Mulligan <jmulligan@redhat.com>
2026-04-16ctdb-scripts: Simplify by taking advantage of early return/exitMartin Schwenke1-13/+13
Negate the condition in the if-statement so the current else part goes first. It always returns or exits, so the remainder (current if part) can just follow. This makes a subsequent change easier to understand. Probably best reviewed with "git show -w" or similar. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: John Mulligan <jmulligan@redhat.com>
2026-04-16ctdb-scripts: Fix the NAT gateway IP drop in crash cleanupMartin Schwenke1-1/+1
This has been bizarrely wrong since commit 095fac9491bfe6a29127d9c3f76c15bc947cf591. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: John Mulligan <jmulligan@redhat.com>
2026-04-16ctdb-scripts: No longer attempt to delete IP from new interfaceMartin Schwenke1-2/+1
Since commit 6471541d6d2bc9f2af0ff92b280abbd1d933cf88 this is completely unnecessary because interface $oiface is determined by looking at the system. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: John Mulligan <jmulligan@redhat.com>
2026-04-16ctdb-scripts: Add address with specified mask bits in updateipMartin Schwenke1-1/+1
That is, add using $_maskbits, not $maskbits. In the rare case where the mask bits were inconsistent on the old interface, $maskbits will be needed for removal from the old interface. However, the specified mask bits ($_maskbits) must always be used when adding to the new interface. Circumstances where this matters are likely to be very rare. It matters more if the address is unexpectedly not assigned at all. In this case $maskbits will not be set, so the address can't be added to the new interface using that variable. This got confused in commit 6471541d6d2bc9f2af0ff92b280abbd1d933cf88. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: John Mulligan <jmulligan@redhat.com>
2026-04-16ctdb-scripts: Change style to use if-statementsMartin Schwenke2-10/+10
Well known, explicit structured programming constructs are arguably easier to understand than implicit shell magic. Only change instances that will be updated by subsequent commits. Doing this separately, instead of in each subsequent commit, will make those commits easier to understand. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: John Mulligan <jmulligan@redhat.com>
2026-04-16ctdb-scripts: Reformat with "shfmt -w -i 0 -fn"Martin Schwenke3-136/+138
Best reviewed with "git show -w" or similar. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: John Mulligan <jmulligan@redhat.com>
2026-04-16ctdb-scripts: Avoid a shellcheck complaintMartin Schwenke1-1/+1
In ctdb/config/events/legacy/11.natgw.script line 174: read _old_natgwleader <"$natgw_leader_old" ^--^ SC2162 (info): read without -r will mangle backslashes. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: John Mulligan <jmulligan@redhat.com>
2026-03-18ctdb-tests: Tweak some NFS monitoring tests for portabilityMartin Schwenke2-4/+8
FreeBSD doesn't have an option to print time in nanoseconds. We need to run something to produce fake "statistics" that are guaranteed to change. I think this will do - the chances of getting the same 256 bytes twice in a row seems small enough. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org> Autobuild-User(master): Martin Schwenke <martins@samba.org> Autobuild-Date(master): Wed Mar 18 12:33:13 UTC 2026 on atb-devel-224
2026-03-18ctdb-tests: Skip statd-callout tests on FreeBSDMartin Schwenke1-0/+2
NFS is probably wildly different on FreeBSD and statd_callout_helper uses chown with the --reference option. Too hard. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-03-18ctdb-scripts: Trim "wc -l" output for FreeBSD compatibilityMartin Schwenke1-2/+4
tests/UNIT/eventscripts/10.interface.020.sh fails in case "10.interface.script releaseip dev123 10.0.0.3 24" with: -------------------------------------------------- Output (Exit status: 0): -------------------------------------------------- Killed 10/10 TCP connections to released IP 10.0.0.3, using ss -K -------------------------------------------------- Required output (Exit status: 0): -------------------------------------------------- Killed 10/10 TCP connections to released IP 10.0.0.3, using ss -K FAILED ========================================================================== TEST FAILED: ./tests/UNIT/eventscripts/10.interface.020.sh (status 1) (duration: 1s) ========================================================================== We have seen this type of thing before when output doesn't match because FreeBSD wc -l space-pads output. For example, see commit c6c81ea287924c2924aebc6dc0cdea1dc4322ae2. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-03-18ctdb-event: Fix the build on FreeBSDMartin Schwenke3-3/+3
FreeBSD does not have ENODATA. Sorry, I wasn't thinking about portability when I made the changes that introduced the use of ENODATA here. :-( Use ENOMSG instead, for lack of anything better, to indicate a script slot containing no result. ENOENT might seem more appropriate but it is already involved in this code (where it is sometimes mapped to ENOEXEC). The choice of error number only needs to be consistent within the event code. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-tests: Update READMEMartin Schwenke1-2/+6
Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-common: Remove unused function ctdb_set_helper()Martin Schwenke2-67/+0
Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-daemon: Remove helper variable CTDB_DEBUG_LOCKSMartin Schwenke3-19/+9
Replace with a lock_debug_script member in ctdb_context. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-tests: Reorder and group script variables, add commentsMartin Schwenke1-9/+18
Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-tests: Remove unused helper variable CTDB_SCRIPTS_HELPER_BINDIRMartin Schwenke1-3/+0
Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-daemon: Remove helper variable CTDB_CLUSTER_MUTEX_HELPERMartin Schwenke6-105/+17
Use path_helperdir() to help construct the path and then cache the result in the existing static buffer (with length adjusted because POSIX says the +1 is not necessary). Given the way this is used by cluster_mutex_test, there is no (other) sane place to cache it. path_helperdir_append() could be used to construct the path, but then there would be an unnecessary talloc() result to free. The flexibility in unit test cluster_mutex_003.sh was never used, so remove this test. If other cluster mutex helpers are added then they can be tested by separate tests. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-daemon: Remove helper variable CTDB_LOCK_HELPERMartin Schwenke4-11/+9
Replace with a lock_helper member in ctdb_context, set using path_helperdir_append(). Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-daemon: Remove helper variable CTDB_EVENTDMartin Schwenke2-9/+1
Simplify the initialisation of the path to eventd in eventd_context using path_helperdir_append(). Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-recoverd: Remove some helper variablesMartin Schwenke2-18/+17
Remove CTDB_RECOVERY_HELPER, CTDB_TAKEOVER_HELPER. Add new struct members in ctdb_recoverd to contain the paths, set via path_helperdir_append(). Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-tools: Remove some helper variablesMartin Schwenke4-36/+6
Remove CTDB_EVENT_HELPER, CTDB_LVS_HELPER, CTDB_NATGW_HELPER. Use path_helperdir_append() instead. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-common: Add path_helperdir() and path_helperdir_append()Martin Schwenke2-0/+33
These can be used to locate helpers, either during in-tree testing (using $CTDB_TEST_HELPER_BINDIR) or in their configured installation location. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-tests: Drop an unnecessary use of CTDB_SCRIPTS_HELPER_BINDIRMartin Schwenke1-2/+1
As a helper, ctdb-path is in $CTDB_TEST_HELPER_BINDIR, which is in $PATH. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-tests: Use CTDB_TEST_HELPER_BINDIR inlineMartin Schwenke9-14/+14
Replace most remaining uses of CTDB_SCRIPTS_TOOLS_HELPER_DIR and CTDB_SCRIPTS_HELPER_BINDIR. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-tests: Remove redundant PATH addsMartin Schwenke11-24/+0
These are covered because CTDB_TEST_HELPER_BINDIR is now added to PATH. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-tests: Add CTDB_TEST_HELPER_BINDIRMartin Schwenke2-3/+10
Now that generated scripts are linked into bin/, nothing needs to be run from the tools/ directory anymore during self-test. So, introduce CTDB_TEST_HELPER_BINDIR to replace both CTDB_SCRIPTS_TOOLS_HELPER_DIR and CTDB_SCRIPTS_HELPER_BINDIR. Add this directory to PATH. CTDB_TEST_HELPER_BINDIR will also be used in combination with CTDB_TEST_MODE to allow helpers to be found via a single mechanism that uses this single variable. This will replace the multiple mechanisms and variables currently used. For simplicity, leave the old variables alone for now. Replacing them in a comprehensible way will take a few steps. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-tests: Silence some shellcheck complaintsMartin Schwenke5-9/+23
Add most of the fixed files to the associated shellcheck unit test. Include a couple of formatting fixups. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-tests: Reformat with "shfmt -w -i 0 -fn"Martin Schwenke16-210/+230
Best reviewed with "git show -w" or similar. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-tests: Add a useful commentMartin Schwenke1-0/+3
Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-tests: Remove unused variablesMartin Schwenke1-4/+0
Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-build: Store generator rules in variablesMartin Schwenke1-14/+14
This improves readability and maintainability. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-build: Ensure generated scripts are executable and symlinkedMartin Schwenke1-8/+22
Ensure that all generated scripts are executable. All of the generated scripts (except test harnesses ctdb_run_tests, ctdb_local_daemons) also need to be linked into the bin/ directory so they can be more easily run during self-test. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-23ctdb-tools: Fix CID 1681637 - Drop unnecessary if-statementsMartin Schwenke1-9/+0
The first was found by Coverity: >>> CID 1681637: Incorrect expression (IDENTICAL_BRANCHES) >>> The same code is executed when the condition "ret != 0" is true or false, because the code in the if-then branch and after the if statement is identical. Should the if statement be removed? The second and third are also obvious. Sorry, missed these in review. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Signed-off-by: Anoop C S <anoopcs@samba.org> Autobuild-User(master): Anoop C S <anoopcs@samba.org> Autobuild-Date(master): Mon Feb 23 08:43:29 UTC 2026 on atb-devel-224
2026-02-20ctdb-doc: add section to manpage for -j/--json optionJohn Mulligan1-0/+17
Signed-off-by: John Mulligan <jmulligan@redhat.com> Reviewed-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Anoop C S <anoopcs@samba.org> Autobuild-User(master): Martin Schwenke <martins@samba.org> Autobuild-Date(master): Fri Feb 20 01:50:20 UTC 2026 on atb-devel-224
2026-02-20ctdb-tools: add some tests cases for ctdb status --jsonJohn Mulligan3-0/+261
Signed-off-by: John Mulligan <jmulligan@redhat.com> Reviewed-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-20ctdb-tests: add wrapper helper over JSON-mode commandShachar Sharon1-0/+8
Run ctdb sub-command with '--json' flag only when code has been compiled with json support. Otherwise, ignore the test silently. Signed-off-by: Shachar Sharon <ssharon@redhat.com> Reviewed-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-20ctdb-tools: add --json support to 'version' sub-commandShachar Sharon1-1/+33
When building ctdb with json-outpuit support, enable json output when running 'ctdb version --json'. This may be used as indication to json support in other sub-commands. Pair-Programmed-With: John Mulligan <jmulligan@redhat.com> Signed-off-by: Shachar Sharon <ssharon@redhat.com> Signed-off-by: John Mulligan <jmulligan@redhat.com> Reviewed-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-20ctdb-tools: add a --json option for ctdb statusJohn Mulligan1-15/+445
Add a new --json option that prints JSON as a higher-level machine parse-able output. The --json option is only supported if the jansson library is available. The --json option will ONLY print json. If the subcommand does not (yet) support json it will raise an error rather than fall back to emitting human readable text. This way a json parser is never given "invalid" input. Pair-Programmed-With: Shachar Sharon <ssharon@redhat.com> Signed-off-by: Shachar Sharon <ssharon@redhat.com> Signed-off-by: John Mulligan <jmulligan@redhat.com> Reviewed-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Anoop C S <anoopcs@samba.org>