diff --git a/SOURCES/bz2024140-SAPInstance-1-add-systemd-support.patch b/SOURCES/bz2024140-SAPInstance-1-add-systemd-support.patch new file mode 100644 index 0000000..1c31b8b --- /dev/null +++ b/SOURCES/bz2024140-SAPInstance-1-add-systemd-support.patch @@ -0,0 +1,196 @@ +From 2d50c76c366df4e6021c2992e085bbc48fa112b0 Mon Sep 17 00:00:00 2001 +From: fmherschel +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_.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 + } + + diff --git a/SOURCES/bz2024140-SAPInstance-2-fix-systemd-issue.patch b/SOURCES/bz2024140-SAPInstance-2-fix-systemd-issue.patch new file mode 100644 index 0000000..750f50f --- /dev/null +++ b/SOURCES/bz2024140-SAPInstance-2-fix-systemd-issue.patch @@ -0,0 +1,24 @@ +From 9a851525c30a4bdb522e64301268c9ef2188ae83 Mon Sep 17 00:00:00 2001 +From: fmherschel +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 diff --git a/SOURCES/bz2024186-SAPInstance-1-add-systemd-support.patch b/SOURCES/bz2024186-SAPInstance-1-add-systemd-support.patch deleted file mode 100644 index 1c31b8b..0000000 --- a/SOURCES/bz2024186-SAPInstance-1-add-systemd-support.patch +++ /dev/null @@ -1,196 +0,0 @@ -From 2d50c76c366df4e6021c2992e085bbc48fa112b0 Mon Sep 17 00:00:00 2001 -From: fmherschel -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_.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 - } - - diff --git a/SOURCES/bz2024186-SAPInstance-2-fix-systemd-issue.patch b/SOURCES/bz2024186-SAPInstance-2-fix-systemd-issue.patch deleted file mode 100644 index 750f50f..0000000 --- a/SOURCES/bz2024186-SAPInstance-2-fix-systemd-issue.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 9a851525c30a4bdb522e64301268c9ef2188ae83 Mon Sep 17 00:00:00 2001 -From: fmherschel -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 diff --git a/SPECS/resource-agents-sap.spec b/SPECS/resource-agents-sap.spec index a701e55..741aa0e 100644 --- a/SPECS/resource-agents-sap.spec +++ b/SPECS/resource-agents-sap.spec @@ -28,7 +28,7 @@ Name: resource-agents-sap Summary: SAP cluster resource agents Version: 4.1.1 -Release: 30%{?rcver:%{rcver}}%{?numcomm:.%{numcomm}}%{?alphatag:.%{alphatag}}%{?dirty:.%{dirty}}%{?dist}.1 +Release: 31%{?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} @@ -42,8 +42,8 @@ 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: bz2024186-SAPInstance-1-add-systemd-support.patch -Patch5: bz2024186-SAPInstance-2-fix-systemd-issue.patch +Patch4: bz2024140-SAPInstance-1-add-systemd-support.patch +Patch5: bz2024140-SAPInstance-2-fix-systemd-issue.patch BuildArch: noarch @@ -136,10 +136,10 @@ rm -rf %{buildroot} %exclude /usr/src %changelog -* Thu Nov 18 2021 Oyvind Albrigtsen - 4.1.1-30.1 +* Thu Nov 18 2021 Oyvind Albrigtsen - 4.1.1-31 - SAPInstance: add systemd support - Resolves: rhbz#2024186 + Resolves: rhbz#2024140 * Fri Apr 17 2020 Oyvind Albrigtsen - 4.1.1-30 - use safe temp file location