]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-tests: Improve setup_ctdb_base() to fix local_daemons.sh bug
authorMartin Schwenke <mschwenke@ddn.com>
Tue, 7 Oct 2025 11:27:06 +0000 (22:27 +1100)
committerRalph Boehme <slow@samba.org>
Tue, 14 Oct 2025 16:53:36 +0000 (16:53 +0000)
$ ctdb/tests/local_daemons.sh foo onnode 0 ctdb event script list legacy
Unable to find event script installation directory: foo/node.0/share/events/legacy

This happens if the $CTDB_BASE/share/events/legacy/ directory does not
exist.  This directory is (theoretically) for installed but not
necessarily enabled event scripts.  ctdb/tests/etc-ctdb/ contains
events/legacy/ but setup_ctdb_base() currently does not ensure
creation of the corresponding directory under $CTDB_BASE/share/.

Ensure that an event script component installation subdirectory exists
for each corresponding configuration subdirectory.

An alternative would be to continue to allow the existing failure, but
create directory ctdb/tests/etc-ctdb/share/events/legacy/ specifically
to make local_daemons.sh work.  However, it took 5 years to find the
current bug, so this may be too subtle for other users of
local_daemons.sh.  Anyone wanting to test the failure case can remove
unwanted subdirectories after "local_daemons.sh setup".

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
ctdb/tests/scripts/common.sh

index ba3d0f4c8bb3a74e0db6cba8ad612e64ea7e9cb4..eb2c4c0a8a5ca0ea635ccf0bc15eba2f5b14ec1c 100644 (file)
@@ -148,5 +148,18 @@ setup_ctdb_base()
                [ -e "$_i" ] || break
 
                cp -pr "$_i" "${CTDB_BASE}/"
+
+       done
+
+       # Ensure existence of an event script component installation
+       # subdirectory corresponding to each event script component
+       # configuration subdirectory.
+       #
+       # This helps:
+       #   local_daemons.sh <dir> onnode <n> ctdb event script list <component>
+       # to work.
+       for _d in "${CTDB_BASE}/events/"*; do
+               _b=$(basename "$_d")
+               mkdir -p "${CTDB_BASE}/share/events/${_b}"
        done
 }