[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Thu May 30 12:51:01 UTC 2024


The branch, master has been updated
       via  e9eb5810438 ctdb-scripts: Protect against races when starting grace period
       via  911117c79a1 ctdb-scripts: Check NFS-Ganesha is running before attempting grace
       via  27c53880c2a ctdb-scripts: Improve service PID check
       via  bc10704aec6 ctdb-scripts: Improve NFS-Ganesha export path extraction
       via  944d9d308d5 ctdb-scripts: Add script option CTDB_NFS_EXPORTS_FILE
       via  1be5b1df1bd ctdb-scripts: Fix usage message
       via  2a3d7c09719 ctdb-scripts: Change NFS-Ganesha PID file location
       via  a534f713478 ctdb-scripts: Quote variable expansions
       via  6ffb73bb55e ctdb-scripts: Reformat with "shfmt -w -p -i 0 -fn"
       via  991d21d075c ctdb-scripts: No longer run statd-callout under sudo
       via  ecb9545b3fb ctdb-scripts: Use find_statd_sm_dir() in one more place
       via  50b3cebeb39 ctdb-scripts: Set ownership of statd-callout state directory
       via  608557c6ce3 ctdb-scripts: Avoid connecting to ctdbd in add-client/del-client
       via  5a4209b7132 ctdb-tests: Default PNN is 0
       via  ed3f041c309 ctdb-scripts: Add caching function for public IPs
       via  558cf280b22 ctdb-scripts: Move state directory creation to "startup" action
       via  d02fb20d793 ctdb-scripts: Avoid globally changing to queue directory
       via  b90d72c7b8f ctdb-scripts: Move ctdb.tdb attach to statd-callout
       via  c912e406c1c ctdb-scripts: Reformat with shfmt -w -p -i 0 -fn
       via  7b24cc032ea ctdb-scripts: Improve documentation
       via  5176b43da78 ctdb-scripts: Avoid ShellCheck warning SC2162
       via  54015223804 ctdb-scripts: Reformat with "shfmt -w -p -i 0 -fn"
      from  5a54c9b28ab s3:utils: let smbstatus report anonymous signing/encryption explicitly

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit e9eb5810438c7de713a45f43af227798a6b5ec2f
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Fri May 10 18:00:18 2024 +1000

    ctdb-scripts: Protect against races when starting grace period
    
    While the PID check is worth it in relevant cases, NFS-Ganesha still
    might go away after the check.  Unfortunately, neither grace command
    fails an indicative exit code, so invent one by checking error
    messages.  This can then be converted to success by the caller.
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Thu May 30 12:50:01 UTC 2024 on atb-devel-224

commit 911117c79a1c9a61a74aced8d87346dd25c8cce3
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Fri May 10 17:51:18 2024 +1000

    ctdb-scripts: Check NFS-Ganesha is running before attempting grace
    
    If monitoring has failed because it isn't running, then don't fail
    "startipreallocate" or "relaseip" by trying to go into grace.
    
    Don't check this for "takeip".  In that case NFS-Ganesha had better be
    running.
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 27c53880c2a35a320bc31655ada3367d1be02b19
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Fri May 10 17:46:58 2024 +1000

    ctdb-scripts: Improve service PID check
    
    No need to grovel around in /proc.  ps will happily tell us the
    command.
    
    Factor out the actual check into a separate function that can be used
    elsewhere.
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit bc10704aec66e143b8c9e715a74ddb82f44a3204
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Tue Apr 30 15:00:34 2024 +1000

    ctdb-scripts: Improve NFS-Ganesha export path extraction
    
    Path values do not need to have quotes.  The current code fails if
    there aren't any.
    
    Instead, implement a 2 stage parser using 2 sed commands.  See
    comments in the code for details.
    
    Regexps are POSIX basic regular expressions, apart from \<WORD\> (used
    to ensure WORD is on word boundaries, and the 'i' flag for case
    insensitivity.  The latter is supported in FreeBSD sed.
    
    This code successfully parses Path values out of the following
    monstrosity:
    
    path = "/foo/bar1;a";
       Path = /foo/bar2;
    Something = false;
    Pseudo = "/foo/bar3x" ; Path = "/foo/bar3; y" ; Access_type = RO;
    Pseudo = "/foo/bar4x" ; path=/foo/bar4; Access_type = RO;
    Pseudo = "/foo/barNONONO" ; not_Path=/foo/barNONONO; Access_type = RO;
       Path = /foo/bar5
    Pseudo = "/foo/bar6x Path=foo" ; Path=/foo/bar6; Access_type = RO
    
    This is probably the best that can be done within a shell script.
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 944d9d308d53598ba0aa2dc599fc1f5c78e78313
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Wed Mar 27 14:24:09 2024 +1100

    ctdb-scripts: Add script option CTDB_NFS_EXPORTS_FILE
    
    Exports may be contained in an include file rather than the top-level
    ganesha.conf.
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 1be5b1df1bd28d1cebc61c2287de2e42b9f034d9
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Thu Jul 6 13:37:03 2023 +1000

    ctdb-scripts: Fix usage message
    
    An IP address is passed to these actions.
    
    Reported-by: Arnab Tah <atah at ddn.com>
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 2a3d7c09719c1898bc90ace2bc35cbb74d75b5f4
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Thu Jul 6 20:28:30 2023 +1000

    ctdb-scripts: Change NFS-Ganesha PID file location
    
    This is the current default.
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit a534f7134789baea547e6b3686e0c60fcd5cc81c
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Tue Mar 5 14:44:32 2024 +1100

    ctdb-scripts: Quote variable expansions
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 6ffb73bb55ef2c7a72426945e8a8595a5c8f3738
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Tue Mar 5 14:26:19 2024 +1100

    ctdb-scripts: Reformat with "shfmt -w -p -i 0 -fn"
    
    Best reviewed with "git show -w".
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 991d21d075c0382b27dc9da64e8a6cfd94f175c0
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Mon Jun 19 10:39:29 2023 +1000

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

commit ecb9545b3fbf9e6da238096f937cd3fb4fd503ec
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Wed Aug 2 13:37:03 2023 +1000

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

commit 50b3cebeb39be1124d6ea572cb452cbd2a43f65e
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Mon Jun 19 12:17:44 2023 +1000

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

commit 608557c6ce3f1a26c62792db56869958e325d9ff
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Thu Jun 29 10:12:44 2023 +1000

    ctdb-scripts: Avoid connecting to ctdbd in add-client/del-client
    
    rpc.statd runs statd-callout as a non-root user, which is currently
    hacked around using some sudo logic that fails to work in some
    contexts (e.g. in a container).
    
    Use $CTDB_MY_PUBLIC_IPS_CACHE to access the node's currently assigned
    public IPs, for add-client/del-client.  This avoids connecting to
    ctdbd when called from rpc.statd.
    
    Also, use $CTDB_MY_PUBLIC_IPS_CACHE in other places where it makes
    sense.
    
    Connections to ctdbd are still made in the "notify" action, but this
    is always run as root.
    
    In the test code, set the PNN after public addresses setup so that the
    cache of assigned IPs correctly initialised.
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 5a4209b713226eeba6cfbff6e85b8e72cadfe9e7
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Fri Jun 30 12:24:30 2023 +1000

    ctdb-tests: Default PNN is 0
    
    This is called in a couple of places without an argument, so give it a
    default.
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit ed3f041c309e84bcb73fda9a7a68dbf69f63e3e3
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Thu Jun 15 16:21:19 2023 +1000

    ctdb-scripts: Add caching function for public IPs
    
    This is way more complicated than I would like but, as per the
    comment, this is due to complexities in the way public IPs work.  The
    main consumer will be statd-callout, which will then be able to run as
    a non-root user.
    
    Also generate the cache file in test code, whenever the PNN is set.
    However, this can cause "ctdb ip" to generate a fake IP layout before
    public IPs are setup.  So, have the "ctdb ip" stub generate the IP
    layout every time it is run to avoid it being stale.
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 558cf280b22e0433c3601f47fb1ce8b660e71691
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Thu Jun 29 13:25:03 2023 +1000

    ctdb-scripts: Move state directory creation to "startup" action
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit d02fb20d793312150b20507e8309c414d49b3320
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Wed May 8 14:44:13 2024 +1000

    ctdb-scripts: Avoid globally changing to queue directory
    
    Add new variables statd_callout_state_dir and statd_callout_queue_dir
    - the latter is for files queued by add-client/del-client.
    
    Use $statd_callout_queue_dir to avoid a global cd to the queue
    directory near the top of the script.
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit b90d72c7b8f01bb50bc9ae8138342afb359c6988
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Thu Jun 29 13:11:46 2023 +1000

    ctdb-scripts: Move ctdb.tdb attach to statd-callout
    
    All of the other uses of ctdb.tdb are in statd-callout.
    
    New variable statd_callout_db makes it easy to change the database
    name in future, perhaps even allowing it to be configurable.
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit c912e406c1cf8346b5eff8dd3582b102bae3b0df
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Mon Feb 19 12:56:46 2024 +1100

    ctdb-scripts: Reformat with shfmt -w -p -i 0 -fn
    
    Tweak some lines to avoid overflowing 80 columns.
    
    Best viewed with "git show -w".
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 7b24cc032ea49e71beca76a81e2a70739c5636dd
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Tue Jun 13 10:39:37 2023 +1000

    ctdb-scripts: Improve documentation
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 5176b43da78dd14f6ed85463bcb64fc3375d4b1d
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Mon Jun 19 09:43:33 2023 +1000

    ctdb-scripts: Avoid ShellCheck warning SC2162
    
      SC2162 read without -r will mangle backslashes.
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 54015223804a514bb5cc76312c70325704a11459
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Fri Jun 16 11:09:02 2023 +1000

    ctdb-scripts: Reformat with "shfmt -w -p -i 0 -fn"
    
    Best reviewed with "git show -w".
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 ctdb/config/ctdb.sudoers                           |   3 -
 ctdb/config/events/legacy/00.ctdb.script           |   4 -
 ctdb/config/events/legacy/10.interface.script      |   9 +
 ctdb/config/events/legacy/60.nfs.script            | 318 +++++++++++----------
 ctdb/config/functions                              |  56 ++++
 ctdb/config/nfs-linux-kernel-callout               |   9 +-
 ctdb/config/statd-callout                          | 214 ++++++++------
 ctdb/doc/ctdb-script.options.5.xml                 |  23 ++
 ctdb/doc/examples/ctdb.spec.in                     |   6 +-
 ctdb/doc/examples/nfs-ganesha-callout              | 206 ++++++++-----
 ctdb/tests/UNIT/eventscripts/scripts/local.sh      |  10 +-
 .../UNIT/eventscripts/scripts/statd-callout.sh     |   2 +-
 ctdb/tests/UNIT/eventscripts/statd-callout.001.sh  |   1 +
 ctdb/tests/UNIT/eventscripts/statd-callout.002.sh  |   1 +
 ctdb/tests/UNIT/eventscripts/statd-callout.003.sh  |   1 +
 ctdb/tests/UNIT/eventscripts/statd-callout.004.sh  |   1 +
 ctdb/tests/UNIT/eventscripts/statd-callout.005.sh  |   2 +
 ctdb/tests/UNIT/eventscripts/statd-callout.006.sh  |   2 +
 ctdb/tests/UNIT/eventscripts/statd-callout.007.sh  |   1 +
 ctdb/tests/UNIT/eventscripts/stubs/ctdb            |   8 +-
 ctdb/tests/UNIT/eventscripts/stubs/id              |   3 -
 ctdb/wscript                                       |   7 -
 22 files changed, 549 insertions(+), 338 deletions(-)
 delete mode 100644 ctdb/config/ctdb.sudoers
 delete mode 100755 ctdb/tests/UNIT/eventscripts/stubs/id


Changeset truncated at 500 lines:

diff --git a/ctdb/config/ctdb.sudoers b/ctdb/config/ctdb.sudoers
deleted file mode 100644
index 1c238180cc9..00000000000
--- a/ctdb/config/ctdb.sudoers
+++ /dev/null
@@ -1,3 +0,0 @@
-Defaults!/usr/local/etc/ctdb/statd-callout	!requiretty
-
-rpcuser		ALL=(ALL) 	NOPASSWD: /usr/local/etc/ctdb/statd-callout
diff --git a/ctdb/config/events/legacy/00.ctdb.script b/ctdb/config/events/legacy/00.ctdb.script
index 81c16af08a0..292081bbe06 100755
--- a/ctdb/config/events/legacy/00.ctdb.script
+++ b/ctdb/config/events/legacy/00.ctdb.script
@@ -120,10 +120,6 @@ init)
 	    check_non_persistent_databases
 	fi
 	;;
-
-startup)
-	$CTDB attach ctdb.tdb persistent
-	;;
 esac
 
 # all OK
diff --git a/ctdb/config/events/legacy/10.interface.script b/ctdb/config/events/legacy/10.interface.script
index 110b1213966..fdc559ee1c8 100755
--- a/ctdb/config/events/legacy/10.interface.script
+++ b/ctdb/config/events/legacy/10.interface.script
@@ -149,6 +149,8 @@ takeip)
 	ip=$3
 	maskbits=$4
 
+	update_my_public_ip_addresses "takeip" "$ip"
+
 	add_ip_to_iface "$iface" "$ip" "$maskbits" || {
 		exit 1;
 	}
@@ -177,6 +179,8 @@ releaseip)
 
 	kill_tcp_connections "$iface" "$ip"
 
+	update_my_public_ip_addresses "releaseip" "$ip"
+
 	delete_ip_from_iface "$iface" "$ip" "$maskbits" || {
 		ip_unblock "$ip" "$iface"
 		exit 1
@@ -236,6 +240,11 @@ updateip)
 	tickle_tcp_connections "$ip"
 	;;
 
+ipreallocated)
+	# Just to make sure
+	update_my_public_ip_addresses "ipreallocated"
+	;;
+
 monitor)
 	monitor_interfaces || exit 1
 	;;
diff --git a/ctdb/config/events/legacy/60.nfs.script b/ctdb/config/events/legacy/60.nfs.script
index 001140611a2..6935ad9fadc 100755
--- a/ctdb/config/events/legacy/60.nfs.script
+++ b/ctdb/config/events/legacy/60.nfs.script
@@ -1,7 +1,7 @@
 #!/bin/sh
 # script to manage nfs in a clustered environment
 
-[ -n "$CTDB_BASE" ] || \
+[ -n "$CTDB_BASE" ] ||
 	CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && dirname "$PWD")
 
 . "${CTDB_BASE}/functions"
@@ -16,14 +16,14 @@ ctdb_setup_state_dir "service" "$service_name"
 
 ######################################################################
 
-service_reconfigure ()
+service_reconfigure()
 {
-    # Restart lock manager, notify clients
-    # shellcheck disable=SC2317
-    # Called indirectly via check_thresholds()
-    if [ -x "${CTDB_BASE}/statd-callout" ] ; then
-	"${CTDB_BASE}/statd-callout" notify &
-    fi >/dev/null 2>&1
+	# Restart lock manager, notify clients
+	# shellcheck disable=SC2317
+	# Called indirectly via check_thresholds()
+	if [ -x "${CTDB_BASE}/statd-callout" ]; then
+		"${CTDB_BASE}/statd-callout" notify &
+	fi >/dev/null 2>&1
 }
 
 ######################################################################
@@ -34,19 +34,19 @@ service_reconfigure ()
 # Use .check files in $CTDB_NFS_CHECKS_DIR.
 # Default is "${CTDB_BASE}/nfs-checks.d/"
 ######################################################
-nfs_check_services ()
+nfs_check_services()
 {
-    _dir="${CTDB_NFS_CHECKS_DIR:-${CTDB_BASE}/nfs-checks.d}"
+	_dir="${CTDB_NFS_CHECKS_DIR:-${CTDB_BASE}/nfs-checks.d}"
 
-    # Files must end with .check - avoids editor backups, RPM fu, ...
-    for _f in "$_dir"/[0-9][0-9].*.check ; do
-	[ -r "$_f" ] || continue
+	# Files must end with .check - avoids editor backups, RPM fu, ...
+	for _f in "$_dir"/[0-9][0-9].*.check; do
+		[ -r "$_f" ] || continue
 
-	_t="${_f%.check}"
-	_progname="${_t##*/[0-9][0-9].}"
+		_t="${_f%.check}"
+		_progname="${_t##*/[0-9][0-9].}"
 
-	nfs_check_service "$_progname" <"$_f"
-    done
+		nfs_check_service "$_progname" <"$_f"
+	done
 }
 
 ######################################################
@@ -84,169 +84,177 @@ nfs_check_services ()
 # Quoting in values is not preserved
 #
 ######################################################
-nfs_check_service ()
+nfs_check_service()
 {
-    _progname="$1"
-
-    # This sub-shell is created to intentionally limit the scope of
-    # variable values read from the .check files.
-    # shellcheck disable=SC2030
-    (
-	# Subshell to restrict scope variables...
-
-	# Defaults
-	family="tcp"
-	version=""
-	unhealthy_after=1
-	restart_every=0
-	service_stop_cmd=""
-	service_start_cmd=""
-	service_check_cmd=""
-	service_debug_cmd=""
-
-	# Eval line-by-line.  Expands variable references in values.
-	# Also allows variable name checking, which seems useful.
-	while read _line ; do
-	    case "$_line" in
-		\#*|"") : ;; # Ignore comments, blank lines
-
-		family=*|version=*|\
-		unhealthy_after=*|restart_every=*|\
-		service_stop_cmd=*|service_start_cmd=*|\
-		service_check_cmd=*|service_debug_cmd=*)
-
-		    eval "$_line"
-		    ;;
-		*)
-		    echo "ERROR: Unknown variable for ${_progname}: ${_line}"
-		    exit 1
-	    esac
-	done
-
-	_ok=false
-	if [ -n "$service_check_cmd" ] ; then
-	    # Using eval means variables can contain semicolon separated commands
-	    if eval "$service_check_cmd" ; then
-		_ok=true
-	    else
-		_err="monitoring service \"${_progname}\" failed"
-	    fi
-	else
-	    if nfs_check_rpcinfo \
-		   "$_progname" "$version" "$family" >/dev/null ; then
-		_ok=true
-	    else
-		_err="$ctdb_check_rpc_out"
-	    fi
-	fi
+	_progname="$1"
+
+	# This sub-shell is created to intentionally limit the scope of
+	# variable values read from the .check files.
+	# shellcheck disable=SC2030
+	(
+		# Subshell to restrict scope variables...
+
+		# Defaults
+		family="tcp"
+		version=""
+		unhealthy_after=1
+		restart_every=0
+		service_stop_cmd=""
+		service_start_cmd=""
+		service_check_cmd=""
+		service_debug_cmd=""
+
+		# Eval line-by-line.  Expands variable references in values.
+		# Also allows variable name checking, which seems useful.
+		while read _line; do
+			case "$_line" in
+			\#* | "") : ;; # Ignore comments, blank lines
+
+			family=* | version=* | \
+				unhealthy_after=* | restart_every=* | \
+				service_stop_cmd=* | service_start_cmd=* | \
+				service_check_cmd=* | service_debug_cmd=*)
+
+				eval "$_line"
+				;;
+			*)
+				printf 'ERROR: Unknown variable for %s: %s\n' \
+					"$_progname" "$_line"
+				exit 1
+				;;
+			esac
+		done
+
+		_ok=false
+		if [ -n "$service_check_cmd" ]; then
+			# Using eval means variables can contain
+			# semicolon separated commands
+			if eval "$service_check_cmd"; then
+				_ok=true
+			else
+				_err="monitoring service \"${_progname}\" failed"
+			fi
+		else
+			if nfs_check_rpcinfo \
+				"$_progname" "$version" "$family" \
+				>/dev/null; then
+				_ok=true
+			else
+				_err="$ctdb_check_rpc_out"
+			fi
+		fi
 
-	if $_ok ; then
-	    if [ $unhealthy_after -ne 1 ] || [ $restart_every -ne 0 ] ; then
-		ctdb_counter_init "$_progname"
-	    fi
-	    exit 0
-	fi
+		if $_ok; then
+			if [ $unhealthy_after -ne 1 ] ||
+				[ $restart_every -ne 0 ]; then
+				ctdb_counter_init "$_progname"
+			fi
+			exit 0
+		fi
 
-	ctdb_counter_incr "$_progname"
-	_failcount=$(ctdb_counter_get "$_progname")
+		ctdb_counter_incr "$_progname"
+		_failcount=$(ctdb_counter_get "$_progname")
 
-	_unhealthy=false
-	if [ "$unhealthy_after" -gt 0 ] ; then
-	    if [ "$_failcount" -ge "$unhealthy_after" ] ; then
-		_unhealthy=true
-		echo "ERROR: $_err"
-	    fi
-	fi
+		_unhealthy=false
+		if [ "$unhealthy_after" -gt 0 ]; then
+			if [ "$_failcount" -ge "$unhealthy_after" ]; then
+				_unhealthy=true
+				echo "ERROR: $_err"
+			fi
+		fi
 
-	if [ "$restart_every" -gt 0 ] ; then
-	    if [ $((_failcount % restart_every)) -eq 0 ] ; then
-		if ! $_unhealthy ; then
-		    echo "WARNING: $_err"
+		if [ "$restart_every" -gt 0 ]; then
+			if [ $((_failcount % restart_every)) -eq 0 ]; then
+				if ! $_unhealthy; then
+					echo "WARNING: $_err"
+				fi
+				nfs_restart_service
+			fi
 		fi
-		nfs_restart_service
-	    fi
-	fi
 
-	if $_unhealthy ; then
-	    exit 1
-	fi
+		if $_unhealthy; then
+			exit 1
+		fi
 
-	return 0
-    ) || exit 1
+		return 0
+	) || exit 1
 }
 
 # Uses: service_stop_cmd, service_start_cmd, service_debug_cmd
 # This function is called within the sub-shell that shellcheck thinks
 # loses the above variable values.
 # shellcheck disable=SC2031
-nfs_restart_service ()
+nfs_restart_service()
 {
-    if [ -z "$service_stop_cmd" ] || [ -z "$service_start_cmd" ] ; then
-	die "ERROR: Can not restart service \"${_progname}\" without corresponding service_start_cmd/service_stop_cmd settings"
-    fi
-
-    echo "Trying to restart service \"${_progname}\"..."
-    # Using eval means variables can contain semicolon separated commands
-    eval "$service_stop_cmd"
-    if [ -n "$service_debug_cmd" ] ; then
-	eval "$service_debug_cmd"
-    fi
-    background_with_logging eval "$service_start_cmd"
+	if [ -z "$service_stop_cmd" ] || [ -z "$service_start_cmd" ]; then
+		die "ERROR: Can not restart service \"${_progname}\" without corresponding service_start_cmd/service_stop_cmd settings"
+	fi
+
+	echo "Trying to restart service \"${_progname}\"..."
+	# Using eval means variables can contain semicolon separated commands
+	eval "$service_stop_cmd"
+	if [ -n "$service_debug_cmd" ]; then
+		eval "$service_debug_cmd"
+	fi
+	background_with_logging eval "$service_start_cmd"
 }
 
 ######################################################
 # Check an RPC service with rpcinfo
 ######################################################
-ctdb_check_rpc ()
+ctdb_check_rpc()
 {
-    _progname="$1"        # passed to rpcinfo (looked up in /etc/rpc)
-    _version="$2"         # optional, not passed if empty/unset
-    _family="${3:-tcp}"   # optional, default is "tcp"
-
-    case "$_family" in
-	tcp6|udp6)
-	    _localhost="${CTDB_RPCINFO_LOCALHOST6:-::1}"
-	    ;;
+	_progname="$1"      # passed to rpcinfo (looked up in /etc/rpc)
+	_version="$2"       # optional, not passed if empty/unset
+	_family="${3:-tcp}" # optional, default is "tcp"
+
+	case "$_family" in
+	tcp6 | udp6)
+		_localhost="${CTDB_RPCINFO_LOCALHOST6:-::1}"
+		;;
 	*)
-	    _localhost="${CTDB_RPCINFO_LOCALHOST:-127.0.0.1}"
-    esac
-
-    # $_version is not quoted because it is optional
-    # shellcheck disable=SC2086
-    if ! ctdb_check_rpc_out=$(rpcinfo -T "$_family" "$_localhost" \
-				      "$_progname" $_version 2>&1) ; then
-	ctdb_check_rpc_out="$_progname failed RPC check:
+		_localhost="${CTDB_RPCINFO_LOCALHOST:-127.0.0.1}"
+		;;
+	esac
+
+	# $_version is not quoted because it is optional
+	# shellcheck disable=SC2086
+	if ! ctdb_check_rpc_out=$(rpcinfo -T "$_family" "$_localhost" \
+		"$_progname" $_version 2>&1); then
+		ctdb_check_rpc_out="$_progname failed RPC check:
 $ctdb_check_rpc_out"
-	echo "$ctdb_check_rpc_out"
-	return 1
-    fi
+		echo "$ctdb_check_rpc_out"
+		return 1
+	fi
 }
 
-nfs_check_rpcinfo ()
+nfs_check_rpcinfo()
 {
-    _progname="$1"        # passed to rpcinfo (looked up in /etc/rpc)
-    _versions="$2"        # optional, space separated, not passed if empty/unset
-    _families="${3:-tcp}" # optional, space separated, default is "tcp"
-
-    for _family in $_families ; do
-	if [ -n "$_versions" ] ; then
-	    for _version in $_versions ; do
-		ctdb_check_rpc "$_progname" "$_version" "$_family" || return $?
-	    done
-	else
-	    ctdb_check_rpc "$_progname" "" "$_family" || return $?
-	fi
-    done
+	_progname="$1"        # passed to rpcinfo (looked up in /etc/rpc)
+	_versions="$2"        # optional, space separated, not passed if empty/unset
+	_families="${3:-tcp}" # optional, space separated, default is "tcp"
+
+	for _family in $_families; do
+		if [ -n "$_versions" ]; then
+			for _version in $_versions; do
+				ctdb_check_rpc \
+					"$_progname" "$_version" "$_family" ||
+					return $?
+			done
+		else
+			ctdb_check_rpc "$_progname" "" "$_family" || return $?
+		fi
+	done
 }
 
 ##################################################################
 # use statd-callout to update NFS lock info
 ##################################################################
-nfs_update_lock_info ()
+nfs_update_lock_info()
 {
-    if [ -x "$CTDB_BASE/statd-callout" ] ; then
-	"$CTDB_BASE/statd-callout" update
-    fi
+	if [ -x "$CTDB_BASE/statd-callout" ]; then
+		"$CTDB_BASE/statd-callout" update
+	fi
 }
 
 ######################################################################
@@ -257,6 +265,10 @@ nfs_callout_init "$script_state_dir"
 
 case "$1" in
 startup)
+	if [ -x "${CTDB_BASE}/statd-callout" ] ; then
+		"${CTDB_BASE}/statd-callout" startup
+	fi
+
 	nfs_callout "$@" || exit $?
 	;;
 
@@ -279,7 +291,7 @@ releaseip)
 	;;
 
 ipreallocated)
-	if ctdb_service_needs_reconfigure ; then
+	if ctdb_service_needs_reconfigure; then
 		ctdb_service_reconfigure
 	fi
 	;;
@@ -288,9 +300,9 @@ monitor)
 	nfs_callout "monitor-pre" || exit $?
 
 	# Check that directories for shares actually exist
-	if [ "$CTDB_NFS_SKIP_SHARE_CHECK" != "yes" ] ; then
-	    nfs_callout "monitor-list-shares" | ctdb_check_directories || \
-		exit $?
+	if [ "$CTDB_NFS_SKIP_SHARE_CHECK" != "yes" ]; then
+		nfs_callout "monitor-list-shares" | ctdb_check_directories ||
+			exit $?
 	fi
 
 	update_tickles 2049
@@ -299,7 +311,7 @@ monitor)
 	nfs_check_services
 
 	nfs_callout "monitor-post" || exit $?
-       	;;
+	;;
 esac
 
 exit 0
diff --git a/ctdb/config/functions b/ctdb/config/functions
index e76082b7cb3..fbb1e284020 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -269,6 +269,59 @@ ctdb_get_ip_address()
 	cat "$_ip_addr_file"
 }
 
+# Cache of public IP addresses assigned to this node.  This function
+# exists mainly so statd-callout does not need to talk to ctdbd, so
+# can be run as non-root, but it may be used in other places.  This
+# must be updated/refreshed on failover.  This is done in
+# 10.interface, but doing it in "ipreallocated" isn't enough because
+# clients may connect as soon as "takeip" completes.  Also, the VNN in
+# the daemon is only updated after the "releaseip" event completes, so
+# "ctdb -X ip" can't be relied on there.  Hence, complex updates
+# involving locking for "takeip" & "releaseip".  A future
+# restructuring of the failover model will obsolete all of these
+# moving parts.
+CTDB_MY_PUBLIC_IPS_CACHE="${CTDB_SCRIPT_VARDIR}/my-public-ip-addresses"
+update_my_public_ip_addresses()
+{
+	_event="$1"
+
+	_f="$CTDB_MY_PUBLIC_IPS_CACHE"
+	_lock="${_f}.lock"
+


-- 
Samba Shared Repository



More information about the samba-cvs mailing list