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

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