Blame SOURCES/bz2127117-nfsserver-nfsv4_only-parameter.patch

17ae29
From 764757380af19d3a21d40f3c9624e4135ff074e1 Mon Sep 17 00:00:00 2001
17ae29
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
17ae29
Date: Wed, 2 Nov 2022 10:26:31 +0100
17ae29
Subject: [PATCH] nfsserver: add nfsv4_only parameter to make it run without
17ae29
 rpc-statd/rpcbind services
17ae29
17ae29
---
17ae29
 heartbeat/nfsserver | 200 +++++++++++++++++++++++++-------------------
17ae29
 1 file changed, 114 insertions(+), 86 deletions(-)
17ae29
17ae29
diff --git a/heartbeat/nfsserver b/heartbeat/nfsserver
17ae29
index 9bbd603e5..cb2d43ab1 100755
17ae29
--- a/heartbeat/nfsserver
17ae29
+++ b/heartbeat/nfsserver
17ae29
@@ -79,6 +79,16 @@ Init script for nfsserver
17ae29
 <content type="string" default="auto detected" />
17ae29
 </parameter>
17ae29
 
17ae29
+<parameter name="nfsv4_only" unique="0" required="0">
17ae29
+<longdesc lang="en">
17ae29
+Run in NFSv4 only mode (rpc-statd and rpcbind services masked).
17ae29
+</longdesc>
17ae29
+<shortdesc lang="en">
17ae29
+NFSv4 only mode.
17ae29
+</shortdesc>
17ae29
+<content type="boolean" default="false" />
17ae29
+</parameter>
17ae29
+
17ae29
 <parameter name="nfs_no_notify" unique="0" required="0">
17ae29
 <longdesc lang="en">
17ae29
 Do not send reboot notifications to NFSv3 clients during server startup.
17ae29
@@ -332,7 +342,7 @@ v3locking_exec()
17ae29
 	if [ $EXEC_MODE -eq 2 ]; then
17ae29
 		nfs_exec $cmd nfs-lock.service
17ae29
 	elif [ $EXEC_MODE -eq 3 ]; then
17ae29
-		nfs_exec $cmd rpc-statd.service
17ae29
+		 nfs_exec $cmd rpc-statd.service
17ae29
 	else 
17ae29
 		case $cmd in
17ae29
 			start) locking_start;;
17ae29
@@ -348,20 +358,22 @@ nfsserver_systemd_monitor()
17ae29
 	local rc
17ae29
 	local fn
17ae29
 
17ae29
-	ocf_log debug "Status: rpcbind"
17ae29
-	rpcinfo > /dev/null 2>&1
17ae29
-	rc=$?
17ae29
-	if [ "$rc" -ne "0" ]; then
17ae29
-		ocf_exit_reason "rpcbind is not running"
17ae29
-		return $OCF_NOT_RUNNING
17ae29
-	fi
17ae29
+	if ! ocf_is_true "$OCF_RESKEY_nfsv4_only"; then
17ae29
+		ocf_log debug "Status: rpcbind"
17ae29
+		rpcinfo > /dev/null 2>&1
17ae29
+		rc=$?
17ae29
+		if [ "$rc" -ne "0" ]; then
17ae29
+			ocf_exit_reason "rpcbind is not running"
17ae29
+			return $OCF_NOT_RUNNING
17ae29
+		fi
17ae29
 
17ae29
-	ocf_log debug "Status: nfs-mountd"
17ae29
-	ps axww | grep -q "[r]pc.mountd"
17ae29
-	rc=$?
17ae29
-	if [ "$rc" -ne "0" ]; then
17ae29
-		ocf_exit_reason "nfs-mountd is not running"
17ae29
-		return $OCF_NOT_RUNNING
17ae29
+		ocf_log debug "Status: nfs-mountd"
17ae29
+		ps axww | grep -q "[r]pc.mountd"
17ae29
+		rc=$?
17ae29
+		if [ "$rc" -ne "0" ]; then
17ae29
+			ocf_exit_reason "nfs-mountd is not running"
17ae29
+			return $OCF_NOT_RUNNING
17ae29
+		fi
17ae29
 	fi
17ae29
 
17ae29
 	ocf_log debug "Status: nfs-idmapd"
17ae29
@@ -375,12 +387,14 @@ nfsserver_systemd_monitor()
17ae29
 		return $OCF_NOT_RUNNING
17ae29
 	fi
17ae29
 
17ae29
-	ocf_log debug "Status: rpc-statd"
17ae29
-	rpcinfo -t localhost 100024 > /dev/null 2>&1
17ae29
-	rc=$?
17ae29
-	if [ "$rc" -ne "0" ]; then
17ae29
-		ocf_exit_reason "rpc-statd is not running"
17ae29
-		return $OCF_NOT_RUNNING
17ae29
+	if ! ocf_is_true "$OCF_RESKEY_nfsv4_only"; then
17ae29
+		ocf_log debug "Status: rpc-statd"
17ae29
+		rpcinfo -t localhost 100024 > /dev/null 2>&1
17ae29
+		rc=$?
17ae29
+		if [ "$rc" -ne "0" ]; then
17ae29
+			ocf_exit_reason "rpc-statd is not running"
17ae29
+			return $OCF_NOT_RUNNING
17ae29
+		fi
17ae29
 	fi
17ae29
 
17ae29
 	nfs_exec is-active nfs-server
17ae29
@@ -424,7 +438,7 @@ nfsserver_monitor ()
17ae29
 	if [ $rc -eq 0 ]; then
17ae29
 		# don't report success if nfs servers are up
17ae29
 		# without locking daemons.
17ae29
-		v3locking_exec "status"
17ae29
+		ocf_is_true "$OCF_RESKEY_nfsv4_only" || v3locking_exec "status"
17ae29
 		rc=$?
17ae29
 		if [ $rc -ne 0 ]; then
17ae29
 			ocf_exit_reason "NFS server is up, but the locking daemons are down"
17ae29
@@ -786,48 +800,54 @@ nfsserver_start ()
17ae29
 
17ae29
 	# systemd
17ae29
 	case $EXEC_MODE in
17ae29
-            [23]) nfs_exec start rpcbind
17ae29
-		  local i=1
17ae29
-		  while : ; do
17ae29
-			ocf_log info "Start: rpcbind i: $i"
17ae29
-			rpcinfo > /dev/null 2>&1
17ae29
-			rc=$?
17ae29
-			if [ "$rc" -eq "0" ]; then
17ae29
-				break;
17ae29
-			fi
17ae29
-			sleep 1
17ae29
-			i=$((i + 1))
17ae29
-		  done
17ae29
+            [23]) if ! ocf_is_true "$OCF_RESKEY_nfsv4_only"; then
17ae29
+			nfs_exec start rpcbind
17ae29
+			local i=1
17ae29
+			while : ; do
17ae29
+				ocf_log info "Start: rpcbind i: $i"
17ae29
+				rpcinfo > /dev/null 2>&1
17ae29
+				rc=$?
17ae29
+				if [ "$rc" -eq "0" ]; then
17ae29
+					break
17ae29
+				fi
17ae29
+				sleep 1
17ae29
+				i=$((i + 1))
17ae29
+			done
17ae29
+		  fi
17ae29
 		  ;;
17ae29
 	esac
17ae29
 
17ae29
-	# check to see if we need to start rpc.statd
17ae29
-	v3locking_exec "status"
17ae29
-	if [ $? -ne $OCF_SUCCESS ]; then
17ae29
-		v3locking_exec "start"
17ae29
-		rc=$?
17ae29
-		if [ $rc -ne 0 ]; then
17ae29
-			ocf_exit_reason "Failed to start NFS server locking daemons"
17ae29
-			return $rc
17ae29
+	if ! ocf_is_true "$OCF_RESKEY_nfsv4_only"; then
17ae29
+		# check to see if we need to start rpc.statd
17ae29
+		v3locking_exec "status"
17ae29
+		if [ $? -ne $OCF_SUCCESS ]; then
17ae29
+			v3locking_exec "start"
17ae29
+			rc=$?
17ae29
+			if [ $rc -ne 0 ]; then
17ae29
+				ocf_exit_reason "Failed to start NFS server locking daemons"
17ae29
+				return $rc
17ae29
+			fi
17ae29
+		else
17ae29
+			ocf_log info "rpc.statd already up"
17ae29
 		fi
17ae29
-	else
17ae29
-		ocf_log info "rpc.statd already up"
17ae29
 	fi
17ae29
 
17ae29
 	# systemd
17ae29
 	case $EXEC_MODE in
17ae29
-            [23]) nfs_exec start nfs-mountd
17ae29
-		  local i=1
17ae29
-		  while : ; do
17ae29
-			ocf_log info "Start: nfs-mountd i: $i"
17ae29
-			ps axww | grep -q "[r]pc.mountd"
17ae29
-			rc=$?
17ae29
-			if [ "$rc" -eq "0" ]; then
17ae29
-				break;
17ae29
-			fi
17ae29
-			sleep 1
17ae29
-			i=$((i + 1))
17ae29
-		  done
17ae29
+            [23]) if ! ocf_is_true "$OCF_RESKEY_nfsv4_only"; then
17ae29
+			nfs_exec start nfs-mountd
17ae29
+			local i=1
17ae29
+			while : ; do
17ae29
+				ocf_log info "Start: nfs-mountd i: $i"
17ae29
+				ps axww | grep -q "[r]pc.mountd"
17ae29
+				rc=$?
17ae29
+				if [ "$rc" -eq "0" ]; then
17ae29
+					break
17ae29
+				fi
17ae29
+				sleep 1
17ae29
+				i=$((i + 1))
17ae29
+			done
17ae29
+		  fi
17ae29
 
17ae29
 		  nfs_exec start nfs-idmapd
17ae29
 		  local i=1
17ae29
@@ -839,24 +859,26 @@ nfsserver_start ()
17ae29
 			ocf_log debug "$(cat $fn)"
17ae29
 			rm -f $fn
17ae29
 			if [ "$rc" -eq "0" ]; then
17ae29
-				break;
17ae29
+				break
17ae29
 			fi
17ae29
 			sleep 1
17ae29
 			i=$((i + 1))
17ae29
 		  done
17ae29
 
17ae29
-		  nfs_exec start rpc-statd
17ae29
-		  local i=1
17ae29
-		  while : ; do
17ae29
-			ocf_log info "Start: rpc-statd i: $i"
17ae29
-			rpcinfo -t localhost 100024 > /dev/null 2>&1
17ae29
-			rc=$?
17ae29
-			if [ "$rc" -eq "0" ]; then
17ae29
-				break;
17ae29
-			fi
17ae29
-			sleep 1
17ae29
-			i=$((i + 1))
17ae29
-		  done
17ae29
+		  if ! ocf_is_true "$OCF_RESKEY_nfsv4_only"; then
17ae29
+			nfs_exec start rpc-statd
17ae29
+			local i=1
17ae29
+			while : ; do
17ae29
+				ocf_log info "Start: rpc-statd i: $i"
17ae29
+				rpcinfo -t localhost 100024 > /dev/null 2>&1
17ae29
+				rc=$?
17ae29
+				if [ "$rc" -eq "0" ]; then
17ae29
+					break
17ae29
+				fi
17ae29
+				sleep 1
17ae29
+				i=$((i + 1))
17ae29
+			done
17ae29
+		  fi
17ae29
 	esac
17ae29
 
17ae29
 
17ae29
@@ -914,13 +936,15 @@ nfsserver_stop ()
17ae29
 			sleep 1
17ae29
 		  done
17ae29
 
17ae29
-		  nfs_exec stop rpc-statd > /dev/null 2>&1
17ae29
-		  ocf_log info "Stop: rpc-statd"
17ae29
-		  rpcinfo -t localhost 100024 > /dev/null 2>&1
17ae29
-		  rc=$?
17ae29
-		  if [ "$rc" -eq "0" ]; then
17ae29
-			ocf_exit_reason "Failed to stop rpc-statd"
17ae29
-			return $OCF_ERR_GENERIC
17ae29
+		  if ! ocf_is_true "$OCF_RESKEY_nfsv4_only"; then
17ae29
+			nfs_exec stop rpc-statd > /dev/null 2>&1
17ae29
+			ocf_log info "Stop: rpc-statd"
17ae29
+			rpcinfo -t localhost 100024 > /dev/null 2>&1
17ae29
+			rc=$?
17ae29
+			if [ "$rc" -eq "0" ]; then
17ae29
+				ocf_exit_reason "Failed to stop rpc-statd"
17ae29
+				return $OCF_ERR_GENERIC
17ae29
+			fi
17ae29
 		  fi
17ae29
 
17ae29
 		  nfs_exec stop nfs-idmapd > /dev/null 2>&1
17ae29
@@ -935,13 +959,15 @@ nfsserver_stop ()
17ae29
 			return $OCF_ERR_GENERIC
17ae29
 		  fi
17ae29
 
17ae29
-		  nfs_exec stop nfs-mountd > /dev/null 2>&1
17ae29
-		  ocf_log info "Stop: nfs-mountd"
17ae29
-		  ps axww | grep -q "[r]pc.mountd"
17ae29
-		  rc=$?
17ae29
-		  if [ "$rc" -eq "0" ]; then
17ae29
-			ocf_exit_reason "Failed to stop nfs-mountd"
17ae29
-			return $OCF_ERR_GENERIC
17ae29
+		  if ! ocf_is_true "$OCF_RESKEY_nfsv4_only"; then
17ae29
+			nfs_exec stop nfs-mountd > /dev/null 2>&1
17ae29
+			ocf_log info "Stop: nfs-mountd"
17ae29
+			ps axww | grep -q "[r]pc.mountd"
17ae29
+			rc=$?
17ae29
+			if [ "$rc" -eq "0" ]; then
17ae29
+				ocf_exit_reason "Failed to stop nfs-mountd"
17ae29
+				return $OCF_ERR_GENERIC
17ae29
+			fi
17ae29
 		  fi
17ae29
 
17ae29
 		  if systemctl --no-legend list-unit-files "nfsdcld*" | grep -q nfsdcld; then
17ae29
@@ -960,10 +986,12 @@ nfsserver_stop ()
17ae29
 	esac
17ae29
 
17ae29
 
17ae29
-	v3locking_exec "stop"
17ae29
-	if [ $? -ne 0 ]; then
17ae29
-		ocf_exit_reason "Failed to stop NFS locking daemons"
17ae29
-		rc=$OCF_ERR_GENERIC
17ae29
+	if ! ocf_is_true "$OCF_RESKEY_nfsv4_only"; then
17ae29
+		v3locking_exec "stop"
17ae29
+		if [ $? -ne 0 ]; then
17ae29
+			ocf_exit_reason "Failed to stop NFS locking daemons"
17ae29
+			rc=$OCF_ERR_GENERIC
17ae29
+		fi
17ae29
 	fi
17ae29
 
17ae29
 	# systemd