Files
freenas-proxmox/tests/stubs/systemctl
T
Kevin AdamsandClaude Sonnet 5 d60adfaaf7 fix: restart HA daemons on install/remove; add regression test (#179)
pvedaemon/pveproxy picked up the patched PVE::Storage state, but
pve-ha-lrm/pve-ha-crm kept running against the pre-install state, so
HA-managed VMs on TrueNAS storage failed to start. They don't support
a `restart` subcommand (only start/stop/status), so they're restarted
via systemctl instead. Also switched every restart from `cmd && log
...` to bare statements — set -e does not fire on the left side of
&&, so a genuine restart failure was previously swallowed silently
instead of aborting the script.

Adds tests/test-restart-services.sh: sources the real postinst/postrm
against stub PVE binaries in CI to catch both classes of regression
(wrong subcommand, silently-swallowed failure) without needing a live
PVE cluster. Real HA-cluster validation is documented as a manual
runbook (RUNBOOK-001) since GitHub Actions can't run pve-ha-lrm/crm.

Bumps $VERSION to 3.2.4.

Fixes #179

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-01 17:57:46 -04:00

26 lines
732 B
Bash

#!/bin/bash
# Stub for systemctl, scoped to what restart_pve_services() actually calls:
# `systemctl restart <unit> [<unit>...]` against known PVE service units.
KNOWN_UNITS="pvedaemon pveproxy pvestatd pve-ha-lrm pve-ha-crm"
case "$1" in
restart)
shift
if [[ $# -eq 0 ]]; then
echo "systemctl: restart requires at least one unit" >&2
exit 1
fi
for unit in "$@"; do
if [[ ! " $KNOWN_UNITS " =~ \ ${unit}\ ]]; then
echo "systemctl: unknown unit '${unit}'" >&2
exit 1
fi
done
exit 0
;;
*)
echo "systemctl: unsupported command '$1' in test stub" >&2
exit 1
;;
esac