Shadow daemon notification target during demotion
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
10932919c4339b553c7c9dbf30b45a917c51c0a08f362e12678003d58b12fa82 ocf/loxthelion/managed-container.d/applications/postgresql/auth.sh
|
10932919c4339b553c7c9dbf30b45a917c51c0a08f362e12678003d58b12fa82 ocf/loxthelion/managed-container.d/applications/postgresql/auth.sh
|
||||||
61d64b4a3a15c354f101ef34c5dc0425723f4204207d359b5377d2b9f04f6b23 ocf/loxthelion/managed-container.d/applications/postgresql/demote.sh
|
61d64b4a3a15c354f101ef34c5dc0425723f4204207d359b5377d2b9f04f6b23 ocf/loxthelion/managed-container.d/applications/postgresql/demote.sh
|
||||||
38323b217204132e572a9b1cfec8072773e502e49d6f0f96dfa2e565d332bbd1 ocf/loxthelion/managed-container.d/applications/postgresql/native_peers.sh
|
38323b217204132e572a9b1cfec8072773e502e49d6f0f96dfa2e565d332bbd1 ocf/loxthelion/managed-container.d/applications/postgresql/native_peers.sh
|
||||||
54b10636f26f57691a1467c660682643c458bb8b5e8945bdab3d5caa4a5f3fb5 ocf/loxthelion/managed-container.d/applications/postgresql/notify.sh
|
bcfde96b98f4727a8c97d42a39b7c6ec925b1b89d17ef67cc58eb7bd67afbfae ocf/loxthelion/managed-container.d/applications/postgresql/notify.sh
|
||||||
957a5a72ed277d0216e070abb80733483be3d421b9fa488e27fdd75bb2919548 ocf/loxthelion/managed-container.d/applications/postgresql/peer_config.sh
|
957a5a72ed277d0216e070abb80733483be3d421b9fa488e27fdd75bb2919548 ocf/loxthelion/managed-container.d/applications/postgresql/peer_config.sh
|
||||||
5091bc554915d1450fe939f94c0b0a370fecdb2ae5db9c4f0f55c340c0145519 ocf/loxthelion/managed-container.d/applications/postgresql/plugin.sh
|
5091bc554915d1450fe939f94c0b0a370fecdb2ae5db9c4f0f55c340c0145519 ocf/loxthelion/managed-container.d/applications/postgresql/plugin.sh
|
||||||
c1d878dabf22ad3928d66a5542bda3c150e5e9b039926629e7c5fd3401d29be4 ocf/loxthelion/managed-container.d/applications/postgresql/postgres.sh
|
c1d878dabf22ad3928d66a5542bda3c150e5e9b039926629e7c5fd3401d29be4 ocf/loxthelion/managed-container.d/applications/postgresql/postgres.sh
|
||||||
@@ -23,9 +23,10 @@ a42bb59a058ffeb59c1baa96e403856910bbbaea98f9104ff93daf4b5970c780 postgres-host/
|
|||||||
957a5a72ed277d0216e070abb80733483be3d421b9fa488e27fdd75bb2919548 postgres-host/postgres-ha-peer-config.sh
|
957a5a72ed277d0216e070abb80733483be3d421b9fa488e27fdd75bb2919548 postgres-host/postgres-ha-peer-config.sh
|
||||||
deb09e3ae40629f43b262ba4f9a7ebf59a1dca3da9d8c94478f670aea28bd0e1 quadlet/postgres.container
|
deb09e3ae40629f43b262ba4f9a7ebf59a1dca3da9d8c94478f670aea28bd0e1 quadlet/postgres.container
|
||||||
04a125068677bbee6e71d313ca9d95d35faa32851b79de781cd7b9f466561445 quadlet/postgres.env.example
|
04a125068677bbee6e71d313ca9d95d35faa32851b79de781cd7b9f466561445 quadlet/postgres.env.example
|
||||||
81dada1b948cf47a80521eb59761ea9d0b36a8c2b10f48fb0aea637b64de9adf tests/run-all.sh
|
cd883d7defcbdd8911aece12160122efd896a47661d1ab86f676ee3d56733b3e tests/run-all.sh
|
||||||
5e5d4fdd2b6c7e0b8b146de7aad06c1f96b221a10fec525b00d40e0d85709fb0 tests/test-entrypoint-structure.sh
|
5e5d4fdd2b6c7e0b8b146de7aad06c1f96b221a10fec525b00d40e0d85709fb0 tests/test-entrypoint-structure.sh
|
||||||
2faee72cf2fdcbfa667c3e1c2a7aabc053b96a9b8127ff7440ddb717fd2dc314 tests/test-notify-daemon-shadow.sh
|
2faee72cf2fdcbfa667c3e1c2a7aabc053b96a9b8127ff7440ddb717fd2dc314 tests/test-notify-daemon-shadow.sh
|
||||||
|
9150004af86a819d7d1b5ae2b3fa9d4ddd0480f55babd094137052109864b057 tests/test-notify-target-shadow.sh
|
||||||
b83f0415c09f0be34c51722370e5b07c51b9a9756d305d3b3f50827f484aa4dd tests/test-proxy-client-actions.py
|
b83f0415c09f0be34c51722370e5b07c51b9a9756d305d3b3f50827f484aa4dd tests/test-proxy-client-actions.py
|
||||||
cc4482d229805c64d7df258a8a82984f244128d27fff4ea43b36caa004b56bef tests/test-proxy-client-parameters.py
|
cc4482d229805c64d7df258a8a82984f244128d27fff4ea43b36caa004b56bef tests/test-proxy-client-parameters.py
|
||||||
c3b988d7b2b1b138bb2530df9172f96bb0f5edc2f1561f38f0055695f4126134 tests/test-proxy-protocol.sh
|
c3b988d7b2b1b138bb2530df9172f96bb0f5edc2f1561f38f0055695f4126134 tests/test-proxy-protocol.sh
|
||||||
|
|||||||
@@ -1,5 +1,69 @@
|
|||||||
# Sourced by managed-container; uses the shared OCF and parameter environment.
|
# 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()
|
mc_pg_demote_notification_target()
|
||||||
{
|
{
|
||||||
local allow_self="${1:-false}"
|
local allow_self="${1:-false}"
|
||||||
@@ -43,6 +107,8 @@ mc_pg_demote_notification_target()
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
mc_pg_notify_target_daemon_shadow "${local_node}" "${promote_uname}"
|
||||||
|
|
||||||
printf '%s\n' "${promote_uname}"
|
printf '%s\n' "${promote_uname}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ echo ">>> Generic proxy client actions"
|
|||||||
python3 ./tests/test-proxy-client-actions.py
|
python3 ./tests/test-proxy-client-actions.py
|
||||||
python3 ./tests/test-proxy-client-parameters.py
|
python3 ./tests/test-proxy-client-parameters.py
|
||||||
./tests/test-notify-daemon-shadow.sh
|
./tests/test-notify-daemon-shadow.sh
|
||||||
|
./tests/test-notify-target-shadow.sh
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo ">>> Python syntax"
|
echo ">>> Python syntax"
|
||||||
|
|||||||
Executable
+13
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT="$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)"
|
||||||
|
FILE="$ROOT/ocf/loxthelion/managed-container.d/applications/postgresql/notify.sh"
|
||||||
|
|
||||||
|
grep -q '^mc_pg_notify_target_daemon_shadow()' "$FILE"
|
||||||
|
grep -q '"notify.target"' "$FILE"
|
||||||
|
grep -q 'MC_EXPECTED_SUCCESSOR' "$FILE"
|
||||||
|
grep -q 'comparison=MATCH' "$FILE"
|
||||||
|
grep -q 'notify.target shadow MISMATCH' "$FILE"
|
||||||
|
|
||||||
|
echo "NOTIFY_TARGET_SHADOW_TEST_PASS=1"
|
||||||
Reference in New Issue
Block a user