mirror of
https://github.com/TheGrandWazoo/freenas-proxmox.git
synced 2026-10-18 04:42:20 +02:00
fix: restart HA daemons in truenas-proxmox-multipath postinst/postrm
Same root cause as #179: postinst/postrm only restarted pvedaemon/pveproxy, never pvestatd/pve-ha-lrm/pve-ha-crm, so HA-managed VMs on truenas-multipath storage could fail to start after install/upgrade. Mirrors the #179 fix — bare statements so set -e aborts on a real failure, HA daemons restarted via systemctl (they don't support a restart subcommand). Extended test-restart-services.sh to cover both multipath scripts with the same stub approach. Fixes #287 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
0070bb78e8
commit
92c8beafe3
@@ -87,26 +87,38 @@ STANZA
|
||||
}
|
||||
|
||||
restart_pve_services() {
|
||||
# Bare statements (not `cmd && log ...`) so `set -e` actually aborts on
|
||||
# failure instead of silently skipping past it — see tests/test-restart-services.sh.
|
||||
log "Restarting Proxmox VE services ..."
|
||||
pvedaemon restart && log "pvedaemon restarted"
|
||||
pveproxy restart && log "pveproxy restarted"
|
||||
pvedaemon restart
|
||||
log "pvedaemon restarted"
|
||||
pveproxy restart
|
||||
log "pveproxy restarted"
|
||||
pvestatd restart
|
||||
log "pvestatd restarted"
|
||||
systemctl restart pve-ha-lrm pve-ha-crm
|
||||
log "pve-ha-lrm, pve-ha-crm restarted"
|
||||
log "Done. Refresh your Proxmox browser tab."
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
configure)
|
||||
log "Configuring truenas-proxmox-multipath (previous version: ${2:-none})"
|
||||
install_plugin
|
||||
install_ui
|
||||
install_multipath_conf
|
||||
restart_pve_services
|
||||
;;
|
||||
abort-upgrade|abort-remove|abort-deconfigure)
|
||||
;;
|
||||
*)
|
||||
echo "$0: called with unknown argument '$1'" >&2
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
# Guard so tests can `source` this file (to exercise its functions) without
|
||||
# running dpkg's maintainer-script logic below.
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
case "$1" in
|
||||
configure)
|
||||
log "Configuring truenas-proxmox-multipath (previous version: ${2:-none})"
|
||||
install_plugin
|
||||
install_ui
|
||||
install_multipath_conf
|
||||
restart_pve_services
|
||||
;;
|
||||
abort-upgrade|abort-remove|abort-deconfigure)
|
||||
;;
|
||||
*)
|
||||
echo "$0: called with unknown argument '$1'" >&2
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -14,41 +14,57 @@ log() {
|
||||
echo "[truenas-proxmox-multipath] $*" | tee -a "$LOG_FILE"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
remove|purge)
|
||||
if [ -f "$PLUGIN_DST" ]; then
|
||||
log "Removing ${PLUGIN_DST}"
|
||||
rm -f "$PLUGIN_DST"
|
||||
fi
|
||||
restart_pve_services() {
|
||||
# Bare statements (not `cmd && log ...`) so `set -e` actually aborts on
|
||||
# failure instead of silently skipping past it — see tests/test-restart-services.sh.
|
||||
log "Restarting Proxmox VE services ..."
|
||||
pvedaemon restart
|
||||
log "pvedaemon restarted"
|
||||
pveproxy restart
|
||||
log "pveproxy restarted"
|
||||
pvestatd restart
|
||||
log "pvestatd restarted"
|
||||
systemctl restart pve-ha-lrm pve-ha-crm
|
||||
log "pve-ha-lrm, pve-ha-crm restarted"
|
||||
}
|
||||
|
||||
if [ -f "$JS_DST" ]; then
|
||||
log "Removing ${JS_DST}"
|
||||
rm -f "$JS_DST"
|
||||
fi
|
||||
# Guard so tests can `source` this file (to exercise its functions) without
|
||||
# running dpkg's maintainer-script logic below.
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
case "$1" in
|
||||
remove|purge)
|
||||
if [ -f "$PLUGIN_DST" ]; then
|
||||
log "Removing ${PLUGIN_DST}"
|
||||
rm -f "$PLUGIN_DST"
|
||||
fi
|
||||
|
||||
if [ -f "$TPL" ] && grep -qF 'truenas-multipath.js' "$TPL" 2>/dev/null; then
|
||||
log "Removing <script> tag from ${TPL}"
|
||||
sed -i '/truenas-multipath\.js/d' "$TPL"
|
||||
fi
|
||||
if [ -f "$JS_DST" ]; then
|
||||
log "Removing ${JS_DST}"
|
||||
rm -f "$JS_DST"
|
||||
fi
|
||||
|
||||
if [ -f "$MULTIPATH_CONF" ] && grep -qF "$BLOCK_BEGIN" "$MULTIPATH_CONF"; then
|
||||
log "Removing TrueNAS stanza from ${MULTIPATH_CONF}"
|
||||
perl -i -0777 -pe \
|
||||
"s|\n?\Q${BLOCK_BEGIN}\E.*?\Q${BLOCK_END}\E\n?||s" \
|
||||
"$MULTIPATH_CONF"
|
||||
fi
|
||||
if [ -f "$TPL" ] && grep -qF 'truenas-multipath.js' "$TPL" 2>/dev/null; then
|
||||
log "Removing <script> tag from ${TPL}"
|
||||
sed -i '/truenas-multipath\.js/d' "$TPL"
|
||||
fi
|
||||
|
||||
log "Restarting Proxmox VE services ..."
|
||||
if pvedaemon restart 2>/dev/null; then log "pvedaemon restarted"; fi
|
||||
if pveproxy restart 2>/dev/null; then log "pveproxy restarted"; fi
|
||||
log "Done."
|
||||
;;
|
||||
upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
|
||||
;;
|
||||
*)
|
||||
echo "$0: called with unknown argument '$1'" >&2
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
if [ -f "$MULTIPATH_CONF" ] && grep -qF "$BLOCK_BEGIN" "$MULTIPATH_CONF"; then
|
||||
log "Removing TrueNAS stanza from ${MULTIPATH_CONF}"
|
||||
perl -i -0777 -pe \
|
||||
"s|\n?\Q${BLOCK_BEGIN}\E.*?\Q${BLOCK_END}\E\n?||s" \
|
||||
"$MULTIPATH_CONF"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
restart_pve_services
|
||||
log "Done."
|
||||
;;
|
||||
upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
|
||||
;;
|
||||
*)
|
||||
echo "$0: called with unknown argument '$1'" >&2
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -44,6 +44,8 @@ run_case() {
|
||||
|
||||
run_case "${REPO_ROOT}/packaging/DEBIAN/postinst" "postinst"
|
||||
run_case "${REPO_ROOT}/packaging/DEBIAN/postrm" "postrm"
|
||||
run_case "${REPO_ROOT}/packaging/DEBIAN-multipath/postinst" "multipath postinst"
|
||||
run_case "${REPO_ROOT}/packaging/DEBIAN-multipath/postrm" "multipath postrm"
|
||||
|
||||
# Failure-propagation check: a failing restart must abort the function (and
|
||||
# thus the maintainer script under `set -e`), not be silently swallowed.
|
||||
@@ -80,5 +82,7 @@ run_failure_case() {
|
||||
|
||||
run_failure_case "${REPO_ROOT}/packaging/DEBIAN/postinst" "postinst"
|
||||
run_failure_case "${REPO_ROOT}/packaging/DEBIAN/postrm" "postrm"
|
||||
run_failure_case "${REPO_ROOT}/packaging/DEBIAN-multipath/postinst" "multipath postinst"
|
||||
run_failure_case "${REPO_ROOT}/packaging/DEBIAN-multipath/postrm" "multipath postrm"
|
||||
|
||||
echo "All restart_pve_services() tests passed."
|
||||
|
||||
Reference in New Issue
Block a user