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.

Preserve archive metadata during verified updater recovery

pulse-triage[bot]3e69c6706cdd
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index 5445c00444..44c5428910 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -6424,7 +6424,9 @@ path without following a new symlink or treating a directory as a destination.
Every restored destination must itself be regular and byte-equal to its saved
copy before recovery may activate the service or discard the backup.
Files absent before the attempt remain absent after recovery, including the
-legacy/current binary alternative and `VERSION`. Metadata is preserved. A
+legacy/current binary alternative and `VERSION`. Archive copies preserve modes,
+ownership, timestamps and extended attributes supported by the filesystem; a
+content-only copy is not the metadata recovery contract. A
partial restore must not invoke the RETURN restart backstop. The backup remains
with a manual-recovery diagnostic if stop, staging, replacement, absence restore
or prior-active service recovery fails. It is discarded only after complete
@@ -6442,7 +6444,8 @@ Verification: `scripts/installtests/pulse_auto_update_test.go`
conditional caller with locally signed installers, real executable version reads
and file operations, and bounded fake download/systemd boundaries. It covers
snapshot admission, all three original failure paths, both binary layouts and
-absence, retained recovery failures, symlink/directory replacement, file modes,
+absence, retained recovery failures, symlink/directory/non-regular replacement,
+file modes and an explicit extended-attribute fixture (unavailability is a skip),
prior-active-only restoration, configuration/identity preservation and trap
cleanup. Exact-parent negative controls must reject ignored snapshot failures
and loss of the backup after a failed restore. Synthetic proof is not a deployed
diff --git a/scripts/installtests/pulse_auto_update_test.go b/scripts/installtests/pulse_auto_update_test.go
index bc4373b161..861a8b911e 100644
--- a/scripts/installtests/pulse_auto_update_test.go
+++ b/scripts/installtests/pulse_auto_update_test.go
@@ -639,6 +639,7 @@ func TestAutoUpdateBackupTransaction(t *testing.T) {
{name: "installer_failure", outcome: "failure"},
{name: "wrong_version", outcome: "mismatch"},
{name: "original_version_absent", outcome: "failure", noVersion: true},
+ {name: "extended_metadata", fault: "xattrs", outcome: "failure"},
{name: "legacy_layout_migration", outcome: "failure", layout: "legacy"},
{name: "both_binary_paths", outcome: "failure", layout: "both"},
{name: "new_destination_symlink", outcome: "symlink"},
@@ -648,6 +649,7 @@ func TestAutoUpdateBackupTransaction(t *testing.T) {
{name: "corrupt_rollback_copy", fault: "restore_corrupt", outcome: "failure", retained: true},
{name: "rollback_rename_failure", fault: "restore_rename", outcome: "failure", retained: true},
{name: "rollback_rename_noop", fault: "restore_noop", outcome: "failure", retained: true},
+ {name: "rollback_nonregular_destination", fault: "restore_noop", outcome: "fifo", retained: true},
{name: "rollback_destination_changed", fault: "restore_changed", outcome: "failure", retained: true},
{name: "version_restore_failure", fault: "version_rename", outcome: "failure", retained: true},
{name: "new_destination_directory", outcome: "directory", retained: true},
@@ -673,6 +675,11 @@ func TestAutoUpdateBackupTransaction(t *testing.T) {
func runAutoUpdateTransactionScenario(t *testing.T, fault, outcome, layout, active string, noVersion, preflight, retained, success bool) {
t.Helper()
+ if fault == "xattrs" {
+ if _, err := exec.LookPath("python3"); err != nil {
+ t.Skip("python3 unavailable for extended metadata fixture")
+ }
+ }
updater, err := filepath.Abs(repoFile("scripts", "pulse-auto-update.sh"))
if err != nil {
t.Fatal(err)
@@ -703,6 +710,26 @@ case "$FAULT" in
binary_symlink) mv "$INSTALL_DIR/bin/pulse" "$FIXTURE_DIR/original/linked-binary"; ln -s "$FIXTURE_DIR/original/linked-binary" "$INSTALL_DIR/bin/pulse" ;;
version_symlink) rm "$INSTALL_DIR/VERSION"; ln -s "$FIXTURE_DIR/original/VERSION" "$INSTALL_DIR/VERSION" ;;
esac
+if [[ "$FAULT" == xattrs ]]; then
+ if python3 - "$INSTALL_DIR" <<'METADATA'
+import errno, os, sys
+try:
+ for name in ('bin/pulse', 'VERSION'):
+ os.setxattr(os.path.join(sys.argv[1], name), 'user.pulse-updater-test', b'original extended metadata')
+except AttributeError:
+ sys.exit(77)
+except OSError as exc:
+ if exc.errno in (errno.ENOTSUP, errno.EOPNOTSUPP):
+ sys.exit(77)
+ raise
+METADATA
+ then :
+ else
+ metadata_status=$?
+ if [[ "$metadata_status" == 77 ]]; then echo TRANSACTION_METADATA_UNAVAILABLE; exit 0; fi
+ exit "$metadata_status"
+ fi
+fi
printf '%s\n' "$PRIOR_ACTIVE" > "$FIXTURE_DIR/active"
export FIXTURE_DIR OUTCOME FAULT
cat > "$FIXTURE_DIR/installer" <<'INSTALLER'
@@ -726,7 +753,11 @@ if [[ "$OUTCOME" == directory ]]; then
mkdir "$PULSE_INSTALL_DIR/bin/pulse"
printf 'unexpected directory\n' > "$PULSE_INSTALL_DIR/bin/pulse/keep"
fi
-case "$OUTCOME" in failure|symlink|directory) exit 23 ;; esac
+if [[ "$OUTCOME" == fifo ]]; then
+ rm "$PULSE_INSTALL_DIR/bin/pulse"
+ mkfifo "$PULSE_INSTALL_DIR/bin/pulse"
+fi
+case "$OUTCOME" in failure|symlink|directory|fifo) exit 23 ;; esac
exit 0
INSTALLER
command ssh-keygen -q -t ed25519 -N '' -f "$FIXTURE_DIR/fixture-key"
@@ -869,6 +900,13 @@ if [[ "$PREFLIGHT" != true && "$RETAINED" != true && "$EXPECTED_RESULT" != succe
[[ "$(cat "$FIXTURE_DIR/active")" == "$PRIOR_ACTIVE" ]]
fi
if [[ "$EXPECTED_RESULT" == success ]]; then [[ "$(get_current_version)" == v6.5.0 ]]; fi
+if [[ "$FAULT" == xattrs ]]; then
+ python3 - "$INSTALL_DIR" <<'METADATA'
+import os, sys
+for name in ('bin/pulse', 'VERSION'):
+ assert os.getxattr(os.path.join(sys.argv[1], name), 'user.pulse-updater-test') == b'original extended metadata'
+METADATA
+fi
printf 'TRANSACTION_ASSERTIONS_PASSED\n'
`
cmd := exec.Command("bash", "-c", script)
@@ -890,6 +928,9 @@ printf 'TRANSACTION_ASSERTIONS_PASSED\n'
if err != nil {
t.Fatalf("complete updater transaction: %v\n%s", err, out)
}
+ if strings.Contains(string(out), "TRANSACTION_METADATA_UNAVAILABLE") {
+ t.Skip("extended metadata unsupported by fixture filesystem")
+ }
if !strings.Contains(string(out), "TRANSACTION_ASSERTIONS_PASSED") {
t.Fatalf("transaction assertions did not finish:\n%s", out)
}
diff --git a/scripts/pulse-auto-update.sh b/scripts/pulse-auto-update.sh
index 4b1a0a5995..b06118fec8 100755
--- a/scripts/pulse-auto-update.sh
+++ b/scripts/pulse-auto-update.sh
@@ -348,12 +348,13 @@ wait_for_service_active() {
# Guarantee the Pulse service is left running after an update attempt if (and
# only if) it was running beforehand. Invoked from perform_update's RETURN trap
-# so that no exit path — present or future — can leave Pulse stopped (#1630:
+# after pre-install failures or a verified update/recovery (#1630:
# the install-failed rollback branch restored the backup but never restarted
# the service). This matters doubly because the generated pulse-update.service
# uses ExecCondition=systemctl is-active pulse.service: once Pulse is down,
# every subsequent timer run is skipped and the install stays down until
-# someone intervenes. Always returns 0 (it runs under set -e in a trap).
+# someone intervenes. Incomplete recovery deliberately suppresses this backstop:
+# activating a partial restore would be unsafe. Always returns 0 in the trap.
ensure_service_restarted() {
local service_name=$1
local service_was_active=$2
@@ -397,9 +398,9 @@ perform_update() {
service_was_active="true"
fi
- # Whatever way this function exits, never leave Pulse stopped when it was
- # running before the update (#1630). Extended below once the installer
- # tempfiles exist. The trap disarms itself on the first RETURN: a RETURN
+ # Keep the prior-active restart backstop (#1630), except when incomplete
+ # recovery requires manual intervention. The trap disarms itself on the
+ # first RETURN: a RETURN
# trap is not scoped to the function that set it, so leaving it installed
# makes it re-run when any later function returns — with these locals gone
# that aborted the updater under set -u after a successful update (#2128).
@@ -434,7 +435,7 @@ perform_update() {
log error "Unsupported rollback source ${file_paths[i]}; refusing update"
return 1
fi
- if ! cp -p -- "${file_paths[i]}" "$backup_dir/${backup_names[i]}" ||
+ if ! cp -a -- "${file_paths[i]}" "$backup_dir/${backup_names[i]}" ||
! cmp -s -- "${file_paths[i]}" "$backup_dir/${backup_names[i]}"; then
log error "Could not verify rollback backup for ${file_paths[i]}; refusing update"
return 1
@@ -543,7 +544,7 @@ perform_update() {
for i in "${!file_paths[@]}"; do
if [[ "${file_present[i]}" == "true" ]]; then
if ! restore_files[i]=$(mktemp "${file_paths[i]}.rollback.XXXXXX") ||
- ! cp -p -- "$backup_dir/${backup_names[i]}" "${restore_files[i]}" ||
+ ! cp -a -- "$backup_dir/${backup_names[i]}" "${restore_files[i]}" ||
! cmp -s -- "$backup_dir/${backup_names[i]}" "${restore_files[i]}"; then
log error "Could not stage rollback for ${file_paths[i]}; backup retained at $backup_dir; manual recovery required"
return 1
@@ -554,7 +555,7 @@ perform_update() {
if [[ "${file_present[i]}" == "true" ]]; then
if [[ -d "${file_paths[i]}" ]] ||
! mv -f -- "${restore_files[i]}" "${file_paths[i]}" ||
- [[ -L "${file_paths[i]}" ]] ||
+ [[ ! -f "${file_paths[i]}" || -L "${file_paths[i]}" ]] ||
! cmp -s -- "$backup_dir/${backup_names[i]}" "${file_paths[i]}"; then
log error "Could not restore ${file_paths[i]}; backup retained at $backup_dir; manual recovery required"
return 1