The branch, master has been updated via f1a1c300e19 ctdb-scripts: Do not "correct" number of nfsd threads when it is 0 via a2bd4085896 ctdb-scripts: Update statd-callout to try several configuration files via 0d67ea5fcca ctdb-scripts: Allow load_system_config() to take multiple alternatives via 95283bdf2e9 ctdb-scripts: Default to using systemd services in NFS call-out via 2833ddcfcb7 ctdb-tests: Update NFS test infrastructure to support systemd services via a8fafd377ff ctdb-scripts: Add systemd services to NFS call-out via 708c04071af ctdb-scripts: Start NFS quota service if defined via 42103b56869 ctdb-scripts: Stop/start mount/rquotad/status via NFS call-out via 8de0a339b55 ctdb-scripts: Factor out nfs_load_config() via e72c3c800a5 ctdb-scripts: Add test variable CTDB_NFS_DISTRO_STYLE via 9981353ab79 ctdb-scripts: Rename variable nfslock_service to nfs_lock_service via d7e187c1a70 ctdb-scripts: Reindent some functions prior to making changes from 865b7b0c7d2 libcli: permit larger values of DataLength in SMB2_ENCRYPTION_CAPABILITIES of negotiate response
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit f1a1c300e192d43f5c9faf9450ffbf16341a2661 Author: Martin Schwenke <mar...@meltin.net> Date: Tue Mar 26 14:15:33 2019 +1100 ctdb-scripts: Do not "correct" number of nfsd threads when it is 0 While 0 may indicate that all threads have exited after being stuck, it may also indicate that nfsd should not be running due to being shut down. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13860 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@samba.org> Autobuild-User(master): Martin Schwenke <mart...@samba.org> Autobuild-Date(master): Sun Mar 31 11:47:44 UTC 2019 on sn-devel-144 commit a2bd4085896804ee2da811e17f18c78a5bf4e658 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Mar 20 21:22:43 2019 +1100 ctdb-scripts: Update statd-callout to try several configuration files The alternative seems to be to try something via CTDB_NFS_CALLOUT. That would be complicated and seems like overkill for something this simple. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13860 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@samba.org> commit 0d67ea5fcca766734ecc73ad6b0139f7c13a15c5 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Mar 20 21:19:49 2019 +1100 ctdb-scripts: Allow load_system_config() to take multiple alternatives The situation for NFS config has got more complicated and is probably broken in statd-callout on Debian-like systems at the moment. Allow several alternative configuration names to be tried. Stop after the first that is found and loaded. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13860 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@samba.org> commit 95283bdf2e9ceff2e35af494c79345cfe25c2cf8 Author: Martin Schwenke <mar...@meltin.net> Date: Tue Mar 26 15:05:58 2019 +1100 ctdb-scripts: Default to using systemd services in NFS call-out BUG: https://bugzilla.samba.org/show_bug.cgi?id=13860 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@samba.org> commit 2833ddcfcb780497264e0f412a9ad6e26a9bc657 Author: Martin Schwenke <mar...@meltin.net> Date: Tue Mar 26 15:07:43 2019 +1100 ctdb-tests: Update NFS test infrastructure to support systemd services The tests are written around the default of sysvinit-redhat. Add support for systemd-redhat. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13860 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@samba.org> commit a8fafd377ff0cb07ab161e437c5fe024704345eb Author: Martin Schwenke <mar...@meltin.net> Date: Wed Mar 20 17:45:10 2019 +1100 ctdb-scripts: Add systemd services to NFS call-out At least Red Hat and Debian appear to use (a variant of?) the upstream systemd units for NFS, so adding support for these services is relatively easy. Distributions using Sys-V init can patch the call-out to use the relevant Sys-V init services. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13860 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@samba.org> commit 708c04071af8d6ddc3bf2bddbde4d5847f440c0e Author: Martin Schwenke <mar...@meltin.net> Date: Thu Mar 21 15:30:00 2019 +1100 ctdb-scripts: Start NFS quota service if defined BUG: https://bugzilla.samba.org/show_bug.cgi?id=13860 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@samba.org> commit 42103b568698d8087d27f0848b402ccb7cfac86b Author: Martin Schwenke <mar...@meltin.net> Date: Wed Mar 20 17:35:44 2019 +1100 ctdb-scripts: Stop/start mount/rquotad/status via NFS call-out When an NFS check restarts a failed service by hand then systemd will be unable to stop or start this service again because (at least) the PID file will be wrong. Do this via the NFS Linux kernel call-out instead. Allow the call-out to use the services instead of doing manual restarts. Add variables for mount, status and rquotad services to support this. Adding systemd NFS services to the call-out will follow. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13860 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@samba.org> commit 8de0a339b550e7363d265af04ad69f2179af75c6 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Mar 20 16:11:32 2019 +1100 ctdb-scripts: Factor out nfs_load_config() BUG: https://bugzilla.samba.org/show_bug.cgi?id=13860 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@samba.org> commit e72c3c800a50fe746164e319e21180c44d041619 Author: Martin Schwenke <mar...@meltin.net> Date: Tue Mar 26 14:49:49 2019 +1100 ctdb-scripts: Add test variable CTDB_NFS_DISTRO_STYLE BUG: https://bugzilla.samba.org/show_bug.cgi?id=13860 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@samba.org> commit 9981353ab79dce81b698c535977be4a681119d1e Author: Martin Schwenke <mar...@meltin.net> Date: Wed Mar 20 14:50:59 2019 +1100 ctdb-scripts: Rename variable nfslock_service to nfs_lock_service There will be more of these variable for other services so, for readability, it makes sense for them to start with "nfs_". BUG: https://bugzilla.samba.org/show_bug.cgi?id=13860 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@samba.org> commit d7e187c1a7046196ec96637bdc14cc6b042eafcc Author: Martin Schwenke <mar...@meltin.net> Date: Mon Mar 18 14:42:36 2019 +1100 ctdb-scripts: Reindent some functions prior to making changes BUG: https://bugzilla.samba.org/show_bug.cgi?id=13860 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@samba.org> ----------------------------------------------------------------------- Summary of changes: ctdb/config/functions | 19 ++- ctdb/config/nfs-checks.d/10.status.check | 4 +- ctdb/config/nfs-checks.d/40.mountd.check | 4 +- ctdb/config/nfs-checks.d/50.rquotad.check | 4 +- ctdb/config/nfs-linux-kernel-callout | 265 +++++++++++++++++++++++------- ctdb/config/statd-callout | 3 +- ctdb/tests/eventscripts/scripts/60.nfs.sh | 99 ++++++++++- 7 files changed, 315 insertions(+), 83 deletions(-) Changeset truncated at 500 lines: diff --git a/ctdb/config/functions b/ctdb/config/functions index 7a47c9d8e79..1dc16532890 100755 --- a/ctdb/config/functions +++ b/ctdb/config/functions @@ -33,15 +33,16 @@ fi load_system_config () { - if [ -z "$1" ] ; then - return - fi - - if [ -f "${CTDB_SYS_ETCDIR}/sysconfig/$1" ]; then - . "${CTDB_SYS_ETCDIR}/sysconfig/$1" - elif [ -f "${CTDB_SYS_ETCDIR}/default/$1" ]; then - . "${CTDB_SYS_ETCDIR}/default/$1" - fi + for _i ; do + + if [ -f "${CTDB_SYS_ETCDIR}/sysconfig/${_i}" ]; then + . "${CTDB_SYS_ETCDIR}/sysconfig/${_i}" + return + elif [ -f "${CTDB_SYS_ETCDIR}/default/${_i}" ]; then + . "${CTDB_SYS_ETCDIR}/default/${_i}" + return + fi + done } # load_script_options [ component script ] diff --git a/ctdb/config/nfs-checks.d/10.status.check b/ctdb/config/nfs-checks.d/10.status.check index dfa5c59117e..b8ce1e0ad0b 100644 --- a/ctdb/config/nfs-checks.d/10.status.check +++ b/ctdb/config/nfs-checks.d/10.status.check @@ -2,6 +2,6 @@ version="1" restart_every=2 unhealthy_after=6 -service_stop_cmd="killall -q -9 rpc.statd" -service_start_cmd="rpc.statd ${STATD_HA_CALLOUT:+-H} $STATD_HA_CALLOUT ${STATD_HOSTNAME:+-n} $STATD_HOSTNAME ${STATD_PORT:+-p} $STATD_PORT ${STATD_OUTGOING_PORT:+-o} $STATD_OUTGOING_PORT" +service_stop_cmd="$CTDB_NFS_CALLOUT stop status" +service_start_cmd="$CTDB_NFS_CALLOUT start status" service_debug_cmd="program_stack_traces rpc.statd 5" diff --git a/ctdb/config/nfs-checks.d/40.mountd.check b/ctdb/config/nfs-checks.d/40.mountd.check index 56b3fd29512..bfe4c277ce9 100644 --- a/ctdb/config/nfs-checks.d/40.mountd.check +++ b/ctdb/config/nfs-checks.d/40.mountd.check @@ -2,6 +2,6 @@ version="1" restart_every=2 unhealthy_after=6 -service_stop_cmd="killall -q -9 rpc.mountd" -service_start_cmd="rpc.mountd $RPCMOUNTDOPTS ${MOUNTD_PORT:+-p} $MOUNTD_PORT" +service_stop_cmd="$CTDB_NFS_CALLOUT stop mountd" +service_start_cmd="$CTDB_NFS_CALLOUT start mountd" service_debug_cmd="program_stack_traces rpc.mountd 5" diff --git a/ctdb/config/nfs-checks.d/50.rquotad.check b/ctdb/config/nfs-checks.d/50.rquotad.check index b7bd9d2c757..98bd8d98fce 100644 --- a/ctdb/config/nfs-checks.d/50.rquotad.check +++ b/ctdb/config/nfs-checks.d/50.rquotad.check @@ -2,6 +2,6 @@ version="1" restart_every=2 unhealthy_after=6 -service_stop_cmd="killall -q -9 rpc.rquotad" -service_start_cmd="rpc.rquotad ${RQUOTAD_PORT:+-p} $RQUOTAD_PORT" +service_stop_cmd="$CTDB_NFS_CALLOUT stop rquotad" +service_start_cmd="$CTDB_NFS_CALLOUT start rquotad" service_debug_cmd="program_stack_traces rpc.rquotad 5" diff --git a/ctdb/config/nfs-linux-kernel-callout b/ctdb/config/nfs-linux-kernel-callout index 9b72446b44e..868f3279cf2 100755 --- a/ctdb/config/nfs-linux-kernel-callout +++ b/ctdb/config/nfs-linux-kernel-callout @@ -12,20 +12,66 @@ set -e # hook for testing. nfs_exports_file="${CTDB_NFS_EXPORTS_FILE:-/var/lib/nfs/etab}" -# Red Hat -nfs_service="nfs" -nfslock_service="nfslock" -nfs_config="/etc/sysconfig/nfs" +# As above, edit the default value below. CTDB_NFS_DISTRO_STYLE is a +# test variable only. +nfs_distro_style="${CTDB_NFS_DISTRO_STYLE:-systemd-redhat}" + +case "$nfs_distro_style" in +systemd-*) + # Defaults + nfs_service="nfs-server" + nfs_lock_service="rpc-statd" + nfs_mountd_service="nfs-mountd" + nfs_status_service="rpc-statd" + nfs_rquotad_service="rpc-rquotad" + nfs_config="/etc/sysconfig/nfs" + nfs_rquotad_config="" # Not use with systemd, restart via service + + case "$nfs_distro_style" in + *-redhat|*-suse) + : # Defaults only + ;; + *-debian) + nfs_rquotad_service="quotarpc" + ;; + *) + echo "Internal error" + exit 1 + esac + ;; -# SUSE -#nfs_service="nfsserver" -#nfslock_service="" -#nfs_config="/etc/sysconfig/nfs" +sysvinit-*) + # Defaults + nfs_service="nfs" + nfs_lock_service="" + nfs_mountd_service="" + nfs_status_service="" + nfs_rquotad_service="" + nfs_config="/etc/sysconfig/nfs" + nfs_rquotad_config="$nfs_config" + + case "$nfs_distro_style" in + *-redhat) + nfs_lock_service="nfslock" + ;; + *-suse) + nfs_service="nfsserver" + ;; + *-debian) + nfs_service="nfs-kernel-server" + nfs_config="/etc/default/nfs-kernel-server" + nfs_rquotad_config="/etc/default/quota" + ;; + *) + echo "Internal error" + exit 1 + esac + ;; -# Debian -#nfs_service="nfs-kernel-server" -#nfslock_service="" -#nfs_config="/etc/default/nfs-kernel-server" +*) + echo "Internal error" + exit 1 +esac # Override for unit testing if [ -z "$PROCFS_PATH" ] ; then @@ -46,50 +92,70 @@ EOF exit 1 } +################################################## + +nfs_load_config () +{ + _config="${1:-${nfs_config}}" + + if [ -r "$_config" ] ; then + . "$_config" + fi +} ################################################## # Basic service stop and start basic_stop () { - case "$1" in + case "$1" in nfs) - service "$nfs_service" stop - if [ -n "$nfslock_service" ] ; then - service "$nfslock_service" stop - fi - ;; - nfslock) - if [ -n "$nfslock_service" ] ; then - service "$nfslock_service" stop - else + if [ -n "$nfs_rquotad_service" ] ; then + service "$nfs_rquotad_service" stop + fi + service "$nfs_service" stop - fi - ;; + + if [ -n "$nfs_lock_service" ] ; then + service "$nfs_lock_service" stop + fi + ;; + nfslock) + if [ -n "$nfs_lock_service" ] ; then + service "$nfs_lock_service" stop + else + service "$nfs_service" stop + fi + ;; *) - usage - esac + usage + esac } basic_start () { - case "$1" in + case "$1" in nfs) - if [ -n "$nfslock_service" ] ; then - service "$nfslock_service" start - fi - service "$nfs_service" start - ;; - nfslock) - if [ -n "$nfslock_service" ] ; then - service "$nfslock_service" start - else + if [ -n "$nfs_lock_service" ] ; then + service "$nfs_lock_service" start + fi + service "$nfs_service" start - fi - ;; + + if [ -n "$nfs_rquotad_service" ] ; then + service "$nfs_rquotad_service" start + fi + ;; + nfslock) + if [ -n "$nfs_lock_service" ] ; then + service "$nfs_lock_service" start + else + service "$nfs_service" start + fi + ;; *) - usage - esac + usage + esac } ################################################## @@ -97,32 +163,109 @@ basic_start () service_stop () { - case "$1" in + case "$1" in nfs) - echo 0 >"${PROCFS_PATH}/fs/nfsd/threads" - basic_stop "nfs" >/dev/null 2>&1 || true - pkill -9 nfsd - ;; + echo 0 >"${PROCFS_PATH}/fs/nfsd/threads" + basic_stop "nfs" >/dev/null 2>&1 || true + pkill -9 nfsd + ;; nlockmgr) - basic_stop "nfslock" >/dev/null 2>&1 || true - ;; + basic_stop "nfslock" >/dev/null 2>&1 || true + ;; + mountd) + if [ -n "$nfs_mountd_service" ] ; then + service "$nfs_mountd_service" stop + return + fi + + # Default to stopping by hand + killall -q -9 rpc.mountd + ;; + rquotad) + if [ -n "$nfs_rquotad_service" ] ; then + service "$nfs_rquotad_service" stop + return + fi + + # Default to stopping by hand + killall -q -9 rpc.rquotad + ;; + status) + if [ -n "$nfs_status_service" ] ; then + service "$nfs_status_service" stop + return + fi + + # Default to stopping by hand + killall -q -9 rpc.statd + ;; *) - usage - esac + usage + esac } service_start () { - case "$1" in + case "$1" in nfs) - basic_start "nfs" - ;; + basic_start "nfs" + ;; nlockmgr) - basic_start "nfslock" - ;; + basic_start "nfslock" + ;; + mountd) + if [ -n "$nfs_mountd_service" ] ; then + service "$nfs_mountd_service" start + return + fi + + # Default to starting by hand + nfs_load_config + if [ -z "$RPCMOUNTDOPTS" ] ; then + RPCMOUNTDOPTS="${MOUNTD_PORT:+-p }$MOUNTD_PORT" + fi + # shellcheck disable=SC2086 + rpc.mountd $RPCMOUNTDOPTS + ;; + rquotad) + if [ -n "$nfs_rquotad_service" ] ; then + service "$nfs_rquotad_service" start + return + fi + + # Default to starting by hand + nfs_load_config "$nfs_rquotad_config" + if [ -z "$RPCRQUOTADOPTS" ] ; then + RPCRQUOTADOPTS="${RQUOTAD_PORT:+-p }$RQUOTAD_PORT" + fi + # shellcheck disable=SC2086 + rpc.rquotad $RPCRQUOTADOPTS + ;; + status) + if [ -n "$nfs_status_service" ] ; then + service "$nfs_status_service" start + return + fi + + # Default to starting by hand + nfs_load_config + # Red Hat uses STATDARG, Debian uses STATDOPTS + opts="${STATDARG:-${STATDOPTS:-''}}" + if [ -z "$opts" ] ; then + # shellcheck disable=SC2086 + set -- \ + ${STATD_HA_CALLOUT:+-H} $STATD_HA_CALLOUT \ + ${STATD_HOSTNAME:+-n} $STATD_HOSTNAME \ + ${STATD_PORT:+-p} $STATD_PORT \ + ${STATD_OUTGOING_PORT:+-o} $STATD_OUTGOING_PORT + opts="$*" + fi + # shellcheck disable=SC2086 + rpc.statd $opts + ;; *) - usage - esac + usage + esac } ################################################## @@ -149,9 +292,7 @@ nfs_startup () nfs_check_thread_count () { # Load NFS configuration to get desired number of threads. - if [ -r "$nfs_config" ] ; then - . "$nfs_config" - fi + nfs_load_config # If $RPCNFSDCOUNT/$USE_KERNEL_NFSD_NUMBER isn't set then we could # guess the default from the initscript. However, let's just @@ -172,8 +313,10 @@ nfs_check_thread_count () # Intentionally not arithmetic comparison - avoids extra errors # when above read fails in an unexpected way... - if [ "$_running_threads" != "$_configured_threads" ] ; then - echo "Attempting to correct number of nfsd threads from ${_running_threads} to ${_configured_threads}" + if [ "$_running_threads" != "0" ] && \ + [ "$_running_threads" != "$_configured_threads" ] ; then + printf 'Attempting to correct number of nfsd threads from %s to %s\n' \ + "$_running_threads" "$_configured_threads" echo "$_configured_threads" >"$_threads_file" fi } diff --git a/ctdb/config/statd-callout b/ctdb/config/statd-callout index bf18b5586b3..b75135bbde5 100755 --- a/ctdb/config/statd-callout +++ b/ctdb/config/statd-callout @@ -20,7 +20,8 @@ die () exit 1 } -load_system_config "nfs" +# Try different variables to find config file for NFS_HOSTNAME +load_system_config "nfs" "nfs-common" [ -n "$NFS_HOSTNAME" ] || \ die "NFS_HOSTNAME is not configured. statd-callout failed" diff --git a/ctdb/tests/eventscripts/scripts/60.nfs.sh b/ctdb/tests/eventscripts/scripts/60.nfs.sh index 15670e76910..195f7ffd780 100644 --- a/ctdb/tests/eventscripts/scripts/60.nfs.sh +++ b/ctdb/tests/eventscripts/scripts/60.nfs.sh @@ -5,6 +5,11 @@ setup () service_name="nfs" + if [ -z "$CTDB_NFS_DISTRO_STYLE" ] ; then + # Currently supported: sysvinit-redhat, systemd-redhat + CTDB_NFS_DISTRO_STYLE="systemd-redhat" + fi + export FAKE_RPCINFO_SERVICES="" setup_script_options <<EOF @@ -20,8 +25,18 @@ EOF Setting up NFS environment: all RPC services up, NFS managed by CTDB EOF - service "nfs" force-started - service "nfslock" force-started + case "$CTDB_NFS_DISTRO_STYLE" in + sysvinit-*) + service "nfs" force-started + service "nfslock" force-started + ;; + systemd-*) + service "nfs-service" force-started + service "nfs-mountd" force-started + service "rpc-rquotad" force-started + service "rpc-statd" force-started + ;; + esac rpc_services_up \ "portmapper" "nfs" "mountd" "rquotad" \ @@ -34,8 +49,18 @@ EOF Setting up NFS environment: all RPC services down, NFS not managed by CTDB EOF - service "nfs" force-stopped - service "nfslock" force-stopped + case "$CTDB_NFS_DISTRO_STYLE" in + sysvinit-*) + service "nfs" force-stopped + service "nfslock" force-stopped + ;; + systemd-*) + service "nfs-server" force-stopped + service "nfs-mountd" force-stopped + service "rpc-quotad" force-stopped + service "rpc-statd" force-stopped + ;; + esac fi # This is really nasty. However, when we test NFS we don't @@ -103,13 +128,73 @@ guess_output () { case "$1" in $CTDB_NFS_CALLOUT\ start\ nlockmgr) - echo "&Starting nfslock: OK" + case "$CTDB_NFS_DISTRO_STYLE" in + sysvinit-redhat) + echo "&Starting nfslock: OK" + ;; + systemd-redhat) + echo "&Starting rpc-statd: OK" + ;; + esac ;; $CTDB_NFS_CALLOUT\ start\ nfs) - cat <<EOF + case "$CTDB_NFS_DISTRO_STYLE" in + sysvinit-redhat) + cat <<EOF &Starting nfslock: OK &Starting nfs: OK EOF + ;; + systemd-redhat) + cat <<EOF +&Starting rpc-statd: OK +&Starting nfs-server: OK -- Samba Shared Repository