Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Keep rollback replacement portable and model its stop boundary

pulse-triage[bot]cf92426ec1c0
diff --git a/scripts/installtests/pulse_auto_update_test.go b/scripts/installtests/pulse_auto_update_test.go
index 90e045e699..667a5faf4a 100644
--- a/scripts/installtests/pulse_auto_update_test.go
+++ b/scripts/installtests/pulse_auto_update_test.go
@@ -450,6 +450,7 @@ systemctl() {
SERVICE_UP="yes"
return 0
;;
+ stop) SERVICE_UP="no"; return 0 ;;
esac
return 1
}
@@ -733,6 +734,7 @@ command ssh-keygen -Y sign -f "$FIXTURE_DIR/fixture-key" -n pulse-install "$FIXT
log() { printf '[%s] %s\n' "$1" "${*:2}"; }
detect_service_name() { printf 'pulse\n'; }
sleep() { :; }
+file_mode() { command stat -c '%a' "$1" 2>/dev/null || command stat -f '%Lp' "$1"; }
# Keep real crypto but place all temporary files inside this disposable fixture.
mktemp() {
local -a args=("$@")
@@ -831,7 +833,7 @@ fi
backup=""; [[ ! -f "$FIXTURE_DIR/backup-path" ]] || backup=$(cat "$FIXTURE_DIR/backup-path")
if [[ "$RETAINED" == true ]]; then
[[ -d "$backup" ]] || { echo 'rollback backup lost after failed recovery'; exit 1; }
- [[ "$(stat -c '%a' "$backup")" == 700 ]]
+ [[ "$(file_mode "$backup")" == 700 ]]
cmp "$FIXTURE_DIR/original/pulse-bin" "$backup/pulse-bin"
cmp "$FIXTURE_DIR/original/VERSION" "$backup/VERSION"
else
@@ -854,11 +856,11 @@ if [[ "$PREFLIGHT" != true && "$RETAINED" != true && "$EXPECTED_RESULT" != succe
[[ ! -e "$INSTALL_DIR/VERSION" ]]
else
cmp "$FIXTURE_DIR/original/VERSION" "$INSTALL_DIR/VERSION"
- [[ "$(stat -c '%a' "$INSTALL_DIR/VERSION")" == 640 ]]
+ [[ "$(file_mode "$INSTALL_DIR/VERSION")" == 640 ]]
fi
[[ "$(get_current_version)" == v6.4.5 ]]
binary="$INSTALL_DIR/bin/pulse"; [[ "$LAYOUT" != legacy ]] || binary="$INSTALL_DIR/pulse"
- [[ "$(stat -c '%a' "$binary")" == 751 ]]
+ [[ "$(file_mode "$binary")" == 751 ]]
[[ "$(cat "$FIXTURE_DIR/active")" == "$PRIOR_ACTIVE" ]]
fi
if [[ "$EXPECTED_RESULT" == success ]]; then [[ "$(get_current_version)" == v6.5.0 ]]; fi
diff --git a/scripts/pulse-auto-update.sh b/scripts/pulse-auto-update.sh
index b965e9b42e..d8ee4596ae 100755
--- a/scripts/pulse-auto-update.sh
+++ b/scripts/pulse-auto-update.sh
@@ -552,7 +552,7 @@ perform_update() {
done
for i in "${!file_paths[@]}"; do
if [[ "${file_present[i]}" == "true" ]]; then
- if ! mv -fT -- "${restore_files[i]}" "${file_paths[i]}"; then
+ if [[ -d "${file_paths[i]}" ]] || ! mv -f -- "${restore_files[i]}" "${file_paths[i]}"; then
log error "Could not restore ${file_paths[i]}; backup retained at $backup_dir; manual recovery required"
return 1
fi
diff --git a/scripts/tests/test-pulse-auto-update.sh b/scripts/tests/test-pulse-auto-update.sh
index f3dad3b785..a929815ddb 100755
--- a/scripts/tests/test-pulse-auto-update.sh
+++ b/scripts/tests/test-pulse-auto-update.sh
@@ -170,6 +170,9 @@ INSTALLER
# never comes back up; start also fails -> perform_update must restore + fail.
local is_active_calls=0
systemctl() {
+ # The rollback must stop the service before replacing its executable.
+ # Stopping succeeds; only activation/liveness is the injected failure.
+ if [[ "$1" == "stop" ]]; then return 0; fi
if [[ "$1" == "is-active" ]]; then
((is_active_calls += 1))
if (( is_active_calls == 1 )); then
@@ -230,6 +233,7 @@ test_ensure_service_restarted_starts_stopped_service() {
ENSURE_TEST_UP="yes"
return 0
;;
+ stop) AUTOUPDATE_TEST_UP="no"; return 0 ;;
esac
return 1
}