import resource-agents-sap-hana-scaleout-0.180.0-4.el8

This commit is contained in:
CentOS Sources 2022-03-29 16:28:23 -04:00 committed by Stepan Oksanichenko
parent a121d15d0f
commit c53d8c2528
5 changed files with 468 additions and 1 deletions

View File

@ -0,0 +1,328 @@
From 1450ab47f5645c46e5a1f2fe9096c7db30961ab3 Mon Sep 17 00:00:00 2001
From: AngelaBriel <abriel@suse.com>
Date: Wed, 24 Nov 2021 14:51:30 +0100
Subject: [PATCH] add support for the new systemd unit file handling for
sapstartsrv and saphostagent (bsc#1189532, bsc#1189533)
---
heartbeat/SAPHanaController | 153 ++++++++++++++++++-----------
heartbeat/SAPHanaTopology | 72 ++++++++++++--
4 files changed, 172 insertions(+), 67 deletions(-)
diff --git a/heartbeat/SAPHanaController b/heartbeat/SAPHanaController
index fa47ec5..a98293c 100755
--- a/heartbeat/SAPHanaController
+++ b/heartbeat/SAPHanaController
@@ -34,7 +34,7 @@
# systemReplicationStatus.py (>= SPS090)
#
#######################################################################
-SAPHanaControllerVersion="0.180.0.0628.1823"
+SAPHanaControllerVersion="0.181.0.1123.1923"
# Resource Agent Generation
RAG="2.0"
@@ -765,6 +765,7 @@ function saphana_init() {
super_ocf_log info "FLOW $FUNCNAME ($*)"
local rc=$OCF_SUCCESS
local clN
+ SYSTEMCTL="/usr/bin/systemctl"
# local site
# two parameter models (for transition only)
# OLD: InstanceName
@@ -1125,6 +1126,25 @@ function saphana_init() {
return $OCF_SUCCESS
}
+# chk4systemdsupport - check, if SAP systemd support is available
+# check for the existence of the SAP SID+Instance related unit file
+# rc=0 - sap instance unit file exists
+# rc=1 - sap instance unit file does NOT exist
+function chk4systemdsupport() {
+ super_ocf_log info "FLOW ${FUNCNAME[0]}"
+ local systemd_unit_name="SAP${SID}_${InstanceNr}.service"
+ local rc=1
+ if [ -x "$SYSTEMCTL" ]; then
+ if [ -f /etc/systemd/system/"$systemd_unit_name" ]; then
+ rc=0
+ elif $SYSTEMCTL list-unit-files "$systemd_unit_name"; then
+ rc=0
+ else
+ rc=1
+ fi
+ fi
+ return $rc
+}
#
# function: check_sapstartsrv - check for sapstartsrv - optional start
@@ -1138,69 +1158,88 @@ function check_sapstartsrv() {
local runninginst=""
local rc=$OCF_SUCCESS
local output=""
- if [ ! -S /tmp/.sapstream5${InstanceNr}13 ]; then
- super_ocf_log warn "ACT: sapstartsrv is not running for instance $SID-$InstanceName (no UDS), it will be started now"
- restart=1
+ if chk4systemdsupport; then
+ # use systemd to control sapstartsrv
+ local systemd_unit_name="SAP${SID}_${InstanceNr}.service"
+
+ if $SYSTEMCTL is-active --quiet "$systemd_unit_name"; then
+ super_ocf_log info "ACT: systemd service $systemd_unit_name is active"
+ else
+ super_ocf_log warn "ACT: systemd service $systemd_unit_name is not active, it will be started using systemd"
+ # use start, because restart does also stop sap instance
+ $SYSTEMCTL start "$systemd_unit_name" >/dev/null 2>&1; src=$?
+ if [ $src -ne 0 ]; then
+ super_ocf_log error "ACT: error during start of systemd unit ${systemd_unit_name}!"
+ rc=$OCF_ERR_GENERIC
+ ocf_is_probe && rc=$OCF_NOT_RUNNING
+ fi
+ fi
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" ]
+ # no SAP systemd unit available, continue with old code...
+ if [ ! -S /tmp/.sapstream5${InstanceNr}13 ]; then
+ super_ocf_log warn "ACT: 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
- super_ocf_log warn "ACT: 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
- super_ocf_log warn "ACT: FAILED - sapcontrol -nr $InstanceNr -function AccessCheck Start ($(ls -ld1 /tmp/.sapstream5${InstanceNr}13))"
- super_ocf_log warn "ACT: sapstartsrv will be restarted to try to solve this situation, otherwise please check sapstsartsrv setup (SAP Note 927637)"
+ runninginst=$(echo "$output" | grep '^0 : ' | cut -d' ' -f3)
+ if [ "$runninginst" != "$InstanceName" ]
+ then
+ super_ocf_log warn "ACT: 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
+ super_ocf_log warn "ACT: FAILED - sapcontrol -nr $InstanceNr -function AccessCheck Start ($(ls -ld1 /tmp/.sapstream5${InstanceNr}13))"
+ super_ocf_log warn "ACT: sapstartsrv will be restarted to try to solve this situation, otherwise please check sapstsartsrv setup (SAP Note 927637)"
+ restart=1
+ fi
fi
+ else
+ super_ocf_log warn "ACT: sapstartsrv is not running for instance $SID-$InstanceName, it will be started now"
+ restart=1
fi
- else
- super_ocf_log warn "ACT: 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 [ $restart -eq 1 ]
- then
- if [ -d /usr/sap/$SID/SYS/profile/ ]
+ if [ -z "$runninginst" ]; then runninginst=$InstanceName; fi
+ if [ $restart -eq 1 ]
then
- DIR_PROFILE="/usr/sap/$SID/SYS/profile"
- else
- assert "Expected /usr/sap/$SID/SYS/profile/ to be a directory, please set DIR_PROFILE parameter!"
- fi
- [ ! -r $SAPSTARTPROFILE ] && assert "Expected $SAPSTARTPROFILE to be the instance START profile, please set INSTANCE_PROFILE parameter!"
- 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
- # TODO: PRIO2: Check, if we need to delete the socket files
- rm -f /tmp/.sapstream5${InstanceNr}13
- rm -f /tmp/.sapstream5${InstanceNr}14
- # DONE: PRI0: WE NEED LD_LIBRARY_PATH HERE!!
- (
- export PATH="$DIR_EXECUTABLE${PATH:+:}$PATH"
- export LD_LIBRARY_PATH="$DIR_EXECUTABLE${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH"
- $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
- if [ $srvrc -ne 1 ]
- then
- super_ocf_log info "ACT: sapstartsrv for instance $SID-$InstanceName was restarted!"
- rc=$OCF_SUCCESS
- else
- super_ocf_log error "ACT: sapstartsrv for instance $SID-$InstanceName could not be started!"
- rc=$OCF_ERR_GENERIC
- ocf_is_probe && rc=$OCF_NOT_RUNNING
+ if [ -d /usr/sap/$SID/SYS/profile/ ]
+ then
+ DIR_PROFILE="/usr/sap/$SID/SYS/profile"
+ else
+ assert "Expected /usr/sap/$SID/SYS/profile/ to be a directory, please set DIR_PROFILE parameter!"
+ fi
+ [ ! -r $SAPSTARTPROFILE ] && assert "Expected $SAPSTARTPROFILE to be the instance START profile, please set INSTANCE_PROFILE parameter!"
+ 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
+ # TODO: PRIO2: Check, if we need to delete the socket files
+ rm -f /tmp/.sapstream5${InstanceNr}13
+ rm -f /tmp/.sapstream5${InstanceNr}14
+ # DONE: PRI0: WE NEED LD_LIBRARY_PATH HERE!!
+ (
+ export PATH="$DIR_EXECUTABLE${PATH:+:}$PATH"
+ export LD_LIBRARY_PATH="$DIR_EXECUTABLE${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH"
+ $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
+ if [ $srvrc -ne 1 ]
+ then
+ super_ocf_log info "ACT: sapstartsrv for instance $SID-$InstanceName was restarted!"
+ rc=$OCF_SUCCESS
+ else
+ super_ocf_log error "ACT: sapstartsrv for instance $SID-$InstanceName could not be started!"
+ rc=$OCF_ERR_GENERIC
+ ocf_is_probe && rc=$OCF_NOT_RUNNING
+ fi
fi
fi
return $rc
diff --git a/heartbeat/SAPHanaTopology b/heartbeat/SAPHanaTopology
index a9cbbf5..b025b5b 100755
--- a/heartbeat/SAPHanaTopology
+++ b/heartbeat/SAPHanaTopology
@@ -14,7 +14,7 @@
# License: GNU General Public License (GPL)
# Copyright: (c) 2014 SUSE Linux Products GmbH
# (c) 2015-2016 SUSE Linux GmbH
-# (c) 2017-2019 SUSE LLC
+# (c) 2017-2021 SUSE LLC
#
# An example usage:
# See usage() function below for more details...
@@ -26,7 +26,7 @@
#
#######################################################################
# DONE PRIO 1: AFTER(!) SAP HANA SPS12 is available we could use hdbnsutil --sr_stateConfiguration
-SAPHanaTopologyVersion="0.180.0.0628.1824"
+SAPHanaTopologyVersion="0.181.0.1123.2015"
#
# Initialization:
timeB=$(date '+%s')
@@ -409,6 +409,8 @@ function sht_init() {
local hdbANSWER=""
local siteID
local siteNAME
+ SYSTEMCTL="/usr/bin/systemctl"
+ systemd_unit_name="saphostagent.service"
HOSTEXECNAME=saphostexec
USRSAP=/usr/sap
SAPSERVICE_PATH=${USRSAP}/sapservices
@@ -562,6 +564,25 @@ function check_for_primary() {
}
+# chk4systemdsupport - check, if SAP systemd support is available
+# check for the existence of the SAP Host Agent related unit file
+# rc=0 - SAP Host Agent unit file exists
+# rc=1 - SAP Host Agent unit file does NOT exist
+function chk4systemdsupport() {
+ super_ocf_log info "FLOW ${FUNCNAME[0]}"
+ local rc=1
+ if [ -x "$SYSTEMCTL" ]; then
+ if [ -f /etc/systemd/system/"$systemd_unit_name" ]; then
+ rc=0
+ elif $SYSTEMCTL list-unit-files "$systemd_unit_name"; then
+ rc=0
+ else
+ rc=1
+ fi
+ fi
+ return $rc
+}
+
#
# function: start_saphostagent
# params: -
@@ -570,8 +591,19 @@ function check_for_primary() {
function start_saphostagent()
{
### SAP-CALL
- if [ -x "${HOSTEXEC_PATH}" ]; then
- ${HOSTEXEC_PATH} pf=${HOSTEXEC_PROFILE_PATH}
+ if chk4systemdsupport; then
+ # use systemd to control saphostagent
+ if $SYSTEMCTL is-active --quiet "$systemd_unit_name"; then
+ super_ocf_log info "ACT: systemd service $systemd_unit_name is active"
+ else
+ super_ocf_log warn "ACT: systemd service $systemd_unit_name is not active, it will be started using systemd"
+ $SYSTEMCTL start "$systemd_unit_name" >/dev/null 2>&1
+ fi
+ else
+ # no SAP systemd unit available, continue with old code...
+ if [ -x "${HOSTEXEC_PATH}" ]; then
+ ${HOSTEXEC_PATH} pf=${HOSTEXEC_PROFILE_PATH}
+ fi
fi
return 0
}
@@ -584,8 +616,19 @@ function start_saphostagent()
function stop_saphostagent()
{
### SAP-CALL
- if [ -x "${HOSTEXEC_PATH}" ]; then
- ${HOSTEXEC_PATH} -stop
+ if chk4systemdsupport; then
+ # use systemd to control saphostagent
+ if $SYSTEMCTL is-active --quiet "$systemd_unit_name"; then
+ super_ocf_log warn "ACT: systemd service $systemd_unit_name is active, now stopping using systemd"
+ $SYSTEMCTL stop "$systemd_unit_name" >/dev/null 2>&1
+ else
+ super_ocf_log info "ACT: systemd service $systemd_unit_name is not active"
+ fi
+ else
+ # no SAP systemd unit available, continue with old code...
+ if [ -x "${HOSTEXEC_PATH}" ]; then
+ ${HOSTEXEC_PATH} -stop
+ fi
fi
}
@@ -597,9 +640,20 @@ function stop_saphostagent()
function check_saphostagent()
{
local rc=1
- # TODO: PRIO3: should the path been removed like "saphostexec" instead of "/usr/sap/hostctrl/exe/saphostexec"
- # or should we use ${HOSTEXEC_PATH} instead?
- pgrep -f /usr/sap/hostctrl/exe/saphostexec; rc=$?
+ if chk4systemdsupport; then
+ # use systemd to control saphostagent
+ if $SYSTEMCTL is-active --quiet "$systemd_unit_name"; then
+ super_ocf_log warn "ACT: systemd service $systemd_unit_name is active"
+ rc=0
+ else
+ super_ocf_log info "ACT: systemd service $systemd_unit_name is not active"
+ fi
+ else
+ # no SAP systemd unit available, continue with old code...
+ # TODO: PRIO3: should the path been removed like "saphostexec" instead of "/usr/sap/hostctrl/exe/saphostexec"
+ # or should we use ${HOSTEXEC_PATH} instead?
+ pgrep -f /usr/sap/hostctrl/exe/saphostexec; rc=$?
+ fi
return $rc
}

View File

@ -0,0 +1,36 @@
From c41efcaa658ea7987e03f9f864e9c13bce74bb20 Mon Sep 17 00:00:00 2001
From: AngelaBriel <abriel@suse.com>
Date: Thu, 25 Nov 2021 15:15:23 +0100
Subject: [PATCH] supress output of comman 'systemctl list-unit-files'
---
heartbeat/SAPHanaController | 2 +-
heartbeat/SAPHanaTopology | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/heartbeat/SAPHanaController b/heartbeat/SAPHanaController
index a98293c..9b1c401 100755
--- a/heartbeat/SAPHanaController
+++ b/heartbeat/SAPHanaController
@@ -1137,7 +1137,7 @@ function chk4systemdsupport() {
if [ -x "$SYSTEMCTL" ]; then
if [ -f /etc/systemd/system/"$systemd_unit_name" ]; then
rc=0
- elif $SYSTEMCTL list-unit-files "$systemd_unit_name"; then
+ elif $SYSTEMCTL list-unit-files "$systemd_unit_name" >/dev/null 2>&1; then
rc=0
else
rc=1
diff --git a/heartbeat/SAPHanaTopology b/heartbeat/SAPHanaTopology
index b025b5b..304cea8 100755
--- a/heartbeat/SAPHanaTopology
+++ b/heartbeat/SAPHanaTopology
@@ -574,7 +574,7 @@ function chk4systemdsupport() {
if [ -x "$SYSTEMCTL" ]; then
if [ -f /etc/systemd/system/"$systemd_unit_name" ]; then
rc=0
- elif $SYSTEMCTL list-unit-files "$systemd_unit_name"; then
+ elif $SYSTEMCTL list-unit-files "$systemd_unit_name" >/dev/null 2>&1; then
rc=0
else
rc=1

View File

@ -0,0 +1,42 @@
From c005e8260b736df63985e303558e13aaa4d579f6 Mon Sep 17 00:00:00 2001
From: AngelaBriel <abriel@suse.com>
Date: Mon, 20 Dec 2021 10:53:07 +0100
Subject: [PATCH] The return value of 'systemctl list-unit-files <service>' is
not reliable on all SLE15 codestreams, so it is not usable for our resource
agents. We need to go back to parsing the command output instead and hoping,
that the output format will not change in the future, because that will
breake the solution again as well.
---
heartbeat/SAPHanaController | 3 ++-
heartbeat/SAPHanaTopology | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/heartbeat/SAPHanaController b/heartbeat/SAPHanaController
index 9b1c401..33ae6d6 100755
--- a/heartbeat/SAPHanaController
+++ b/heartbeat/SAPHanaController
@@ -1137,7 +1137,8 @@ function chk4systemdsupport() {
if [ -x "$SYSTEMCTL" ]; then
if [ -f /etc/systemd/system/"$systemd_unit_name" ]; then
rc=0
- elif $SYSTEMCTL list-unit-files "$systemd_unit_name" >/dev/null 2>&1; then
+ elif $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
diff --git a/heartbeat/SAPHanaTopology b/heartbeat/SAPHanaTopology
index 304cea8..b9d5a03 100755
--- a/heartbeat/SAPHanaTopology
+++ b/heartbeat/SAPHanaTopology
@@ -574,7 +574,8 @@ function chk4systemdsupport() {
if [ -x "$SYSTEMCTL" ]; then
if [ -f /etc/systemd/system/"$systemd_unit_name" ]; then
rc=0
- elif $SYSTEMCTL list-unit-files "$systemd_unit_name" >/dev/null 2>&1; then
+ elif $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

View File

@ -0,0 +1,41 @@
From 5206e517e190b3c8dfc4b075cb31b5070e9670d4 Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Thu, 20 Jan 2022 10:54:54 +0100
Subject: [PATCH] SAPHana*: follow OCF standard for version and OCF version in
metadata
---
heartbeat/SAPHanaController | 4 ++--
heartbeat/SAPHanaTopology | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/heartbeat/SAPHanaController b/heartbeat/SAPHanaController
index 767af44..c365f4a 100755
--- a/heartbeat/SAPHanaController
+++ b/heartbeat/SAPHanaController
@@ -166,8 +166,8 @@ function saphana_meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
-<resource-agent name="SAPHanaController">
-<version>$SAPHanaControllerVersion</version>
+<resource-agent name="SAPHanaController" version="$SAPHanaControllerVersion">
+<version>1.0</version>
<shortdesc lang="en">Manages two SAP HANA database systems in system replication (SR).</shortdesc>
<longdesc lang="en">
diff --git a/heartbeat/SAPHanaTopology b/heartbeat/SAPHanaTopology
index 05014af..7f6f4d9 100755
--- a/heartbeat/SAPHanaTopology
+++ b/heartbeat/SAPHanaTopology
@@ -132,8 +132,8 @@ function sht_meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
-<resource-agent name="SAPHanaTopology">
- <version>$SAPHanaTopologyVersion</version>
+<resource-agent name="SAPHanaTopology" version="$SAPHanaTopologyVersion">
+ <version>1.0</version>
<shortdesc lang="en">Analyzes SAP HANA System Replication Topology.</shortdesc>
<longdesc lang="en">This RA analyzes the SAP HANA topology and "sends" all findings via the node status attributes to
all nodes in the cluster. These attributes are taken by the SAPHana RA to control the SAP Hana Databases.

View File

@ -29,7 +29,7 @@ Name: resource-agents-sap-hana-scaleout
Summary: SAP HANA Scale-Out cluster resource agents
Epoch: 1
Version: 0.180.0
Release: 1%{?rcver:%{rcver}}%{?numcomm:.%{numcomm}}%{?alphatag:.%{alphatag}}%{?dirty:.%{dirty}}%{?dist}
Release: 4%{?rcver:%{rcver}}%{?numcomm:.%{numcomm}}%{?alphatag:.%{alphatag}}%{?dirty:.%{dirty}}%{?dist}
License: GPLv2+
URL: https://github.com/SUSE/SAPHanaSR-ScaleOut
%if 0%{?fedora} || 0%{?centos_version} || 0%{?rhel}
@ -39,6 +39,10 @@ Group: Productivity/Clustering/HA
%endif
Source0: %{upstream_prefix}-%{upstream_version}.tar.gz
Source1: %{saphana_scaleout_prefix}-%{saphana_scaleout_hash}.tar.gz
Patch0: bz2026278-1-SAPHanaController-SAPHanaTopology-add-systemd-support.patch
Patch1: bz2026278-2-SAPHanaController-SAPHanaTopology-suppress-systemctl-output.patch
Patch2: bz2026278-3-SAPHanaController-SAPHanaTopology-fix-list-unit-files-issue.patch
Patch3: bz2050196-SAPHanaController-SAPHanaTopology-fix-metadata-version.patch
BuildArch: noarch
@ -72,6 +76,11 @@ sed -i -e '/ ocf_heartbeat_SAPInstance.7 \\/a\
cp %{saphana_scaleout_prefix}-%{saphana_scaleout_hash}/SAPHana/doc/LICENSE .
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%build
if [ ! -f configure ]; then
./autogen.sh
@ -148,6 +157,17 @@ rm -rf %{buildroot}
%exclude %{_mandir}/man8/SAPHanaSR-manageAttr.8.gz
%changelog
* Thu Feb 3 2022 Oyvind Albrigtsen <oalbrigt@redhat.com> - 0.180.0-4
- SAPHanaController/SAPHanaTopology: follow OCF standard for version
and OCF version in metadata
Resolves: rhbz#2050196
* Tue Feb 1 2022 Oyvind Albrigtsen <oalbrigt@redhat.com> - 0.180.0-3
- SAPHanaController/SAPHanaTopology: add systemd support
Resolves: rhbz#2026278
* Mon Aug 2 2021 Oyvind Albrigtsen <oalbrigt@redhat.com> - 0.180.0-1
- Add HANA MTR multi-site cluster support