From 42103b568698d8087d27f0848b402ccb7cfac86b Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Wed, 20 Mar 2019 17:35:44 +1100 Subject: [PATCH] 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 Reviewed-by: Amitay Isaacs --- 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 | 82 +++++++++++++++++++++++ 4 files changed, 88 insertions(+), 6 deletions(-) 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 ca7e2b88e96..74f7f0a16b0 100755 --- a/ctdb/config/nfs-linux-kernel-callout +++ b/ctdb/config/nfs-linux-kernel-callout @@ -21,7 +21,11 @@ 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) @@ -33,6 +37,7 @@ sysvinit-*) *-debian) nfs_service="nfs-kernel-server" nfs_config="/etc/default/nfs-kernel-server" + nfs_rquotad_config="/etc/default/quota" ;; *) echo "Internal error" @@ -134,6 +139,33 @@ service_stop () nlockmgr) 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 @@ -148,6 +180,56 @@ service_start () nlockmgr) 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