Blame SOURCES/bz2157872-1-all-ras-validate-all-OCF_CHECK_LEVEL-10.patch

f18d3d
From bf89ad06d5da5c05533c80a37a37c8dbbcd123aa Mon Sep 17 00:00:00 2001
f18d3d
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
f18d3d
Date: Thu, 8 Dec 2022 15:40:07 +0100
f18d3d
Subject: [PATCH] galera/mpathpersist/sg_persist/IPsrcaddr: only check notify
f18d3d
 and promotable when OCF_CHECK_LEVEL=10
f18d3d
f18d3d
Pacemaker has started running validate-all action before creating the
f18d3d
resource. It doesnt provide notify/promotable settings while doing so,
f18d3d
so this patch moves these checks to OCF_CHECK_LEVEL 10 and runs the
f18d3d
validate action at OCF_CHECK_LEVEL 10 in the start-action.
f18d3d
---
f18d3d
 heartbeat/IPsrcaddr       | 13 ++++++++-----
f18d3d
 heartbeat/galera.in       |  9 ++++++---
f18d3d
 heartbeat/mpathpersist.in | 13 +++++++++----
f18d3d
 heartbeat/sg_persist.in   | 13 +++++++++----
f18d3d
 4 files changed, 32 insertions(+), 16 deletions(-)
f18d3d
f18d3d
diff --git a/heartbeat/IPsrcaddr b/heartbeat/IPsrcaddr
f18d3d
index 1bd41a930..66e2ad8cd 100755
f18d3d
--- a/heartbeat/IPsrcaddr
f18d3d
+++ b/heartbeat/IPsrcaddr
f18d3d
@@ -510,11 +510,13 @@ srca_validate_all() {
f18d3d
 	fi
f18d3d
 
f18d3d
 #	We should serve this IP address of course
f18d3d
-	if ip_status "$ipaddress"; then
f18d3d
-	  :
f18d3d
-	else
f18d3d
-	  ocf_exit_reason "We are not serving [$ipaddress], hence can not make it a preferred source address"
f18d3d
-	  return $OCF_ERR_INSTALLED
f18d3d
+	if [ "$OCF_CHECK_LEVEL" -eq 10 ]; then
f18d3d
+		if ip_status "$ipaddress"; then
f18d3d
+			:
f18d3d
+		else
f18d3d
+			ocf_exit_reason "We are not serving [$ipaddress], hence can not make it a preferred source address"
f18d3d
+			return $OCF_ERR_INSTALLED
f18d3d
+		fi
f18d3d
 	fi
f18d3d
 	return $OCF_SUCCESS
f18d3d
 }
f18d3d
@@ -540,6 +542,7 @@ esac
f18d3d
 
f18d3d
 ipaddress="$OCF_RESKEY_ipaddress"
f18d3d
 
f18d3d
+[ "$__OCF_ACTION" != "validate-all" ] && OCF_CHECK_LEVEL=10
f18d3d
 srca_validate_all
f18d3d
 rc=$?
f18d3d
 if [ $rc -ne $OCF_SUCCESS ]; then
f18d3d
diff --git a/heartbeat/galera.in b/heartbeat/galera.in
f18d3d
index cd2fee7c0..6aed3e4b6 100755
f18d3d
--- a/heartbeat/galera.in
f18d3d
+++ b/heartbeat/galera.in
f18d3d
@@ -1015,9 +1015,11 @@ galera_stop()
f18d3d
 
f18d3d
 galera_validate()
f18d3d
 {
f18d3d
-    if ! ocf_is_ms; then
f18d3d
-        ocf_exit_reason "Galera must be configured as a multistate Master/Slave resource."
f18d3d
-        return $OCF_ERR_CONFIGURED
f18d3d
+    if [ "$OCF_CHECK_LEVEL" -eq 10 ]; then
f18d3d
+        if ! ocf_is_ms; then
f18d3d
+            ocf_exit_reason "Galera must be configured as a multistate Master/Slave resource."
f18d3d
+            return $OCF_ERR_CONFIGURED
f18d3d
+        fi
f18d3d
     fi
f18d3d
 
f18d3d
     if [ -z "$OCF_RESKEY_wsrep_cluster_address" ]; then
f18d3d
@@ -1035,6 +1037,7 @@ case "$1" in
f18d3d
         exit $OCF_SUCCESS;;
f18d3d
 esac
f18d3d
 
f18d3d
+[ "$__OCF_ACTION" = "start" ] && OCF_CHECK_LEVEL=10
f18d3d
 galera_validate
f18d3d
 rc=$?
f18d3d
 LSB_STATUS_STOPPED=3
f18d3d
diff --git a/heartbeat/mpathpersist.in b/heartbeat/mpathpersist.in
f18d3d
index 0e2c2a4a0..8a46b9930 100644
f18d3d
--- a/heartbeat/mpathpersist.in
f18d3d
+++ b/heartbeat/mpathpersist.in
f18d3d
@@ -630,10 +630,11 @@ mpathpersist_action_notify() {
f18d3d
 }
f18d3d
 
f18d3d
 mpathpersist_action_validate_all () {
f18d3d
-
f18d3d
-    if [ "$OCF_RESKEY_CRM_meta_master_max" != "1" ] && [ "$RESERVATION_TYPE"  != "7" ] && [ "$RESERVATION_TYPE" != "8" ]; then
f18d3d
-        ocf_log err "Master options misconfigured."
f18d3d
-        exit $OCF_ERR_CONFIGURED
f18d3d
+    if [ "$OCF_CHECK_LEVEL" -eq 10 ]; then
f18d3d
+        if [ "$OCF_RESKEY_CRM_meta_master_max" != "1" ] && [ "$RESERVATION_TYPE"  != "7" ] && [ "$RESERVATION_TYPE" != "8" ]; then
f18d3d
+            ocf_log err "Master options misconfigured."
f18d3d
+            exit $OCF_ERR_CONFIGURED
f18d3d
+        fi
f18d3d
     fi
f18d3d
 
f18d3d
     return $OCF_SUCCESS
f18d3d
@@ -659,6 +660,10 @@ case $ACTION in
f18d3d
     start|promote|monitor|stop|demote)
f18d3d
         ocf_log debug "$RESOURCE: starting action \"$ACTION\""
f18d3d
         mpathpersist_init
f18d3d
+        if [ "$__OCF_ACTION" = "start" ]; then
f18d3d
+            OCF_CHECK_LEVEL=10
f18d3d
+            mpathpersist_action_validate_all
f18d3d
+        fi
f18d3d
         mpathpersist_action_$ACTION
f18d3d
         exit $?
f18d3d
         ;;
f18d3d
diff --git a/heartbeat/sg_persist.in b/heartbeat/sg_persist.in
f18d3d
index 16048ea6f..620c02f4a 100644
f18d3d
--- a/heartbeat/sg_persist.in
f18d3d
+++ b/heartbeat/sg_persist.in
f18d3d
@@ -643,10 +643,11 @@ sg_persist_action_notify() {
f18d3d
 }
f18d3d
 
f18d3d
 sg_persist_action_validate_all () {
f18d3d
-
f18d3d
-    if [ "$OCF_RESKEY_CRM_meta_master_max" != "1" ] && [ "$RESERVATION_TYPE"  != "7" ] && [ "$RESERVATION_TYPE" != "8" ]; then
f18d3d
-        ocf_log err "Master options misconfigured."
f18d3d
-        exit $OCF_ERR_CONFIGURED
f18d3d
+    if [ "$OCF_CHECK_LEVEL" -eq 10 ]; then
f18d3d
+        if [ "$OCF_RESKEY_CRM_meta_master_max" != "1" ] && [ "$RESERVATION_TYPE"  != "7" ] && [ "$RESERVATION_TYPE" != "8" ]; then
f18d3d
+            ocf_log err "Master options misconfigured."
f18d3d
+            exit $OCF_ERR_CONFIGURED
f18d3d
+        fi
f18d3d
     fi
f18d3d
 
f18d3d
     return $OCF_SUCCESS
f18d3d
@@ -672,6 +673,10 @@ case $ACTION in
f18d3d
     start|promote|monitor|stop|demote)
f18d3d
         ocf_log debug "$RESOURCE: starting action \"$ACTION\""
f18d3d
         sg_persist_init
f18d3d
+        if [ "$__OCF_ACTION" = "start" ]; then
f18d3d
+            OCF_CHECK_LEVEL=10
f18d3d
+            sg_persist_action_validate_all
f18d3d
+        fi
f18d3d
         sg_persist_action_$ACTION
f18d3d
         exit $?
f18d3d
         ;;