Shadow database demotion checks from native path
This commit is contained in:
@@ -29,6 +29,59 @@ mc_peer_write_recovery \"\$PGDATA\" \"\$1\" \"\$2\" \"\$3\" \"\$4\" \"\$5\"" sh
|
||||
"${REPLICATION_USER}" "${OCF_RESKEY_CRM_meta_on_node:-$(hostname)}" "${REPLICATION_SLOT}"
|
||||
}
|
||||
|
||||
mc_pg_demote_database_shadow()
|
||||
{
|
||||
local socket_path resource response rc
|
||||
|
||||
socket_path="${MC_PROXY_SOCKET:-/run/user/1000/managed-containerd/managed-containerd.sock}"
|
||||
resource="${OCF_RESOURCE_INSTANCE:-}"
|
||||
resource="${resource%%:*}"
|
||||
|
||||
[ -n "${resource}" ] || return 0
|
||||
|
||||
response="$(
|
||||
timeout --kill-after=1s 5s \
|
||||
python3 \
|
||||
"${MC_PROXY_CLIENT:-/usr/lib/ocf/resource.d/loxthelion/managed-container.d/proxy_client.py}" \
|
||||
"${socket_path}" \
|
||||
"${resource}" \
|
||||
"demote.database" \
|
||||
10 \
|
||||
11
|
||||
)"
|
||||
rc=$?
|
||||
|
||||
if [ "${rc}" -ne 0 ]; then
|
||||
ocf_log warn \
|
||||
"managed-containerd demote.database shadow unavailable rc=${rc}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if MC_DAEMON_RESPONSE="${response}" python3 -c '
|
||||
import json
|
||||
import os
|
||||
|
||||
response = json.loads(os.environ["MC_DAEMON_RESPONSE"])
|
||||
|
||||
if (
|
||||
response.get("ocf_rc") != 0
|
||||
or response.get("ready") is not True
|
||||
or response.get("mutation") is not False
|
||||
or response.get("final_handoff_required") is not True
|
||||
):
|
||||
raise SystemExit(1)
|
||||
'; then
|
||||
ocf_log info \
|
||||
"managed-containerd demote.database shadow: comparison=MATCH response=${response}"
|
||||
else
|
||||
ocf_log err \
|
||||
"managed-containerd demote.database shadow MISMATCH response=${response}"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
mc_pg_native_demote()
|
||||
(
|
||||
local mc_native_started=${SECONDS}
|
||||
@@ -100,6 +153,8 @@ mc_pg_native_demote()
|
||||
return "${OCF_ERR_GENERIC}"
|
||||
}
|
||||
|
||||
mc_pg_demote_database_shadow
|
||||
|
||||
if [ "$(printf '%s' "${target_node}" | tr '[:upper:]' '[:lower:]')" = \
|
||||
"$(printf '%s' "${local_node}" | tr '[:upper:]' '[:lower:]')" ]; then
|
||||
self_restart=true
|
||||
|
||||
Reference in New Issue
Block a user