Blame SOURCES/bz2157872-4-exportfs-pgsql-validate-all-fixes.patch

f18d3d
From 81f9e1a04dfd2274ccb906310b4f191485e342ab Mon Sep 17 00:00:00 2001
f18d3d
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
f18d3d
Date: Wed, 11 Jan 2023 13:22:24 +0100
f18d3d
Subject: [PATCH 1/2] exportfs: move testdir() to start-action to avoid failing
f18d3d
 during resource creation (validate-all) and make it create the directory if
f18d3d
 it doesnt exist
f18d3d
f18d3d
---
f18d3d
 heartbeat/exportfs | 27 +++++++++++++++------------
f18d3d
 1 file changed, 15 insertions(+), 12 deletions(-)
f18d3d
f18d3d
diff --git a/heartbeat/exportfs b/heartbeat/exportfs
f18d3d
index c10777fa9..2307a9e67 100755
f18d3d
--- a/heartbeat/exportfs
f18d3d
+++ b/heartbeat/exportfs
f18d3d
@@ -301,6 +301,16 @@ exportfs_monitor ()
f18d3d
 	fi
f18d3d
 }
f18d3d
 
f18d3d
+testdir() {
f18d3d
+	if [ ! -d $1 ]; then
f18d3d
+		mkdir -p "$1"
f18d3d
+		if [ $? -ne 0 ]; then
f18d3d
+			ocf_exit_reason "Unable to create directory $1"
f18d3d
+			return 1
f18d3d
+		fi
f18d3d
+	fi
f18d3d
+	return 0
f18d3d
+}
f18d3d
 export_one() {
f18d3d
 	local dir=$1
f18d3d
 	local opts sep
f18d3d
@@ -331,6 +341,10 @@ export_one() {
f18d3d
 }
f18d3d
 exportfs_start ()
f18d3d
 {
f18d3d
+	if ! forall testdir; then
f18d3d
+		return $OCF_ERR_INSTALLED
f18d3d
+	fi
f18d3d
+
f18d3d
 	if exportfs_monitor; then
f18d3d
 		ocf_log debug "already exported"
f18d3d
 		return $OCF_SUCCESS
f18d3d
@@ -428,14 +442,6 @@ exportfs_stop ()
f18d3d
 	fi
f18d3d
 }
f18d3d
 
f18d3d
-testdir() {
f18d3d
-	if [ ! -d $1 ]; then
f18d3d
-		ocf_is_probe ||
f18d3d
-			ocf_log err "$1 does not exist or is not a directory"
f18d3d
-		return 1
f18d3d
-	fi
f18d3d
-	return 0
f18d3d
-}
f18d3d
 exportfs_validate_all ()
f18d3d
 {
f18d3d
 	if echo "$OCF_RESKEY_fsid" | grep -q -F ','; then
f18d3d
@@ -447,9 +453,6 @@ exportfs_validate_all ()
f18d3d
 		ocf_exit_reason "use integer fsid when exporting multiple directories"
f18d3d
 		return $OCF_ERR_CONFIGURED
f18d3d
 	fi
f18d3d
-	if ! forall testdir; then
f18d3d
-		return $OCF_ERR_INSTALLED
f18d3d
-	fi
f18d3d
 }
f18d3d
 
f18d3d
 for dir in $OCF_RESKEY_directory; do
f18d3d
@@ -466,7 +469,7 @@ for dir in $OCF_RESKEY_directory; do
f18d3d
 		fi
f18d3d
 	else
f18d3d
 		case "$__OCF_ACTION" in
f18d3d
-			stop|monitor)
f18d3d
+			stop|monitor|validate-all)
f18d3d
 				canonicalized_dir="$dir"
f18d3d
 				ocf_log debug "$dir does not exist"
f18d3d
 				;;
f18d3d
f18d3d
From 8ee41af82cda35149f8e0cfede6a8ddef3e221e1 Mon Sep 17 00:00:00 2001
f18d3d
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
f18d3d
Date: Wed, 11 Jan 2023 13:25:57 +0100
f18d3d
Subject: [PATCH 2/2] pgsql: dont run promotable and file checks that could be
f18d3d
 on shared storage during validate-all action
f18d3d
f18d3d
---
f18d3d
 heartbeat/pgsql | 53 +++++++++++++++++++++++++++++--------------------
f18d3d
 1 file changed, 32 insertions(+), 21 deletions(-)
f18d3d
f18d3d
diff --git a/heartbeat/pgsql b/heartbeat/pgsql
f18d3d
index aa8a13a84..532063ac5 100755
f18d3d
--- a/heartbeat/pgsql
f18d3d
+++ b/heartbeat/pgsql
f18d3d
@@ -1835,7 +1835,7 @@ check_config() {
f18d3d
 
f18d3d
     if [ ! -f "$1" ]; then
f18d3d
         if ocf_is_probe; then
f18d3d
-           ocf_log info "Configuration file is $1 not readable during probe."
f18d3d
+           ocf_log info "Unable to read $1 during probe."
f18d3d
            rc=1
f18d3d
         else
f18d3d
            ocf_exit_reason "Configuration file $1 doesn't exist"
f18d3d
@@ -1846,8 +1846,7 @@ check_config() {
f18d3d
     return $rc
f18d3d
 }
f18d3d
 
f18d3d
-# Validate most critical parameters
f18d3d
-pgsql_validate_all() {
f18d3d
+validate_ocf_check_level_10() {
f18d3d
     local version
f18d3d
     local check_config_rc
f18d3d
     local rep_mode_string
f18d3d
@@ -1883,12 +1882,6 @@ pgsql_validate_all() {
f18d3d
         fi
f18d3d
     fi
f18d3d
 
f18d3d
-    getent passwd $OCF_RESKEY_pgdba >/dev/null 2>&1
f18d3d
-    if [ ! $? -eq 0 ]; then
f18d3d
-        ocf_exit_reason "User $OCF_RESKEY_pgdba doesn't exist";
f18d3d
-        return $OCF_ERR_INSTALLED;
f18d3d
-    fi
f18d3d
-
f18d3d
     if ocf_is_probe; then
f18d3d
         ocf_log info "Don't check $OCF_RESKEY_pgdata during probe"
f18d3d
     else
f18d3d
@@ -1898,18 +1891,6 @@ pgsql_validate_all() {
f18d3d
         fi
f18d3d
     fi
f18d3d
 
f18d3d
-    if [ -n "$OCF_RESKEY_monitor_user" -a ! -n "$OCF_RESKEY_monitor_password" ]
f18d3d
-    then
f18d3d
-        ocf_exit_reason "monitor password can't be empty"
f18d3d
-        return $OCF_ERR_CONFIGURED
f18d3d
-    fi
f18d3d
-
f18d3d
-    if [ ! -n "$OCF_RESKEY_monitor_user" -a -n "$OCF_RESKEY_monitor_password" ]
f18d3d
-    then
f18d3d
-        ocf_exit_reason "monitor_user has to be set if monitor_password is set"
f18d3d
-        return $OCF_ERR_CONFIGURED
f18d3d
-    fi
f18d3d
-
f18d3d
     if is_replication || [ "$OCF_RESKEY_rep_mode" = "slave" ]; then
f18d3d
         if [ `printf "$version\n9.1" | sort -n | head -1` != "9.1" ]; then
f18d3d
             ocf_exit_reason "Replication mode needs PostgreSQL 9.1 or higher."
f18d3d
@@ -2027,6 +2008,35 @@ pgsql_validate_all() {
f18d3d
     return $OCF_SUCCESS
f18d3d
 }
f18d3d
 
f18d3d
+# Validate most critical parameters
f18d3d
+pgsql_validate_all() {
f18d3d
+    local rc
f18d3d
+
f18d3d
+    getent passwd $OCF_RESKEY_pgdba >/dev/null 2>&1
f18d3d
+    if [ ! $? -eq 0 ]; then
f18d3d
+        ocf_exit_reason "User $OCF_RESKEY_pgdba doesn't exist";
f18d3d
+        return $OCF_ERR_INSTALLED;
f18d3d
+    fi
f18d3d
+
f18d3d
+    if [ -n "$OCF_RESKEY_monitor_user" ] && [ -z "$OCF_RESKEY_monitor_password" ]; then
f18d3d
+        ocf_exit_reason "monitor password can't be empty"
f18d3d
+        return $OCF_ERR_CONFIGURED
f18d3d
+    fi
f18d3d
+
f18d3d
+    if [ -z "$OCF_RESKEY_monitor_user" ] && [ -n "$OCF_RESKEY_monitor_password" ]; then
f18d3d
+        ocf_exit_reason "monitor_user has to be set if monitor_password is set"
f18d3d
+        return $OCF_ERR_CONFIGURED
f18d3d
+    fi
f18d3d
+
f18d3d
+    if [ "$OCF_CHECK_LEVEL" -eq 10 ]; then
f18d3d
+        validate_ocf_check_level_10
f18d3d
+	rc=$?
f18d3d
+	[ $rc -ne "$OCF_SUCCESS" ] && exit $rc
f18d3d
+    fi
f18d3d
+
f18d3d
+    return $OCF_SUCCESS
f18d3d
+}
f18d3d
+
f18d3d
 
f18d3d
 #
f18d3d
 # Check if we need to create a log file
f18d3d
@@ -2163,6 +2173,7 @@ case "$1" in
f18d3d
                 exit $OCF_SUCCESS;;
f18d3d
 esac
f18d3d
 
f18d3d
+[ "$__OCF_ACTION" != "validate-all" ] && OCF_CHECK_LEVEL=10
f18d3d
 pgsql_validate_all
f18d3d
 rc=$?
f18d3d