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

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