Skip to content

Commit

Permalink
Merge pull request #118 from PeterPitterling/raHANA-HANA_CALL
Browse files Browse the repository at this point in the history
get rid of redundant HDBSettings.sh call
  • Loading branch information
angelabriel authored Sep 8, 2022
2 parents d46b4a2 + a7fe05c commit 14067d8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
19 changes: 9 additions & 10 deletions ra/SAPHana
Original file line number Diff line number Diff line change
Expand Up @@ -675,15 +675,15 @@ function HANA_CALL()
fi
case $timeOut in
0 | inf )
output=$($pre_cmd "$pre_script; /usr/sap/$SID/$InstanceName/HDBSettings.sh $cmd"); rc=$?
output=$($pre_cmd "$pre_script; $cmd"); rc=$?
;;
* )
errExt=$(date '+%s%N')_${sid}adm
su_err_log=/tmp/HANA_CALL_SU_RA_${errExt}
cmd_out_log=/tmp/HANA_CALL_CMD_RA_OUT_${errExt}
cmd_err_log=/tmp/HANA_CALL_CMD_RA_${errExt}

output=$(timeout --foreground -s 9 "$timeOut" $pre_cmd "($pre_script; timeout -s 9 $timeOut /usr/sap/$SID/$InstanceName/HDBSettings.sh $cmd > $cmd_out_log) >& $cmd_err_log" 2>"$su_err_log"); rc=$?
output=$(timeout --foreground -s 9 "$timeOut" $pre_cmd "($pre_script; timeout -s 9 $timeOut $cmd > $cmd_out_log) >& $cmd_err_log" 2>"$su_err_log"); rc=$?

output=$(if [ -f "$cmd_out_log" ]; then cat "$cmd_out_log"; rm -f "$cmd_out_log"; fi)
suErr=$(if [ -f "$su_err_log" ]; then cat "$su_err_log"; rm -f "$su_err_log"; else echo "NA"; fi)
Expand All @@ -695,7 +695,7 @@ function HANA_CALL()
if [ "$cmdErr" == "NA" ]; then
# seems something was going wrong with the 'pre_cmd' (su)
super_ocf_log warn "DEC: HANA_CALL returned '1' for command '$pre_cmd'. Retry once."
output=$(timeout --foreground -s 9 "$timeOut" $pre_cmd "$pre_script; timeout -s 9 $timeOut /usr/sap/$SID/$InstanceName/HDBSettings.sh $cmd"); rc=$?
output=$(timeout --foreground -s 9 "$timeOut" $pre_cmd "$pre_script; timeout -s 9 $timeOut $cmd"); rc=$?
fi
fi
#
Expand All @@ -706,7 +706,7 @@ function HANA_CALL()
fi
if [ $rc -eq 124 -a -n "$onTimeOut" ]; then
local second_output=""
second_output=$($pre_cmd "$pre_script; /usr/sap/$SID/$InstanceName/HDBSettings.sh $onTimeOut");
second_output=$($pre_cmd "$pre_script; $onTimeOut");
fi
;;
esac
Expand Down Expand Up @@ -1230,7 +1230,7 @@ function check_for_primary() {
# fallback for 'hdbnsutil' failing 3 times.
local gpKeys=""
gpKeys=$(echo --key=global.ini/system_replication/{actual_mode,mode})
node_full_status=$(HANA_CALL --timeout "$HANA_CALL_TIMEOUT" --cmd "HDBSettings.sh getParameter.py $gpKeys --sapcontrol=1" 2>&1 | awk -F/ 'BEGIN {out=0} /^SAPCONTROL-OK: <begin>/ { out=1 } /^SAPCONTROL-OK: <end>/ { out=0 } /=/ {if (out==1) {print $3} }')
node_full_status=$(HANA_CALL --timeout "$HANA_CALL_TIMEOUT" --cmd "cdpy; python getParameter.py $gpKeys --sapcontrol=1" 2>&1 | awk -F/ 'BEGIN {out=0} /^SAPCONTROL-OK: <begin>/ { out=1 } /^SAPCONTROL-OK: <end>/ { out=0 } /=/ {if (out==1) {print $3} }')
# first try to get the value of 'actual_mode' from the global.ini
ini_mode=$(echo "$node_full_status" | awk -F= '$1=="actual_mode" {print $2}')
# if 'actual_mode' is not available, fallback to 'mode'
Expand Down Expand Up @@ -1295,8 +1295,7 @@ function analyze_hana_sync_statusSRS()
# TODO: Check beginning from which SPS does SAP support HDBSettings.sh?
# TODO: Limit the runtime of systemReplicationStatus.py
# SAP_CALL
# FULL_SR_STATUS=$(su - $sidadm -c "python $DIR_EXECUTABLE/python_support/systemReplicationStatus.py $siteParam" 2>/dev/null); srRc=$?
FULL_SR_STATUS=$(HANA_CALL --timeout 5 --cmd "systemReplicationStatus.py $siteParam" 2>/dev/null); srRc=$?
FULL_SR_STATUS=$(HANA_CALL --timeout 5 --cmd "cdpy; python systemReplicationStatus.py $siteParam" 2>/dev/null); srRc=$?
super_ocf_log info "DEC $FUNCNAME systemReplicationStatus.py (to site '$remSR_name')-> $srRc"
super_ocf_log info "FLOW $FUNCNAME systemReplicationStatus.py (to site '$remSR_name')-> $srRc"
#
Expand Down Expand Up @@ -1435,12 +1434,12 @@ function get_hana_landscape_status()
# SAPSYSTEMNAME=SLE /usr/sap/SLE/HDB00/HDBSettings.sh landscapeHostConfiguration.py
# TODO: Check beginning from which SPS does SAP support HDBSettings.sh?
# DONE: Limit the runtime of landscapeHostConfiguration.py
HANA_CALL --timeout "$HANA_CALL_TIMEOUT" --cmd "landscapeHostConfiguration.py" 1>/dev/null 2>/dev/null; rc=$?
HANA_CALL --timeout "$HANA_CALL_TIMEOUT" --cmd "cdpy; python landscapeHostConfiguration.py" 1>/dev/null 2>/dev/null; rc=$?
if [ $rc -eq 124 ]; then
# TODO: PRIO 1: Check, if we should loop here like 'for i in 1 2 3 ...' ?
# landscape timeout
sleep 20
HANA_CALL --timeout "$HANA_CALL_TIMEOUT" --cmd "landscapeHostConfiguration.py" 1>/dev/null 2>/dev/null; rc=$?
HANA_CALL --timeout "$HANA_CALL_TIMEOUT" --cmd "cdpy; python landscapeHostConfiguration.py" 1>/dev/null 2>/dev/null; rc=$?
if [ $rc -eq 124 ]; then
# TODO PRIO2: How to handle still hanging lss - current solution is to say "FATAL"
rc=0
Expand Down Expand Up @@ -2647,7 +2646,7 @@ function saphana_monitor_secondary()
local hanaOut1=""
# TODO: PRIO 3: check, if using getParameter.py is the best option to analyze the set operationMode
# DONE: PRIO 3: Should we default to logreplay for SAP HANA >= SPS11 ?
hanaOut1=$(HANA_CALL --timeout 10 --use-su --cmd "getParameter.py --key=global.ini/system_replication/operation_mode --sapcontrol=1")
hanaOut1=$(HANA_CALL --timeout 10 --use-su --cmd "cdpy; python getParameter.py --key=global.ini/system_replication/operation_mode --sapcontrol=1")
hanaFilter1=$(echo "$hanaOut1" | awk -F/ 'BEGIN {out=0} /^SAPCONTROL-OK: <begin>/ { out=1 } /^SAPCONTROL-OK: <end>/ { out=0 } /=/ {if (out==1) {print $3} }')
hanaOM=$(echo "$hanaFilter1" | awk -F= '$1=="operation_mode" {print $2}')
set_hana_attribute "${NODENAME}" "$hanaOM" "${ATTR_NAME_HANA_OPERATION_MODE[@]}"
Expand Down
18 changes: 9 additions & 9 deletions ra/SAPHanaTopology
Original file line number Diff line number Diff line change
Expand Up @@ -425,15 +425,15 @@ function HANA_CALL()
fi
case $timeOut in
0 | inf )
output=$($pre_cmd "$pre_script; /usr/sap/$SID/$InstanceName/HDBSettings.sh $cmd"); rc=$?
output=$($pre_cmd "$pre_script; $cmd"); rc=$?
;;
* )
errExt=$(date '+%s%N')_${sid}adm
su_err_log=/tmp/HANA_CALL_SU_TOP_${errExt}
cmd_out_log=/tmp/HANA_CALL_CMD_TOP_OUT_${errExt}
cmd_err_log=/tmp/HANA_CALL_CMD_TOP_${errExt}

output=$(timeout "$timeOut" $pre_cmd "($pre_script; /usr/sap/$SID/$InstanceName/HDBSettings.sh $cmd > $cmd_out_log) >& $cmd_err_log" 2>"$su_err_log"); rc=$?
output=$(timeout "$timeOut" $pre_cmd "($pre_script; $cmd > $cmd_out_log) >& $cmd_err_log" 2>"$su_err_log"); rc=$?

output=$(if [ -f "$cmd_out_log" ]; then cat "$cmd_out_log"; rm -f "$cmd_out_log"; fi)
suErr=$(if [ -f "$su_err_log" ]; then cat "$su_err_log"; rm -f "$su_err_log"; else echo "NA"; fi)
Expand All @@ -445,7 +445,7 @@ function HANA_CALL()
if [ "$cmdErr" == "NA" ]; then
# seems something was going wrong with the 'pre_cmd' (su)
super_ocf_log warn "DEC: HANA_CALL returned '1' for command '$pre_cmd'. Retry once."
output=$(timeout "$timeOut" $pre_cmd "$pre_script; /usr/sap/$SID/$InstanceName/HDBSettings.sh $cmd"); rc=$?
output=$(timeout "$timeOut" $pre_cmd "$pre_script; $cmd"); rc=$?
fi
fi
#
Expand All @@ -456,7 +456,7 @@ function HANA_CALL()
fi
if [ $rc -eq 124 -a -n "$onTimeOut" ]; then
local second_output=""
second_output=$($pre_cmd "$pre_script; /usr/sap/$SID/$InstanceName/HDBSettings.sh $onTimeOut");
second_output=$($pre_cmd "$pre_script; $onTimeOut");
fi
;;
esac
Expand Down Expand Up @@ -586,7 +586,7 @@ function sht_init() {
gP ) # call getParameter (gP)
local gpKeys=""
gpKeys=$(echo --key=global.ini/system_replication/{actual_mode,mode,site_name,site_id})
hdbANSWER=$(HANA_CALL --timeout "$HANA_CALL_TIMEOUT" --cmd "HDBSettings.sh getParameter.py $gpKeys --sapcontrol=1" 2>&1 | awk -F/ 'BEGIN {out=0} /^SAPCONTROL-OK: <begin>/ { out=1 } /^SAPCONTROL-OK: <end>/ { out=0 } /=/ {if (out==1) {print $3} }')
hdbANSWER=$(HANA_CALL --timeout "$HANA_CALL_TIMEOUT" --cmd "cdpy; python getParameter.py $gpKeys --sapcontrol=1" 2>&1 | awk -F/ 'BEGIN {out=0} /^SAPCONTROL-OK: <begin>/ { out=1 } /^SAPCONTROL-OK: <end>/ { out=0 } /=/ {if (out==1) {print $3} }')
srmode=$(echo "$hdbANSWER" | awk -F= '$1=="actual_mode" {print $2}')
# if 'actual_mode' is not available, fallback to 'mode'
if [ -z "$srmode" ]; then
Expand Down Expand Up @@ -1036,11 +1036,11 @@ function sht_monitor_clone() {
#
setRole=true
if version "$hdbver" ">=" "1.00.100"; then
hanaANSWER=$(HANA_CALL --timeout "$HANA_CALL_TIMEOUT" --cmd "landscapeHostConfiguration.py --sapcontrol=1" 2>/dev/null); hanalrc="$?"
hanaANSWER=$(HANA_CALL --timeout "$HANA_CALL_TIMEOUT" --cmd "cdpy; python landscapeHostConfiguration.py --sapcontrol=1" 2>/dev/null); hanalrc="$?"
# retry command, if a timeout occurred
if [ "$hanalrc" -ge 124 ]; then
super_ocf_log warn "HANA_CALL timed out after $HANA_CALL_TIMEOUT seconds running command 'landscapeHostConfiguration.py --sapcontrol=1'. Retrying..."
hanaANSWER=$(HANA_CALL --timeout "$HANA_CALL_TIMEOUT" --cmd "landscapeHostConfiguration.py --sapcontrol=1" 2>/dev/null); hanalrc="$?"
hanaANSWER=$(HANA_CALL --timeout "$HANA_CALL_TIMEOUT" --cmd "cdpy; python landscapeHostConfiguration.py --sapcontrol=1" 2>/dev/null); hanalrc="$?"
# if the second try again run into a timeout, log an error and do not set hanarole but keep the previous settings.
if [ "$hanalrc" -ge 124 ]; then
super_ocf_log err "HANA_CALL Operation timeout after $HANA_CALL_TIMEOUT seconds running command 'landscapeHostConfiguration.py --sapcontrol=1'."
Expand All @@ -1059,11 +1059,11 @@ function sht_monitor_clone() {
#
# old code for backward compatibility
#
hanaANSWER=$(HANA_CALL --timeout "$HANA_CALL_TIMEOUT" --cmd "landscapeHostConfiguration.py" 2>/dev/null); hanalrc="$?"
hanaANSWER=$(HANA_CALL --timeout "$HANA_CALL_TIMEOUT" --cmd "cdpy; python landscapeHostConfiguration.py" 2>/dev/null); hanalrc="$?"
# retry command, if a timeout occurred
if [ "$hanalrc" -ge 124 ]; then
super_ocf_log warn "HANA_CALL timed out after $HANA_CALL_TIMEOUT seconds running command 'landscapeHostConfiguration.py'. Retrying..."
hanaANSWER=$(HANA_CALL --timeout "$HANA_CALL_TIMEOUT" --cmd "landscapeHostConfiguration.py" 2>/dev/null); hanalrc="$?"
hanaANSWER=$(HANA_CALL --timeout "$HANA_CALL_TIMEOUT" --cmd "cdpy; python landscapeHostConfiguration.py" 2>/dev/null); hanalrc="$?"
# if the second try again run into a timeout, log an error and do not set hanarole but keep the previous settings.
if [ "$hanalrc" -ge 124 ]; then
super_ocf_log err "HANA_CALL Operation timeout after $HANA_CALL_TIMEOUT seconds running command 'landscapeHostConfiguration.py'."
Expand Down

0 comments on commit 14067d8

Please sign in to comment.