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 truthful partial-stop recovery in legacy controls

pulse-triage[bot]e1b3a352c549
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index f1107f5ade..d2232691d9 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -33,6 +33,12 @@ manager commands or exact owned-link removal. Foreign, malformed or inaccessible
paths refuse, rather than deleting another service. Both paths recheck after
remote confirmation and before script, PID or credential erasure. Remote refusal
keeps the stopped installation's recovery material; no automatic restart occurs.
+Disabling may succeed before a later stop/status/process read fails; do not
+restore activation links or automatically restart. Earlier installed init scripts
+can still erase their own runtime PID files after failed signals. The independent
+gate then retains service/credential recovery and refuses remote removal; it
+does not recreate PIDs or rewrite those installed scripts. Renderer changes apply
+to newly generated scripts, not historical installed-script acceptance.
Missing/repeated removal still requires known disabled activation and process
absence. Existing systemd/OpenRC gates and credential/transport ownership remain.
@@ -41,7 +47,7 @@ A linked rc.d service or existing appliance bootstrap therefore refuses *before*
remote removal or erasure until its owning activation task can be reconciled;
this step does not claim appliance task, launchd, Windows or native acceptance.
Missing timeout/sysrc or unrecognised manager output also remains a safe refusal.
-`TestInstallSHLegacyTeardownRequiresObservedQuiescence` requires all seventeen
+`TestInstallSHLegacyTeardownRequiresObservedQuiescence` requires all eighteen
production-function/caller/rendered-stop methods in `agent_legacy_teardown.py`,
using closed ordinary-user models and private deletion/signal targets, plus a
real timeout-child termination control. Source models are not installed signed
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index 116c78887a..5ff4c2ac7f 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -34,6 +34,12 @@ manager commands or exact owned-link removal. Foreign, malformed or inaccessible
paths refuse, rather than deleting another service. Both paths recheck after
remote confirmation and before script, PID or credential erasure. Remote refusal
keeps the stopped installation's recovery material; no automatic restart occurs.
+Disabling may succeed before a later stop/status/process read fails; do not
+restore activation links or automatically restart. Earlier installed init scripts
+can still erase their own runtime PID files after failed signals. The independent
+gate then retains service/credential recovery and refuses remote removal; it
+does not recreate PIDs or rewrite those installed scripts. Renderer changes apply
+to newly generated scripts, not historical installed-script acceptance.
Missing/repeated removal still requires known disabled activation and process
absence. Existing systemd/OpenRC gates and credential/transport ownership remain.
@@ -42,7 +48,7 @@ A linked rc.d service or existing appliance bootstrap therefore refuses *before*
remote removal or erasure until its owning activation task can be reconciled;
this step does not claim appliance task, launchd, Windows or native acceptance.
Missing timeout/sysrc or unrecognised manager output also remains a safe refusal.
-`TestInstallSHLegacyTeardownRequiresObservedQuiescence` requires all seventeen
+`TestInstallSHLegacyTeardownRequiresObservedQuiescence` requires all eighteen
production-function/caller/rendered-stop methods in `agent_legacy_teardown.py`,
using closed ordinary-user models and private deletion/signal targets, plus a
real timeout-child termination control. Source models are not installed signed
diff --git a/scripts/installtests/agent_legacy_teardown.py b/scripts/installtests/agent_legacy_teardown.py
index 45c7e71eac..a6ff222ba4 100644
--- a/scripts/installtests/agent_legacy_teardown.py
+++ b/scripts/installtests/agent_legacy_teardown.py
@@ -73,7 +73,10 @@ elif role == 'init':
if a[0] in ('stop', 'onestop'):
event('service:stop')
if fault == 'refused-stop' or (fault == 'refused-stop-after-remote' and remote): sys.exit(1)
- if fault != 'ignored-stop': v['state'] = 'stopped'
+ if fault not in ('ignored-stop', 'legacy-erasing-stop'): v['state'] = 'stopped'
+ if fault == 'legacy-erasing-stop':
+ for name in ('primary.pid', 'child.pid', 'sysv.pid'):
+ (root / name).unlink(missing_ok=True)
save(); sys.exit(0)
event('status:read'); v['status_reads'] += 1; save()
if fault == 'failed-status' or (fault == 'failed-status-after-remote' and remote): sys.exit(2)
@@ -237,6 +240,18 @@ remove_safe_profile_state_dir() { builtin command rm -r -- "$SAFE_PROFILE_STATE_
result[str(p.relative_to(root))] = (info.st_mode, info.st_ino, data)
return result
+ def assert_recovery_retained(self, before, after):
+ # Successful disabling may remove owned activation links before a later
+ # read fails. Never recreate those links (or automatically restart).
+ # Every non-activation file, and every surviving link, remains exact.
+ for name, value in before.items():
+ owned_activation = name.startswith("etc/") and name.rsplit("/", 1)[-1] in ("S20pulse-agent", "K01pulse-agent")
+ if owned_activation and name not in after:
+ continue
+ self.assertIn(name, after)
+ self.assertEqual(after[name], value)
+ self.assertFalse(set(after) - set(before))
+
def test_stop_refusal_retains_all_local_recovery(self):
for platform in ("FreeBSD", "SysV"):
with self.subTest(platform=platform):
@@ -260,7 +275,7 @@ remove_safe_profile_state_dir() { builtin command rm -r -- "$SAFE_PROFILE_STATE_
with self.subTest(platform=platform, fault=fault):
r, events, before, after, _ = self.exercise(platform, fault=fault)
self.assertNotEqual(r.returncode, 0, r.stderr)
- self.assertEqual(after, before)
+ self.assert_recovery_retained(before, after)
self.assertNotIn("init:remove", events)
def test_failed_empty_diagnostic_or_duplicate_reads_are_not_absence(self):
@@ -296,7 +311,7 @@ remove_safe_profile_state_dir() { builtin command rm -r -- "$SAFE_PROFILE_STATE_
with self.subTest(platform=platform, fault=fault):
r, events, before, after, _ = self.exercise(platform, fault=fault)
self.assertNotEqual(r.returncode, 0, r.stderr)
- self.assertEqual(after, before)
+ self.assert_recovery_retained(before, after)
self.assertIn("service:stop", events)
def test_pid_ownership_and_unexpected_paths_refuse_before_signals(self):
@@ -367,6 +382,22 @@ remove_safe_profile_state_dir() { builtin command rm -r -- "$SAFE_PROFILE_STATE_
self.assertNotIn("state:remove", events)
self.assertNotIn("service:start", events)
+ def test_legacy_script_pid_erasure_cannot_authorise_credential_erasure(self):
+ # Old deployed renderers can remove PID files even when signals fail.
+ # The independent process read must still prevent remote/credential
+ # removal. Do not pretend the installer recreated those ephemeral PIDs.
+ for platform in ("FreeBSD", "SysV"):
+ with self.subTest(platform=platform):
+ r, events, before, after, model = self.exercise(platform, fault="legacy-erasing-stop", flow="caller")
+ self.assertNotEqual(r.returncode, 0, r.stderr)
+ for k in ("init", "state/token", "helper/token", "profile/token", "unrelated"):
+ self.assertEqual(after[k], before[k])
+ self.assertEqual(model["state"], "started")
+ self.assertNotIn("remote:remove", events)
+ self.assertNotIn("state:remove", events)
+ self.assertNotIn("service:start", events)
+ self.assertNotIn("primary.pid", after)
+
def test_known_stopped_missing_and_repeated_removal_are_safe(self):
for platform in ("FreeBSD", "SysV"):
for path, repeat in (("regular", False), ("missing", False), ("regular", True)):
diff --git a/scripts/installtests/install_sh_test.go b/scripts/installtests/install_sh_test.go
index e76c11ec2d..a854b3b992 100644
--- a/scripts/installtests/install_sh_test.go
+++ b/scripts/installtests/install_sh_test.go
@@ -8438,6 +8438,7 @@ func TestInstallSHLegacyTeardownRequiresObservedQuiescence(t *testing.T) {
"test_remote_refusal_keeps_stopped_install_and_all_recovery_files",
"test_late_refusal_keeps_local_recovery_after_remote_confirmation",
"test_known_stopped_missing_and_repeated_removal_are_safe",
+ "test_legacy_script_pid_erasure_cannot_authorise_credential_erasure",
"test_process_inventory_does_not_return_arguments_or_secrets",
"test_real_process_timeout_stops_owned_child_without_erasure",
"test_rendered_stop_retains_pidfiles_on_refused_or_ignored_signals",
@@ -8446,7 +8447,7 @@ func TestInstallSHLegacyTeardownRequiresObservedQuiescence(t *testing.T) {
t.Fatalf("legacy manager control %s did not pass:\n%s", name, output)
}
}
- if !strings.Contains(string(output), "\nRan 17 tests in ") || !strings.Contains(string(output), "\nOK\n") {
+ if !strings.Contains(string(output), "\nRan 18 tests in ") || !strings.Contains(string(output), "\nOK\n") {
t.Fatalf("incomplete legacy manager verdict:\n%s", output)
}
t.Logf("%s", output)