Blob Blame History Raw
From dc4fc6fb51481e62c763212129e7dbae4cb663fd Mon Sep 17 00:00:00 2001
From: Reid Wahl <nrwahl@protonmail.com>
Date: Tue, 2 Feb 2021 17:55:40 -0800
Subject: [PATCH] nfsserver: Error-check unbind_tree

Fail to stop if unmounting rpcpipefs_dir or /var/lib/nfs fails.

Resolves: RHBZ#1924363

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
---
 heartbeat/nfsserver | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/heartbeat/nfsserver b/heartbeat/nfsserver
index 80d20676b..96b19abe3 100755
--- a/heartbeat/nfsserver
+++ b/heartbeat/nfsserver
@@ -465,9 +465,20 @@ unbind_tree ()
 		sleep 1
 		i=$((i + 1))
 	done
+
+	if mount | grep -q " on $OCF_RESKEY_rpcpipefs_dir "; then
+		ocf_log err "Failed to unmount $OCF_RESKEY_rpcpipefs_dir"
+		return $OCF_ERR_GENERIC
+	fi
+
 	if is_bound /var/lib/nfs; then
-		umount /var/lib/nfs
+		if ! umount /var/lib/nfs; then
+			ocf_log err "Failed to unmount /var/lib/nfs"
+			return $OCF_ERR_GENERIC
+		fi
 	fi
+
+	return $OCF_SUCCESS
 }
 
 binary_status()
@@ -836,8 +847,14 @@ nfsserver_stop ()
 	esac
 
 	unbind_tree
-	ocf_log info "NFS server stopped"
-	return 0
+	rc=$?
+	if [ "$rc" -ne $OCF_SUCCESS ]; then
+		ocf_exit_reason "Failed to unmount a bind mount"
+	else
+		ocf_log info "NFS server stopped"
+	fi
+
+	return $rc
 }
 
 nfsserver_validate ()