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 cleanup failures through conditional LXC exits

pulse-triage[bot]953a0ea9e8f4
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index 68c10ba42f..b8e7310d87 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -864,6 +864,10 @@ The EXIT handler removes only this invocation's owned temporary installer/archiv
inputs, preserving an earlier failure if input cleanup also fails. Caller-owned
archives/signatures and files already copied into the container remain available.
Before successful creation, the installer does not claim it owns a container.
+Owned-leaf removal errors propagate explicitly through both cleanup helpers,
+including conditional callers; a later successful directory check cannot hide
+them. Cleanup-only failure warns and returns nonzero without replacing an earlier
+installation exit. Nonempty unexpected directories are still never erased.
The dependency shell fails at the first failed required package-index or package
installation command, retains its diagnostic and returns its nonzero status;
diff --git a/install.sh b/install.sh
index 4793b5abe9..fe28eb4eaa 100644
--- a/install.sh
+++ b/install.sh
@@ -589,6 +589,7 @@ handle_container_install_exit() {
local install_status="$1"
# Preserve the original failure, even if removing owned input scratch fails.
if ! cleanup_container_install_inputs "${container_script_temp_dir:-}" "${container_archive_source:-}" "${container_archive_temp:-false}"; then
+ print_warn "Could not remove all temporary installation inputs."
if [[ "$install_status" -eq 0 ]]; then
install_status=1
fi
@@ -3302,21 +3303,25 @@ chown_install_dir_for_pulse() {
cleanup_temp_archive_path() {
local archive_path="$1"
+ local cleanup_status=0
[[ -n "$archive_path" ]] || return 0
- rm -f -- "$archive_path" "${archive_path}.sshsig"
+ rm -f -- "$archive_path" "${archive_path}.sshsig" || cleanup_status=1
# Delete only the two owned leaves and an empty parent, never a tree.
rmdir -- "$(dirname "$archive_path")" 2>/dev/null || true
+ return "$cleanup_status"
}
cleanup_container_install_inputs() {
local script_dir="${1:-}" archive_path="${2:-}" archive_owned="${3:-false}"
+ local cleanup_status=0
if [[ -n "$script_dir" ]]; then
- rm -f -- "$script_dir/install.sh" "$script_dir/install.sh.sshsig" "$script_dir/curl-error"
+ rm -f -- "$script_dir/install.sh" "$script_dir/install.sh.sshsig" "$script_dir/curl-error" || cleanup_status=1
rmdir -- "$script_dir" 2>/dev/null || true
fi
if [[ "$archive_owned" == true ]]; then
- cleanup_temp_archive_path "$archive_path"
+ cleanup_temp_archive_path "$archive_path" || cleanup_status=1
fi
+ return "$cleanup_status"
}
download_container_installer() {
diff --git a/scripts/installtests/root_install_sh_test.go b/scripts/installtests/root_install_sh_test.go
index 61f39e3fed..1f124716a9 100644
--- a/scripts/installtests/root_install_sh_test.go
+++ b/scripts/installtests/root_install_sh_test.go
@@ -145,6 +145,21 @@ func TestRootInstallProxmoxFailurePreservesRecovery(t *testing.T) {
if err != nil {
t.Fatalf("Proxmox installer failure/recovery controls: %v\n%s", err, out)
}
+ for _, control := range []string{
+ "test_inner_installer_exit_is_reported_with_and_without_timeout",
+ "test_interruptions_never_destroy_the_partially_installed_container",
+ "test_late_unexpected_failures_keep_state_and_original_exit",
+ "test_no_owned_container_is_claimed_before_create_succeeds",
+ "test_real_owned_cleanup_failure_does_not_replace_the_primary_failure",
+ "test_required_dependency_failures_stop_before_install",
+ "test_start_network_and_copy_failures_keep_recovery_state",
+ "test_success_and_optional_settings_failures_still_complete",
+ "test_timeout_retains_copied_inputs_and_requires_state_reconciliation",
+ } {
+ if !strings.Contains(string(out), control+" (__main__.LXCRecovery."+control+") ... ok") {
+ t.Fatalf("required LXC recovery control %s did not pass:\n%s", control, out)
+ }
+ }
}
func TestRootInstallScriptVersionFlagRequiresValue(t *testing.T) {
diff --git a/scripts/tests/test_server_lxc_recovery.py b/scripts/tests/test_server_lxc_recovery.py
index 904deed245..5fa5fd75b5 100644
--- a/scripts/tests/test_server_lxc_recovery.py
+++ b/scripts/tests/test_server_lxc_recovery.py
@@ -277,20 +277,48 @@ class LXCRecovery(unittest.TestCase):
actions)
self.assertIn("ready\n", actions)
- def test_exit_handler_does_not_replace_the_primary_failure(self):
- for primary, expected in ((44, 44), (0, 1)):
- with self.subTest(primary=primary):
- env = dict(os.environ, INSTALLER=str(INSTALLER))
- script = r'''
+ def test_real_owned_cleanup_failure_does_not_replace_the_primary_failure(self):
+ for kind in ("script", "archive", "both"):
+ for primary, expected in ((44, 44), (0, 1)):
+ with self.subTest(kind=kind, primary=primary):
+ self.assert_cleanup_failure(kind, primary, expected)
+
+ def assert_cleanup_failure(self, kind, primary, expected):
+ with tempfile.TemporaryDirectory() as temp:
+ root = Path(temp)
+ (root / "script").mkdir()
+ (root / "archive").mkdir()
+ (root / "script/install.sh").write_bytes(b"owned installer input\n")
+ (root / "archive/pulse.tar.gz").write_bytes(b"owned archive input\n")
+ (root / "archive/pulse.tar.gz.sshsig").write_bytes(b"owned signature input\n")
+ env = dict(os.environ, INSTALLER=str(INSTALLER), FIXTURE=temp, KIND=kind)
+ script = r'''
source "$INSTALLER"
-cleanup_container_install_inputs() { return 57; }
+container_script_temp_dir=""
+container_archive_source=""
+container_archive_temp=false
+if [[ "$KIND" != archive ]]; then
+ container_script_temp_dir="$FIXTURE/script"
+fi
+if [[ "$KIND" != script ]]; then
+ container_archive_source="$FIXTURE/archive/pulse.tar.gz"
+ container_archive_temp=true
+fi
+# Fail only removal; run both real production cleanup functions unchanged.
+rm() { printf 'fixture owned-input removal failure\n' >&2; return 57; }
INSTALL_CONTAINER_CREATED=false
handle_container_install_exit "$1"
'''
- result = subprocess.run(["bash", "-c", script, "bash", str(primary)],
- env=env, capture_output=True, text=True,
- timeout=5, start_new_session=True)
- self.assertEqual(result.returncode, expected, result.stdout + result.stderr)
+ result = subprocess.run(["bash", "-c", script, "bash", str(primary)],
+ env=env, capture_output=True, text=True,
+ timeout=5, start_new_session=True)
+ self.assertEqual(result.returncode, expected, result.stdout + result.stderr)
+ self.assertIn("Could not remove all temporary installation inputs.",
+ result.stdout + result.stderr)
+ self.assertEqual((root / "script/install.sh").read_bytes(), b"owned installer input\n")
+ self.assertEqual((root / "archive/pulse.tar.gz").read_bytes(), b"owned archive input\n")
+ self.assertEqual((root / "archive/pulse.tar.gz.sshsig").read_bytes(),
+ b"owned signature input\n")
if __name__ == "__main__":