Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

srmode refactoring #117

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions SAPHana/ra/SAPHanaController
Original file line number Diff line number Diff line change
@@ -1286,13 +1286,15 @@ function cleanup_instance() {
function check_for_primary() {
super_ocf_log info "FLOW ${FUNCNAME[0]} ($*)"
local rc=$HANA_STATE_DEFECT
node_full_status=$(HANA_CALL --timeout $HANA_CALL_TIMEOUT --cmd "hdbnsutil -sr_stateConfiguration --sapcontrol=1" 2>/dev/null )
[[ "$node_full_status" =~ "SAPCONTROL-OK: <begin>".*(^|$'\n')"mode="([^$'\n']*).*"SAPCONTROL-OK: <end>" ]] && node_status=${BASH_REMATCH[2]}

super_ocf_log debug "DBG: check_for_primary: node_status=$node_status"
# TODO: PRIO2: Maybe we need to use a fallback interface when hdbnsitil does not answer properly -> lookup in config files?
# This might also solve some problems when we could not figure-out the local or remote site name
for i in 1 2 3; do
node_full_status=$(HANA_CALL --timeout $HANA_CALL_TIMEOUT --cmd "hdbnsutil -sr_stateConfiguration --sapcontrol=1" 2>/dev/null )
[[ "$node_full_status" =~ "SAPCONTROL-OK: <begin>".*(^|$'\n')"mode="([^$'\n']*).*"SAPCONTROL-OK: <end>" ]] && node_status=${BASH_REMATCH[2]}

super_ocf_log debug "DBG: check_for_primary: node_status=$node_status"

case "$node_status" in
primary )
super_ocf_log info "FLOW: ${FUNCNAME[0]} rc=HANA_STATE_PRIMARY"
@@ -1309,13 +1311,11 @@ function check_for_primary() {
dump=$( echo -n $node_status | hexdump -C );
super_ocf_log err "ACT: check_for_primary: we didn't expect node_status to be: DUMP <$dump>"
fi
node_full_status=$(HANA_CALL --timeout $HANA_CALL_TIMEOUT --cmd "hdbnsutil -sr_stateConfiguration --sapcontrol=1" 2>/dev/null )
[[ "$node_full_status" =~ "SAPCONTROL-OK: <begin>".*(^|$'\n')"mode="([^$'\n']*).*"SAPCONTROL-OK: <end>" ]] && node_status=${BASH_REMATCH[2]}
sleep 20
super_ocf_log debug "DEC: check_for_primary: loop=$i: node_status=$node_status"
# TODO: PRIO1: Maybe we need to keep the old value for P/S/N, if hdbnsutil just crashes
;;
esac
sleep 20
done
super_ocf_log info "FLOW ${FUNCNAME[0]} rc=$rc"
return $rc
6 changes: 2 additions & 4 deletions SAPHana/ra/SAPHanaTopology
Original file line number Diff line number Diff line change
@@ -516,8 +516,7 @@ function sht_init() {
done
# TODO PRIO3: Implement a file lookup, if we did not get a result
[[ "$hdbANSWER" =~ "SAPCONTROL-OK: <begin>".*(^|$'\n')"site"."name="([^$'\n']*).*"SAPCONTROL-OK: <end>" ]] && site=${BASH_REMATCH[2]}
[[ "$hdbANSWER" =~ "SAPCONTROL-OK: <begin>".*(^|$'\n')"mode="([^$'\n']*).*"SAPCONTROL-OK: <end>" ]] && srmode=${BASH_REMATCH[2]}


MAPPING=$(echo "$hdbANSWER" | awk -F[=/] '$1 == "mapping" && $2 == myhost && $3 != site { print $4 }' site="$site" myhost=$HOSTNAME)
super_ocf_log debug "DBG: site=$site, mode=$srmode, MAPPING=$MAPPING"
#
@@ -544,7 +543,6 @@ function check_for_primary() {
local rc=0
node_status=$srmode
super_ocf_log debug "DBG: check_for_primary: node_status=$node_status"
super_ocf_log debug "DBG: check_for_primary: node_status=$node_status"
for i in 1 2 3; do
case "$node_status" in
primary )
@@ -566,14 +564,14 @@ function check_for_primary() {
super_ocf_log err "ACT: check_for_primary: we didn't expect node_status to be: DUMP: <$dump>"
fi
#### SAP-CALL
sleep 20
#node_full_status=$(su - ${sidadm} -c "hdbnsutil -sr_state" 2>/dev/null )
node_full_status=$(HANA_CALL --timeout $HANA_CALL_TIMEOUT --cmd "hdbnsutil -sr_stateConfiguration --sapcontrol=1" 2>/dev/null )
[[ "$node_full_status" =~ "SAPCONTROL-OK: <begin>".*(^|$'\n')"mode="([^$'\n']*).*"SAPCONTROL-OK: <end>" ]] && node_status=${BASH_REMATCH[2]}
super_ocf_log info "DEC: check_for_primary: loop=$i: node_status=$node_status"
# TODO: PRIO5: Maybe we need to keep the old value for P/S/N, if hdbnsutil just crashes
;;
esac
sleep 20
done
super_ocf_log info "FLOW ${FUNCNAME[0]} rc=HANA_STATE_DEFECT"
return $HANA_STATE_DEFECT