Shadow daemon notification target during demotion
This commit is contained in:
@@ -1,5 +1,69 @@
|
||||
# Sourced by managed-container; uses the shared OCF and parameter environment.
|
||||
|
||||
mc_pg_notify_target_daemon_shadow()
|
||||
{
|
||||
local expected_node="$1"
|
||||
local expected_successor="$2"
|
||||
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 3s \
|
||||
python3 \
|
||||
"${MC_PROXY_CLIENT:-/usr/lib/ocf/resource.d/loxthelion/managed-container.d/proxy_client.py}" \
|
||||
"${socket_path}" \
|
||||
"${resource}" \
|
||||
"notify.target" \
|
||||
10 \
|
||||
11
|
||||
)"
|
||||
rc=$?
|
||||
|
||||
if [ "${rc}" -ne 0 ]; then
|
||||
ocf_log warn \
|
||||
"managed-containerd notify.target shadow unavailable rc=${rc}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if MC_DAEMON_RESPONSE="${response}" \
|
||||
MC_EXPECTED_NODE="${expected_node}" \
|
||||
MC_EXPECTED_SUCCESSOR="${expected_successor}" \
|
||||
python3 -c '
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
try:
|
||||
response = json.loads(os.environ["MC_DAEMON_RESPONSE"])
|
||||
except (KeyError, TypeError, json.JSONDecodeError):
|
||||
raise SystemExit(1)
|
||||
|
||||
if (
|
||||
response.get("ocf_rc") != 0
|
||||
or response.get("target") is not True
|
||||
or response.get("target_node", "").lower()
|
||||
!= os.environ["MC_EXPECTED_NODE"].lower()
|
||||
or response.get("successor_node", "").lower()
|
||||
!= os.environ["MC_EXPECTED_SUCCESSOR"].lower()
|
||||
):
|
||||
raise SystemExit(1)
|
||||
'; then
|
||||
ocf_log info \
|
||||
"managed-containerd notify.target shadow: comparison=MATCH target=${expected_node} successor=${expected_successor}"
|
||||
else
|
||||
ocf_log err \
|
||||
"managed-containerd notify.target shadow MISMATCH: expected_target=${expected_node} expected_successor=${expected_successor} response=${response}"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
mc_pg_demote_notification_target()
|
||||
{
|
||||
local allow_self="${1:-false}"
|
||||
@@ -43,6 +107,8 @@ mc_pg_demote_notification_target()
|
||||
return 1
|
||||
fi
|
||||
|
||||
mc_pg_notify_target_daemon_shadow "${local_node}" "${promote_uname}"
|
||||
|
||||
printf '%s\n' "${promote_uname}"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user