From 92c8beafe33e433a488820df9d1faed9887ed5af Mon Sep 17 00:00:00 2001 From: Kevin Adams Date: Sun, 23 Aug 2026 14:28:32 -0400 Subject: [PATCH] fix: restart HA daemons in truenas-proxmox-multipath postinst/postrm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- packaging/DEBIAN-multipath/postinst | 48 ++++++++++------- packaging/DEBIAN-multipath/postrm | 82 +++++++++++++++++------------ tests/test-restart-services.sh | 4 ++ 3 files changed, 83 insertions(+), 51 deletions(-) diff --git a/packaging/DEBIAN-multipath/postinst b/packaging/DEBIAN-multipath/postinst index 8c0cd67..31290f8 100644 --- a/packaging/DEBIAN-multipath/postinst +++ b/packaging/DEBIAN-multipath/postinst @@ -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 diff --git a/packaging/DEBIAN-multipath/postrm b/packaging/DEBIAN-multipath/postrm index eb5b943..f4d80a5 100644 --- a/packaging/DEBIAN-multipath/postrm +++ b/packaging/DEBIAN-multipath/postrm @@ -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