Compare commits

...

No commits in common. "c8" and "c9s" have entirely different histories.
c8 ... c9s

16 changed files with 328 additions and 681 deletions

8
.gitignore vendored
View File

@ -1,2 +1,6 @@
SOURCES/ClusterLabs-resource-agents-e711383f.tar.gz
SOURCES/sap_cluster_connector-0015fe2.tar.gz
/*.tar.gz
/*.src.rpm
/.build-*.log
/*/
!/tests/
/tests/*.retry

View File

@ -1,2 +0,0 @@
0358e1cb7fe86b2105bd2646cbe86f3c0273844a SOURCES/ClusterLabs-resource-agents-e711383f.tar.gz
731c683ecc63b50fbc0823170e966b74ec2a0f51 SOURCES/sap_cluster_connector-0015fe2.tar.gz

View File

@ -1,92 +0,0 @@
From 70a28e8130be863a9073b0a80e0511e971e205c4 Mon Sep 17 00:00:00 2001
From: Fabian Herschel <fabian.herschel@suse.com>
Date: Fri, 27 Jul 2018 12:33:19 +0200
Subject: [PATCH 1/2] SAPInstance: implemeted reload method The reload method
is needed to avoid resource restarts after a non-unique parameter has been
changed. This is in special for interest of the MONITOR_SERVICES parameter.
---
heartbeat/SAPInstance | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/heartbeat/SAPInstance b/heartbeat/SAPInstance
index 8de7cee8c..c25839f0c 100755
--- a/heartbeat/SAPInstance
+++ b/heartbeat/SAPInstance
@@ -61,6 +61,7 @@ sapinstance_usage() {
The 'monitor' operation reports whether the instance seems to be working
The 'promote' operation starts the primary instance in a Master/Slave configuration
The 'demote' operation stops the primary instance and starts the ERS instance
+ The 'reload' operation allows changed parameters (non-unique only) without restarting the service
The 'notify' operation always returns SUCCESS
The 'validate-all' operation reports whether the parameters are valid
The 'methods' operation reports on the methods $0 supports
@@ -224,6 +225,7 @@ The name of the SAP START profile. Specify this parameter, if you have changed t
<action name="monitor" depth="0" timeout="60s" interval="119s" role="Master" />
<action name="promote" timeout="320s" />
<action name="demote" timeout="320s" />
+<action name="reload" timeout="320" />
<action name="validate-all" timeout="5s" />
<action name="meta-data" timeout="5s" />
<action name="methods" timeout="5s" />
@@ -244,6 +246,7 @@ sapinstance_methods() {
monitor
promote
demote
+ reload
notify
validate-all
methods
@@ -965,6 +968,9 @@ case "$ACTION" in
exit $?;;
validate-all) sapinstance_validate
exit $?;;
+ reload )
+ ocf_log info "reloading SAPInstance parameters"
+ exit $OCF_SUCCESS;;
*) sapinstance_methods
exit $OCF_ERR_UNIMPLEMENTED;;
esac
From ee529b088cc1111656e94dea56b9fcfa6d813313 Mon Sep 17 00:00:00 2001
From: Fabian Herschel <fabian.herschel@suse.com>
Date: Fri, 27 Jul 2018 13:02:39 +0200
Subject: [PATCH 2/2] SAPInstance: Improved indents
---
heartbeat/SAPInstance | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/heartbeat/SAPInstance b/heartbeat/SAPInstance
index c25839f0c..174ea36ef 100755
--- a/heartbeat/SAPInstance
+++ b/heartbeat/SAPInstance
@@ -61,7 +61,7 @@ sapinstance_usage() {
The 'monitor' operation reports whether the instance seems to be working
The 'promote' operation starts the primary instance in a Master/Slave configuration
The 'demote' operation stops the primary instance and starts the ERS instance
- The 'reload' operation allows changed parameters (non-unique only) without restarting the service
+ The 'reload' operation allows changed parameters (non-unique only) without restarting the service
The 'notify' operation always returns SUCCESS
The 'validate-all' operation reports whether the parameters are valid
The 'methods' operation reports on the methods $0 supports
@@ -246,7 +246,7 @@ sapinstance_methods() {
monitor
promote
demote
- reload
+ reload
notify
validate-all
methods
@@ -969,8 +969,8 @@ case "$ACTION" in
validate-all) sapinstance_validate
exit $?;;
reload )
- ocf_log info "reloading SAPInstance parameters"
- exit $OCF_SUCCESS;;
+ ocf_log info "reloading SAPInstance parameters"
+ exit $OCF_SUCCESS;;
*) sapinstance_methods
exit $OCF_ERR_UNIMPLEMENTED;;
esac

View File

@ -1,26 +0,0 @@
From 8eda4725a946ca669df035ed0ffdf053a65e1258 Mon Sep 17 00:00:00 2001
From: Fabian Herschel <fabian.herschel@suse.com>
Date: Thu, 2 Aug 2018 15:36:31 +0200
Subject: [PATCH] SAPInstance: Improved SAP instance profile detection
---
heartbeat/SAPInstance | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/heartbeat/SAPInstance b/heartbeat/SAPInstance
index 174ea36ef..eb058cccf 100755
--- a/heartbeat/SAPInstance
+++ b/heartbeat/SAPInstance
@@ -371,7 +371,11 @@ sapinstance_init() {
if [ -z "$currentSTART_PROFILE" ]
then
- SAPSTARTPROFILE="$DIR_PROFILE/START_${InstanceName}_${SAPVIRHOST}"
+ if [ ! -r "$DIR_PROFILE/START_${InstanceName}_${SAPVIRHOST}" -a -r "$DIR_PROFILE/${SID}_${InstanceName}_${SAPVIRHOST}" ]; then
+ SAPSTARTPROFILE="$DIR_PROFILE/${SID}_${InstanceName}_${SAPVIRHOST}"
+ else
+ SAPSTARTPROFILE="$DIR_PROFILE/START_${InstanceName}_${SAPVIRHOST}"
+ fi
else
SAPSTARTPROFILE="$currentSTART_PROFILE"
fi

View File

@ -1,37 +0,0 @@
--- a/heartbeat/SAPInstance 2019-02-20 12:42:55.655819263 +0100
+++ b/heartbeat/SAPInstance 2019-02-08 10:57:02.281048136 +0100
@@ -159,14 +159,14 @@
<content type="string" default="disp+work|msg_server|enserver|enrepserver|jcontrol|jstart|enq_server|enq_replicator"/>
</parameter>
<parameter name="SHUTDOWN_METHOD" unique="0" required="0">
- <longdesc lang="en">Usual a SAP Instance is stopped by the command 'sapcontrol -nr InstanceNr -function Stop'. SHUTDOWN_METHOD=KILL means to kill the SAP Instance using OS commands. SAP processes of the instance are terminated with 'kill -9', shared memory is deleted with 'cleanipc' and the 'kill.sap' file will be deleted. That method is much faster than the gracefull stop, but the instance does not have the chance to say goodbye to other SAPinstances in the same system. USE AT YOUR OWN RISK !!</longdesc>
+ <longdesc lang="en">Usually a SAP Instance is stopped by the command 'sapcontrol -nr InstanceNr -function Stop'. SHUTDOWN_METHOD=KILL means to kill the SAP Instance using OS commands. SAP processes of the instance are terminated with 'kill -9', shared memory is deleted with 'cleanipc' and the 'kill.sap' file will be deleted. That method is much faster than the graceful stop, but the instance does not have the chance to say goodbye to other SAPinstances in the same system. USE AT YOUR OWN RISK !!</longdesc>
<shortdesc lang="en">Shutdown graceful or kill a SAP instance by terminating the processes. (normal|KILL)</shortdesc>
<content type="string" default="normal"/>
</parameter>
<parameter name="ERS_InstanceName" unique="1" required="0">
<longdesc lang="en">Only used in a Master/Slave resource configuration:
The full qualified SAP enqueue replication instance name. e.g. P01_ERS02_sapp01ers. Usually this is the name of the SAP instance profile.
-The enqueue replication instance must be installed, before you want to configure a master-slave cluster recource.
+The enqueue replication instance must be installed, before you want to configure a master-slave cluster resource.
The master-slave configuration in the cluster must use this properties:
clone_max = 2
@@ -209,7 +209,7 @@
<longdesc lang="en">Only used for ASCS/ERS SAP Netweaver installations without implementing a master/slave resource to
allow the ASCS to 'find' the ERS running on another cluster node after a resource failure. This parameter should be set
to true 'only' for the ERS instance for implementations following the SAP NetWeaver 7.40 HA certification (NW-HA-CLU-740). This includes also
- systems for NetWeaver less than 7.40, if you like to impelemnt the NW-HA-CLU-740 scenario.
+ systems for NetWeaver less than 7.40, if you like to implement the NW-HA-CLU-740 scenario.
</longdesc>
<shortdesc lang="en">Mark SAPInstance as ERS instance</shortdesc>
<content type="boolean" default="false" />
@@ -225,7 +225,7 @@
<action name="monitor" depth="0" timeout="60s" interval="119s" role="Master" />
<action name="promote" timeout="320s" />
<action name="demote" timeout="320s" />
-<action name="reload" timeout="320" />
+<action name="reload" timeout="320s" />
<action name="validate-all" timeout="5s" />
<action name="meta-data" timeout="5s" />
<action name="methods" timeout="5s" />

View File

@ -1,44 +0,0 @@
diff -uNr a/heartbeat/ClusterMon b/heartbeat/ClusterMon
--- a/heartbeat/ClusterMon 2018-06-29 14:05:02.000000000 +0200
+++ b/heartbeat/ClusterMon 2020-03-27 12:09:23.636845893 +0100
@@ -86,7 +86,7 @@
PID file location to ensure only one instance is running
</longdesc>
<shortdesc lang="en">PID file</shortdesc>
-<content type="string" default="/tmp/ClusterMon_${OCF_RESOURCE_INSTANCE}.pid" />
+<content type="string" default="${HA_RSCTMP}/ClusterMon_${OCF_RESOURCE_INSTANCE}.pid" />
</parameter>
<parameter name="htmlfile" unique="1" required="0">
@@ -94,7 +94,7 @@
Location to write HTML output to.
</longdesc>
<shortdesc lang="en">HTML output</shortdesc>
-<content type="string" default="/tmp/ClusterMon_${OCF_RESOURCE_INSTANCE}.html" />
+<content type="string" default="${HA_RSCTMP}/ClusterMon_${OCF_RESOURCE_INSTANCE}.html" />
</parameter>
</parameters>
@@ -233,8 +233,8 @@
fi
: ${OCF_RESKEY_update:="15000"}
-: ${OCF_RESKEY_pidfile:="/tmp/ClusterMon_${OCF_RESOURCE_INSTANCE}.pid"}
-: ${OCF_RESKEY_htmlfile:="/tmp/ClusterMon_${OCF_RESOURCE_INSTANCE}.html"}
+: ${OCF_RESKEY_pidfile:="${HA_RSCTMP}/ClusterMon_${OCF_RESOURCE_INSTANCE}.pid"}
+: ${OCF_RESKEY_htmlfile:="${HA_RSCTMP}/ClusterMon_${OCF_RESOURCE_INSTANCE}.html"}
OCF_RESKEY_update=`expr $OCF_RESKEY_update / 1000`
diff -uNr a/heartbeat/sapdb-nosha.sh b/heartbeat/sapdb-nosha.sh
--- a/heartbeat/sapdb-nosha.sh 2018-06-29 14:05:02.000000000 +0200
+++ b/heartbeat/sapdb-nosha.sh 2020-03-27 12:07:16.183958164 +0100
@@ -740,5 +740,5 @@
}
# Set a tempfile and make sure to clean it up again
-TEMPFILE="/tmp/SAPDatabase.$$.tmp"
-trap trap_handler INT TERM
\ No newline at end of file
+TEMPFILE="${HA_RSCTMP}/SAPDatabase.$$.tmp"
+trap trap_handler INT TERM

View File

@ -1,41 +0,0 @@
From d6b954890b496fcdd8a76d7c2dd44a36fa0ad42c Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Thu, 7 Oct 2021 11:10:16 +0200
Subject: [PATCH 1/3] all agents: specify agent and OCF versions corrently in
metadata
---
heartbeat/SAPDatabase | 4 ++--
heartbeat/SAPInstance | 4 ++--
133 files changed, 169 insertions(+), 169 deletions(-)
diff --git a/heartbeat/SAPDatabase b/heartbeat/SAPDatabase
index 3486303f10..563a6f3469 100755
--- a/heartbeat/SAPDatabase
+++ b/heartbeat/SAPDatabase
@@ -109,8 +109,8 @@ meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
-<resource-agent name="SAPDatabase">
-<version>2.14</version>
+<resource-agent name="SAPDatabase" version="2.14">
+<version>1.0</version>
<longdesc lang="en">
Resource script for SAP databases. It manages a SAP database of any type as an HA resource.
diff --git a/heartbeat/SAPInstance b/heartbeat/SAPInstance
index f8bcbc05b8..016f59aff2 100755
--- a/heartbeat/SAPInstance
+++ b/heartbeat/SAPInstance
@@ -110,8 +110,8 @@ sapinstance_meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
-<resource-agent name="SAPInstance">
-<version>2.14</version>
+<resource-agent name="SAPInstance" version="2.14">
+<version>1.0</version>
<longdesc lang="en">
Usually a SAP system consists of one database and at least one or more SAP instances (sometimes called application servers). One SAP Instance is defined by having exactly one instance profile. The instance profiles can usually be found in the directory /sapmnt/SID/profile. Each instance must be configured as it's own resource in the cluster configuration.

View File

@ -1,196 +0,0 @@
From 2d50c76c366df4e6021c2992e085bbc48fa112b0 Mon Sep 17 00:00:00 2001
From: fmherschel <fh-github@herschel-mainz.org>
Date: Fri, 25 Jun 2021 16:16:51 +0200
Subject: [PATCH] SAPInstance: add systemd compatability (#1662)
* SAPInstance: for systemd integrated sapstartsrv instances use systemd to check/start the service
---
heartbeat/SAPInstance | 146 ++++++++++++++++++++++++++----------------
1 file changed, 91 insertions(+), 55 deletions(-)
diff --git a/heartbeat/SAPInstance b/heartbeat/SAPInstance
index 8c404d4376..15b24024e0 100755
--- a/heartbeat/SAPInstance
+++ b/heartbeat/SAPInstance
@@ -369,6 +369,7 @@ sapinstance_init() {
InstanceName=`echo "$myInstanceName" | cut -d_ -f2`
InstanceNr=`echo "$InstanceName" | sed 's/.*\([0-9][0-9]\)$/\1/'`
SAPVIRHOST=`echo "$myInstanceName" | cut -d_ -f3`
+ SYSTEMCTL="systemctl"
# optional OCF parameters, we try to guess which directories are correct
if [ -z "$OCF_RESKEY_DIR_EXECUTABLE" ]
@@ -446,6 +447,25 @@ sapinstance_init() {
return $OCF_SUCCESS
}
+#
+# check_systemd_integration : Check, if SAP instance is controlled by systemd unit file SAP<SID>_<InstanceNr>.service
+# rc == 0 : sap instance is controlled by the unit file (file at least exists)
+# rc == 1 : sap instance is NOT controlled by the unit file (file does not exist)
+#
+check_systemd_integration() {
+ local systemd_unit_name="SAP${SID}_${InstanceNr}"
+ local rc=1
+
+ if [ -x "$SYSTEMCTL" ]; then
+ if $SYSTEMCTL list-unit-files | \
+ awk '$1 == service { found=1 } END { if (! found) {exit 1}}' service="${systemd_unit_name}.service"; then
+ rc=0
+ else
+ rc=1
+ fi
+ fi
+ return "$rc"
+}
#
# check_sapstartsrv : Before using sapcontrol we make sure that the sapstartsrv is running for the correct instance.
@@ -458,76 +478,92 @@ check_sapstartsrv() {
local chkrc=$OCF_SUCCESS
local output=""
- if [ ! -S /tmp/.sapstream5${InstanceNr}13 ]; then
- ocf_log warn "sapstartsrv is not running for instance $SID-$InstanceName (no UDS), it will be started now"
- restart=1
- else
- output=`$SAPCONTROL -nr $InstanceNr -function ParameterValue INSTANCE_NAME -format script`
- if [ $? -eq 0 ]
- then
- runninginst=`echo "$output" | grep '^0 : ' | cut -d' ' -f3`
- if [ "$runninginst" != "$InstanceName" ]
- then
- ocf_log warn "sapstartsrv is running for instance $runninginst, that service will be killed"
+ # check for sapstartsrv/systemd integration
+
+ if check_systemd_integration; then
+ # do it the systemd way
+ local systemd_unit_name="SAP${SID}_${InstanceNr}"
+
+ if $SYSTEMCTL status "$systemd_unit_name" 1>/dev/null 2>/dev/null; then
+ ocf_log info "systemd service $systemd_unit_name is active"
+ else
+ ocf_log warn "systemd service $systemd_unit_name is not active, it will be started using systemd"
+ $SYSTEMCTL start "$systemd_unit_name" 1>/dev/null 2>/dev/null
+ # use start, because restart does also stop sap instance
+ fi
+
+ return 0
+ else # otherwise continue with old code...
+ if [ ! -S /tmp/.sapstream5${InstanceNr}13 ]; then
+ ocf_log warn "sapstartsrv is not running for instance $SID-$InstanceName (no UDS), it will be started now"
restart=1
else
- output=`$SAPCONTROL -nr $InstanceNr -function AccessCheck Start`
- if [ $? -ne 0 ]; then
- ocf_log warn "FAILED : sapcontrol -nr $InstanceNr -function AccessCheck Start (`ls -ld1 /tmp/.sapstream5${InstanceNr}13`)"
- ocf_log warn "sapstartsrv will be restarted to try to solve this situation, otherwise please check sapstsartsrv setup (SAP Note 927637)"
+ output=`$SAPCONTROL -nr $InstanceNr -function ParameterValue INSTANCE_NAME -format script`
+ if [ $? -eq 0 ]
+ then
+ runninginst=`echo "$output" | grep '^0 : ' | cut -d' ' -f3`
+ if [ "$runninginst" != "$InstanceName" ]
+ then
+ ocf_log warn "sapstartsrv is running for instance $runninginst, that service will be killed"
+ restart=1
+ else
+ output=`$SAPCONTROL -nr $InstanceNr -function AccessCheck Start`
+ if [ $? -ne 0 ]; then
+ ocf_log warn "FAILED : sapcontrol -nr $InstanceNr -function AccessCheck Start (`ls -ld1 /tmp/.sapstream5${InstanceNr}13`)"
+ ocf_log warn "sapstartsrv will be restarted to try to solve this situation, otherwise please check sapstsartsrv setup (SAP Note 927637)"
+ restart=1
+ fi
+ fi
+ else
+ ocf_log warn "sapstartsrv is not running for instance $SID-$InstanceName, it will be started now"
restart=1
fi
fi
- else
- ocf_log warn "sapstartsrv is not running for instance $SID-$InstanceName, it will be started now"
- restart=1
- fi
- fi
- if [ -z "$runninginst" ]; then runninginst=$InstanceName; fi
+ if [ -z "$runninginst" ]; then runninginst=$InstanceName; fi
- if [ $restart -eq 1 ]
- then
+ if [ $restart -eq 1 ]
+ then
+ if [ -d /usr/sap/$SID/SYS/profile/ ]
+ then
+ DIR_PROFILE="/usr/sap/$SID/SYS/profile"
+ else
+ abnormal_end "Expected /usr/sap/$SID/SYS/profile/ to be a directory, please set DIR_PROFILE parameter!"
+ fi
- if [ -d /usr/sap/$SID/SYS/profile/ ]
- then
- DIR_PROFILE="/usr/sap/$SID/SYS/profile"
- else
- abnormal_end "Expected /usr/sap/$SID/SYS/profile/ to be a directory, please set DIR_PROFILE parameter!"
- fi
+ [ ! -r $SAPSTARTPROFILE ] && abnormal_end "Expected $SAPSTARTPROFILE to be the instance START profile, please set START_PROFILE parameter!"
- [ ! -r $SAPSTARTPROFILE ] && abnormal_end "Expected $SAPSTARTPROFILE to be the instance START profile, please set START_PROFILE parameter!"
+ pkill -9 -f "sapstartsrv.*$runninginst"
- pkill -9 -f "sapstartsrv.*$runninginst"
+ # removing the unix domain socket files as they might have wrong permissions
+ # or ownership - they will be recreated by sapstartsrv during next start
+ rm -f /tmp/.sapstream5${InstanceNr}13
+ rm -f /tmp/.sapstream5${InstanceNr}14
- # removing the unix domain socket files as they might have wrong permissions
- # or ownership - they will be recreated by sapstartsrv during next start
- rm -f /tmp/.sapstream5${InstanceNr}13
- rm -f /tmp/.sapstream5${InstanceNr}14
+ $SAPSTARTSRV pf=$SAPSTARTPROFILE -D -u $sidadm
- $SAPSTARTSRV pf=$SAPSTARTPROFILE -D -u $sidadm
+ # now make sure the daemon has been started and is able to respond
+ local srvrc=1
+ while [ $srvrc -eq 1 -a `pgrep -f "sapstartsrv.*$runninginst" | wc -l` -gt 0 ]
+ do
+ sleep 1
+ $SAPCONTROL -nr $InstanceNr -function GetProcessList > /dev/null 2>&1
+ srvrc=$?
+ done
- # now make sure the daemon has been started and is able to respond
- local srvrc=1
- while [ $srvrc -eq 1 -a `pgrep -f "sapstartsrv.*$runninginst" | wc -l` -gt 0 ]
- do
- sleep 1
- $SAPCONTROL -nr $InstanceNr -function GetProcessList > /dev/null 2>&1
- srvrc=$?
- done
+ if [ $srvrc -ne 1 ]
+ then
+ ocf_log info "sapstartsrv for instance $SID-$InstanceName was restarted !"
+ chkrc=$OCF_SUCCESS
+ else
+ ocf_log error "sapstartsrv for instance $SID-$InstanceName could not be started!"
+ chkrc=$OCF_ERR_GENERIC
+ ocf_is_probe && chkrc=$OCF_NOT_RUNNING
+ fi
+ fi
- if [ $srvrc -ne 1 ]
- then
- ocf_log info "sapstartsrv for instance $SID-$InstanceName was restarted !"
- chkrc=$OCF_SUCCESS
- else
- ocf_log error "sapstartsrv for instance $SID-$InstanceName could not be started!"
- chkrc=$OCF_ERR_GENERIC
- ocf_is_probe && chkrc=$OCF_NOT_RUNNING
- fi
+ return $chkrc
fi
-
- return $chkrc
}

View File

@ -1,24 +0,0 @@
From 9a851525c30a4bdb522e64301268c9ef2188ae83 Mon Sep 17 00:00:00 2001
From: fmherschel <fh-github@herschel-mainz.org>
Date: Mon, 9 Aug 2021 11:57:22 +0200
Subject: [PATCH] SAPInstance: Fix for issue #1680 - SAPInstance fails to
detect systemd integration (#1681)
* SAPInstance: Fix for issue #1680 - SAPInstance fails to detect systemd integration
---
heartbeat/SAPInstance | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/heartbeat/SAPInstance b/heartbeat/SAPInstance
index 15b24024e..f8bcbc05b 100755
--- a/heartbeat/SAPInstance
+++ b/heartbeat/SAPInstance
@@ -456,7 +456,7 @@ check_systemd_integration() {
local systemd_unit_name="SAP${SID}_${InstanceNr}"
local rc=1
- if [ -x "$SYSTEMCTL" ]; then
+ if which "$SYSTEMCTL" 1>/dev/null 2>/dev/null; then
if $SYSTEMCTL list-unit-files | \
awk '$1 == service { found=1 } END { if (! found) {exit 1}}' service="${systemd_unit_name}.service"; then
rc=0

View File

@ -1,46 +0,0 @@
From 08ed464aa803f03cbb6cabc79afe462fc98ad213 Mon Sep 17 00:00:00 2001
From: Fabian Herschel <fabian.herschel@suse.com>
Date: Mon, 5 Dec 2022 18:13:36 +0100
Subject: [PATCH 1/2] SAPInstance: be more resilient against broken kill.sap
files
---
heartbeat/SAPInstance | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/heartbeat/SAPInstance b/heartbeat/SAPInstance
index e3fe788ae..fbf6c5245 100755
--- a/heartbeat/SAPInstance
+++ b/heartbeat/SAPInstance
@@ -830,7 +830,7 @@ sapinstance_status() {
local pids
[ ! -f "/usr/sap/$SID/$InstanceName/work/kill.sap" ] && return $OCF_NOT_RUNNING
- pids=`grep '^kill -[0-9]' /usr/sap/$SID/$InstanceName/work/kill.sap | awk '{print $3}'`
+ pids=$(awk '$3 ~ "[0-9]+" { print $3 }' /usr/sap/$SID/$InstanceName/work/kill.sap)
for pid in $pids
do
[ `pgrep -f -U $sidadm $InstanceName | grep -c $pid` -gt 0 ] && return $OCF_SUCCESS
From a7153dd3f31fe5a14bf76d367cd8185848821fcd Mon Sep 17 00:00:00 2001
From: Fabian Herschel <fabian.herschel@suse.com>
Date: Tue, 6 Dec 2022 09:15:56 +0100
Subject: [PATCH 2/2] SAPInstance: Also need the begin-end markers
---
heartbeat/SAPInstance | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/heartbeat/SAPInstance b/heartbeat/SAPInstance
index fbf6c5245..26fd54136 100755
--- a/heartbeat/SAPInstance
+++ b/heartbeat/SAPInstance
@@ -830,7 +830,7 @@ sapinstance_status() {
local pids
[ ! -f "/usr/sap/$SID/$InstanceName/work/kill.sap" ] && return $OCF_NOT_RUNNING
- pids=$(awk '$3 ~ "[0-9]+" { print $3 }' /usr/sap/$SID/$InstanceName/work/kill.sap)
+ pids=$(awk '$3 ~ "^[0-9]+$" { print $3 }' /usr/sap/$SID/$InstanceName/work/kill.sap)
for pid in $pids
do
[ `pgrep -f -U $sidadm $InstanceName | grep -c $pid` -gt 0 ] && return $OCF_SUCCESS

View File

@ -1,171 +0,0 @@
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
#
# Below is the script used to generate a new source file
# from the resource-agent upstream git repo.
#
# TAG=$(git log --pretty="format:%h" -n 1)
# distdir="ClusterLabs-resource-agents-${TAG}"
# TARFILE="${distdir}.tar.gz"
# rm -rf $TARFILE $distdir
# git archive --prefix=$distdir/ HEAD | gzip > $TARFILE
#
%global upstream_prefix ClusterLabs-resource-agents
%global upstream_version e711383f
%global sap_script_prefix sap_cluster_connector
%global sap_script_hash 0015fe2
Name: resource-agents-sap
Summary: SAP cluster resource agents
Version: 4.1.1
Release: 34%{?rcver:%{rcver}}%{?numcomm:.%{numcomm}}%{?alphatag:.%{alphatag}}%{?dirty:.%{dirty}}%{?dist}
License: GPLv2+
URL: https://github.com/ClusterLabs/resource-agents
%if 0%{?fedora} || 0%{?centos_version} || 0%{?rhel}
Group: System Environment/Base
%else
Group: Productivity/Clustering/HA
%endif
Source0: %{upstream_prefix}-%{upstream_version}.tar.gz
Source1: %{sap_script_prefix}-%{sap_script_hash}.tar.gz
Patch0: bz1751949-1-SAPInstance-add-reload-action.patch
Patch1: bz1751949-2-SAPInstance-improve-profile-detection.patch
Patch2: bz1751949-3-SAPInstance-metadata-improvements.patch
Patch3: bz1817439-use-safe-temp-file-location.patch
Patch4: bz2024140-SAPInstance-1-add-systemd-support.patch
Patch5: bz2024140-SAPInstance-2-fix-systemd-issue.patch
Patch6: bz1937026-SAPDatabase-SAPInstance-set-correct-agent-ocf-version.patch
Patch7: bz2151296-SAPInstance-improve-killsap-logic.patch
BuildArch: noarch
BuildRequires: automake autoconf gcc
BuildRequires: perl-interpreter python3-devel
BuildRequires: libxslt glib2-devel
%if 0%{?fedora} || 0%{?centos_version} || 0%{?rhel}
BuildRequires: docbook-style-xsl docbook-dtds
%endif
Requires: resource-agents >= 4.1.1
Requires: /bin/bash /usr/bin/grep /bin/sed /bin/gawk
%description
The SAP resource agents interface with Pacemaker to allow
SAP instances to be managed in a cluster environment.
%prep
%setup -q -n %{upstream_prefix}-%{upstream_version}
%setup -q -T -D -a 1 -n %{upstream_prefix}-%{upstream_version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%build
if [ ! -f configure ]; then
./autogen.sh
fi
%global rasset linux-ha
%configure BASH_SHELL="/bin/bash" \
PYTHON="%{__python3}" \
%{conf_opt_fatal} \
%if %{defined _unitdir}
--with-systemdsystemunitdir=%{_unitdir} \
%endif
%if %{defined _tmpfilesdir}
--with-systemdtmpfilesdir=%{_tmpfilesdir} \
--with-rsctmpdir=/run/resource-agents \
%endif
--with-pkg-name=%{name} \
--with-ras-set=%{rasset}
%if %{defined jobs}
JFLAGS="$(echo '-j%{jobs}')"
%else
JFLAGS="$(echo '%{_smp_mflags}')"
%endif
make $JFLAGS
%install
make install DESTDIR=%{buildroot}
# remove other agents
find %{buildroot}/usr/lib/ocf ! -type d ! -iname "SAP*" -exec rm {} \;
find %{buildroot}/%{_mandir} -type f ! -iname "*SAP*" -exec rm {} \;
cp %{sap_script_prefix}-%{sap_script_hash}/redhat/sap_redhat_cluster_connector %{buildroot}/%{_sbindir}/sap_redhat_cluster_connector
## tree fixup
# remove docs (there is only one and they should come from doc sections in files)
rm -rf %{buildroot}/usr/share/doc/resource-agents
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root)
%{_usr}/lib/ocf/resource.d/heartbeat/SAP*
%{_usr}/lib/ocf/lib/heartbeat/sap*
%{_mandir}/man7/*SAP*
%{_sbindir}/sap_redhat_cluster_connector
%exclude /etc
%exclude /usr/include
%exclude %{_usr}/lib/debug
%exclude %{_usr}/lib/systemd
%exclude %{_usr}/lib/tmpfiles.d
%exclude /usr/libexec/heartbeat
%exclude /usr/sbin/ldirectord
%exclude /usr/sbin/ocf*
%exclude /usr/share/%{name}
%exclude /usr/src
%changelog
* Wed Dec 07 2022 Janine Fuchs <jfuchs@redhat.com> - 4.1.1-34
- SAPInstance: be more resilient against broken kill.sap files
Resolves: rhbz#2151296
* Fri Jun 17 2022 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.1.1-32
- SAPDatabase/SAPInstance: set correct agent and OCF version in metadata
Resolves: rhbz#1937026
* Thu Nov 18 2021 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.1.1-31
- SAPInstance: add systemd support
Resolves: rhbz#2024140
* Fri Apr 17 2020 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.1.1-30
- use safe temp file location
Resolves: rhbz#1817439
* Thu Jan 23 2020 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.1.1-29
- SAPInstance: add reload-action
Resolves: rhbz#1751949
* Tue Jun 18 2019 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.1.1-28
- Initial build as separate package
Resolves: rhbz#1688341

6
gating.yaml Normal file
View File

@ -0,0 +1,6 @@
--- !Policy
product_versions:
- rhel-9
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}

284
resource-agents-sap.spec Normal file
View File

@ -0,0 +1,284 @@
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
#
# Below is the script used to generate a new source file
# from the resource-agent upstream git repo.
#
# Use a specified version as HEAD if needed, e.g. "v4.14.0"
#
# # Source0:
# git checkout <version tag>
# TAG=$(git log --pretty="format:%h" -n 1)
# distdir="ClusterLabs-resource-agents-${TAG}"
# TARFILE="${distdir}.tar.gz"
# rm -rf $TARFILE $distdir
# git archive --prefix=$distdir/ HEAD | gzip > $TARFILE
#
# # Source1:
# git checkout <version tag>
# TAG=$(git log --pretty="format:%h" -n 1)
# distdir="SAPStartSrv-resourceAgent-${TAG}"
# TARFILE="${distdir}.tar.gz"
# rm -rf $TARFILE $distdir
# git archive --prefix=$distdir/ HEAD | gzip > $TARFILE
#
%global upstream_prefix ClusterLabs-resource-agents
%global upstream_version a6ccb93a
%global sapstart_prefix SAPStartSrv-resourceAgent
%global sapstart_version 1758e33
# Whether this platform defaults to using systemd as an init system
# (needs to be evaluated prior to BuildRequires being enumerated and
# installed as it's intended to conditionally select some of these, and
# for that there are only few indicators with varying reliability:
# - presence of systemd-defined macros (when building in a full-fledged
# environment, which is not the case with ordinary mock-based builds)
# - systemd-aware rpm as manifested with the presence of particular
# macro (rpm itself will trivially always be present when building)
# - existence of /usr/lib/os-release file, which is something heavily
# propagated by systemd project
# - when not good enough, there's always a possibility to check
# particular distro-specific macros (incl. version comparison)
%define systemd_native (%{?_unitdir:1}%{!?_unitdir:0}%{nil \
} || %{?__transaction_systemd_inhibit:1}%{!?__transaction_systemd_inhibit:0}%{nil \
} || %(test -f /usr/lib/os-release; test $? -ne 0; echo $?))
# determine the ras-set to process based on configure invocation
%bcond_with rgmanager
%bcond_without linuxha
Name: resource-agents-sap
Summary: SAP cluster resource agents
Version: 4.15.1
Release: 1%{?rcver:%{rcver}}%{?numcomm:.%{numcomm}}%{?alphatag:.%{alphatag}}%{?dirty:.%{dirty}}%{?dist}
License: GPLv2+
URL: https://github.com/ClusterLabs/resource-agents
Source0: %{upstream_prefix}-%{upstream_version}.tar.gz
Source1: %{sapstart_prefix}-%{sapstart_version}.tar.gz
BuildArch: noarch
# Build dependencies
BuildRequires: make
BuildRequires: automake autoconf pkgconfig gcc
BuildRequires: libxslt glib2-devel libqb-devel
BuildRequires: systemd
BuildRequires: which
%if 0%{?fedora} || 0%{?centos} > 7 || 0%{?rhel} > 7 || 0%{?suse_version}
BuildRequires: python3-devel
%else
BuildRequires: python-devel
%endif
%if 0%{?fedora} || 0%{?centos} || 0%{?rhel}
BuildRequires: docbook-style-xsl docbook-dtds
%if 0%{?rhel} == 0
BuildRequires: libnet-devel
%endif
%endif
%if 0%{?suse_version}
BuildRequires: libnet-devel
%if 0%{?suse_version} > 1500
BuildRequires: cluster-glue-devel
%else
BuildRequires: libglue-devel
%endif
BuildRequires: libxslt docbook_4 docbook-xsl-stylesheets
%endif
BuildRequires: python3-psutil
Requires: resource-agents >= 4.8.0
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
Requires: /bin/bash /usr/bin/grep /bin/sed /bin/gawk
Requires: python3 python3-psutil
%description
The SAP resource agents interface with Pacemaker to allow
SAP instances to be managed in a cluster environment.
%prep
%setup -q -n %{upstream_prefix}-%{upstream_version}
%setup -q -T -D -a 1 -n %{upstream_prefix}-%{upstream_version}
# Move the agent to the others for the ClusterLabs included processing.
mv %{sapstart_prefix}-%{sapstart_version}/ra/SAPStartSrv.in heartbeat
# Find the existing SAPInstance entry in the list and add 2 new after in corresponding formatting.
# heartbeat/Makefile.am indents by 3 tabs in the target list
# Skip the .in suffix, the agent is renamed in the process.
sed -i -e 's/\(\t\tSAPInstance\t\t\\\)/\1\n\t\t\tSAPStartSrv\t\t\\/' heartbeat/Makefile.am
# Find the existing SAPInstance entry in the list and add 2 new after in corresponding formatting.
# doc/man/Makefile.am indents by 26 spaces in the target list
sed -i -e 's/\( \{26\}ocf_heartbeat_SAPInstance.7 \\\)/\1\n'\
' ocf_heartbeat_SAPStartSrv.7 \\/' doc/man/Makefile.am
# Add RA to configure.ac for processing during compilation.
# - renames python files after shebang fixup
# - enables man page creation
sed -i -e 's/\(AC_CONFIG_FILES..heartbeat.SysInfo.*\)/AC_CONFIG_FILES([heartbeat\/SAPStartSrv], [chmod +x heartbeat\/SAPStartSrv])\n\1/' configure.ac
%build
if [ ! -f configure ]; then
./autogen.sh
fi
%if 0%{?fedora} >= 11 || 0%{?centos} > 5 || 0%{?rhel} > 5
CFLAGS="$(echo '%{optflags}')"
%global conf_opt_fatal "--enable-fatal-warnings=no"
%else
CFLAGS="${CFLAGS} ${RPM_OPT_FLAGS}"
%global conf_opt_fatal "--enable-fatal-warnings=yes"
%endif
%if %{with rgmanager}
%global rasset rgmanager
%endif
%if %{with linuxha}
%global rasset linux-ha
%endif
%if %{with rgmanager} && %{with linuxha}
%global rasset all
%endif
export CFLAGS
%configure \
%if 0%{?fedora} || 0%{?centos} > 7 || 0%{?rhel} > 7 || 0%{?suse_version}
PYTHON="%{__python3}" \
%endif
%{conf_opt_fatal} \
%if %{defined _unitdir}
--with-systemdsystemunitdir=%{_unitdir} \
%endif
%if %{defined _tmpfilesdir}
--with-systemdtmpfilesdir=%{_tmpfilesdir} \
--with-rsctmpdir=/run/resource-agents \
%endif
--with-pkg-name=resource-agents \
--with-ras-set=%{rasset}
make %{_smp_mflags}
%install
rm -rf %{buildroot}
make install DESTDIR=%{buildroot}
# Remove other agents
find %{buildroot}/usr/lib/ocf ! -type d ! -iname "SAP*" -exec rm {} \;
find %{buildroot}%{_mandir} -type f ! -iname "*SAP*" -exec rm {} \;
find %{buildroot}%{_unitdir} -type f ! -iname "sap*" -exec rm {} \;
# Service units and script called by services.
install -D -m 0644 %{sapstart_prefix}-%{sapstart_version}/sbin/sapservices-move.in \
%{buildroot}%{_bindir}/sapservices-move
install -D -m 0644 %{sapstart_prefix}-%{sapstart_version}/service/* \
%{buildroot}%{_unitdir}
# Change hard-coded /usr/sbin to /usr/bin, where the sapservices-move script lives.
sed -i -e 's|%{_sbindir}|%{_bindir}|g' %{buildroot}%{_unitdir}/sap*
# Fix python shebang.
sed -i -e 's|@PYTHON@|%{__python3}|g' %{buildroot}%{_bindir}/sapservices-move
# License
mkdir -p %{buildroot}%{_defaultlicensedir}/%{name}
cp %{sapstart_prefix}-%{sapstart_version}/LICENSE %{buildroot}%{_defaultlicensedir}/%{name}
## tree fixup
# remove docs (there is only one and they should come from doc sections in files)
rm -rf %{buildroot}/usr/share/doc/resource-agents
%post
%systemd_post sapping.service
%systemd_post sappong.service
%preun
%systemd_preun sapping.service
%systemd_preun sappong.service
%postun
%systemd_postun sapping.service
%systemd_postun sappong.service
%files
%defattr(-,root,root)
%license LICENSE
%{_usr}/lib/ocf/resource.d/heartbeat/SAP*
%{_usr}/lib/ocf/lib/heartbeat/sap*
%{_mandir}/man7/*SAP*
%defattr(755,root,root,-)
%{_bindir}/sap*
%defattr(644,root,root,-)
%{_unitdir}/sap*
%exclude /etc
%exclude /usr/include
%exclude %{_usr}/lib/debug
%exclude %{_usr}/lib/tmpfiles.d
%exclude /usr/libexec/heartbeat
%exclude /usr/sbin/ldirectord
%exclude /usr/sbin/ocf*
%exclude /usr/share/resource-agents
%exclude /usr/share/pkgconfig/resource-agents.pc
%exclude /usr/src
%changelog
* Fri Jan 10 2025 Janine Fuchs <jfuchs@redhat.com> - 4.15.1-1
- Add resource agent SAPStartSrv.
Resolves: RHEL-2294
* Wed Dec 07 2022 Janine Fuchs <jfuchs@redhat.com> - 4.10.0-3
- SAPInstance: be more resilient against broken kill.sap files
Resolves: rhbz#2151293
* Mon Nov 22 2021 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.10.0-2
- Rebase to resource-agents 4.10.0 upstream release.
Resolves: rhbz#2024660
* Tue Aug 10 2021 Mohan Boddu <mboddu@redhat.com> - 4.8.0-2.1
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Tue Jun 22 2021 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.8.0-2
- Add CI gating tests
Resolves: rhbz#1960245
* Mon Jun 7 2021 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.8.0-1
- Rebase to resource-agents 4.8.0 upstream release.
* Fri Apr 17 2020 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.1.1-30
- use safe temp file location
Resolves: rhbz#1817439
* Thu Jan 23 2020 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.1.1-29
- SAPInstance: add reload-action
Resolves: rhbz#1751949
* Tue Jun 18 2019 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.1.1-28
- Initial build as separate package
Resolves: rhbz#1688341
# vim:set ai ts=2 sw=2 sts=2 et:

2
sources Normal file
View File

@ -0,0 +1,2 @@
SHA512 (ClusterLabs-resource-agents-a6ccb93a.tar.gz) = 3ea92f051f16efbd0845d193cc7d2e7d8e9f66ba8e2bbba3a7b8d093ceff3103f8077b93037067dee8962a7d5c1ad0a0b5642acbaf385b0619cef96f18928911
SHA512 (SAPStartSrv-resourceAgent-1758e33.tar.gz) = 3460cc57bae99c390e80e8b5b92be3a62fb635161901a1d1d1cc68c38d03810e6e4f9b15a5a57eb4416f25d5f939202e1830f5b0b165ceb902d1f8fb53bc4876

16
tests/run_tests.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
err=0
agents=$(pcs resource list ocf:heartbeat 2>&1)
if [ $(echo "$agents" | wc -l) -lt 2 ]; then
echo "ERROR: pcs: agents available:\n$agents"
err=$((err+1))
else
echo "INFO: pcs: agents available..."
fi
if [ $err -ge 1 ]; then
echo -e "\nERROR: $err tests FAILED..."
exit 1
fi

14
tests/tests.yml Normal file
View File

@ -0,0 +1,14 @@
- hosts: localhost
roles:
- role: standard-test-basic
tags:
- classic
- container
required_packages:
- resource-agents-sap
- pcs
tests:
- subpackage_tests:
dir: .
run: ./run_tests.sh