From 025e1132eca2d41ced1005eafa3b41e3e0727f3a Mon Sep 17 00:00:00 2001 From: "pulse-triage[bot]" <249995291+pulse-triage[bot]@users.noreply.github.com> Date: Fri, 27 Nov 2026 12:59:46 +0000 Subject: [PATCH] Align watchdog, API, and TrueNAS Help with poll lifecycle fixes Document four monitoring-progress and poll-lifecycle fixes landed on main across the unclaimed in-app Help guides and their mirrored public copies, with source-bound Python regression tests: - docs/AVAILABILITY.md and docs/API.md (+ mirrors): document external watchdog recovery and replacement truthfulness (#5226), including immediate clearing of Monitoring stalled (monitor_stalled) on fresh monitoring progress, synchronous clearing of lastSuccessAt and lastAttemptAt on URL replacement/removal/invalid save (while preserving lastSuccessAt when re-saving the same URL), and cycle fencing on shutdown or config replacement. - docs/API.md (+ mirror): document monitor-local staleness scores in GET /api/monitoring/scheduler/health (#5234) and paused Proxmox VE passive cluster-discovery skipping in GET /api/config/nodes (#5251). - docs/TRUENAS.md (+ mirror): document retiring-connection poller ownership retirement and in-flight RPC cancellation including blocked socket negotiation (#5239). - scripts/tests/test_watchdog_help_docs.py, test_scheduler_health_api_help_docs.py, test_node_api_docs.py, and test_truenas_docs.py: bind each documented behaviour directly to its live Go runtime source. Contract-Neutral: Documentation, mirrored Help, and Python doc-regression test alignment for already-landed runtime behaviour; no runtime, API, schema, or subsystem contract changes. Change-source: pulse-maintainer --- docs/API.md | 18 +++++++++- docs/AVAILABILITY.md | 10 ++++++ docs/TRUENAS.md | 6 +++- frontend-modern/public/docs/API.md | 18 +++++++++- frontend-modern/public/docs/AVAILABILITY.md | 10 ++++++ frontend-modern/public/docs/TRUENAS.md | 6 +++- scripts/tests/test_node_api_docs.py | 10 ++++++ .../test_scheduler_health_api_help_docs.py | 36 +++++++++++++++++++ scripts/tests/test_truenas_docs.py | 5 +++ scripts/tests/test_watchdog_help_docs.py | 24 +++++++++++++ 10 files changed, 139 insertions(+), 4 deletions(-) diff --git a/docs/API.md b/docs/API.md index e23acf72cd..4f80c49ea2 100644 --- a/docs/API.md +++ b/docs/API.md @@ -769,7 +769,10 @@ This administrative inventory covers saved **PVE, PBS and PMG connections**, not individual VMs or agents. Keep its response private. Use the returned connection `id` for updates, deletion and tests; a display name, VMID or another installation's node name is not that ID. Re-read the inventory before a change -rather than guessing an ID from a list position. +rather than guessing an ID from a list position. Listing saved nodes returns +retained configuration for paused Proxmox VE connections without running +passive cluster discovery probes, while explicit tests and active discovery +stay unchanged. ### Add Node `POST /api/config/nodes` (admin, `settings:write`) @@ -1246,6 +1249,13 @@ it, use the snooze and unsnooze endpoints below. - `GET /api/alerts/deadman/status` — live watchdog health, monitor-loop progress, sanitized delivery failure state, and the most recent restart interruption; never includes the URL or endpoint fingerprint + When monitoring progress recovers after a stall, `monitor_stalled` clears + immediately and reports `starting` or `delivery_failed` if the recovery + heartbeat fails. Replacing, removing, or saving an invalid watchdog URL + clears stale `lastSuccessAt` and `lastAttemptAt` timestamps immediately while + re-saving the same configured URL preserves `lastSuccessAt`, and shutdown or + configuration changes fence superseded cycles from overwriting clean shutdown + records or the new destination's status. - `POST /api/alerts/activate` enables notification delivery and can notify about existing unacknowledged critical alerts. It is not a maintenance toggle, and there is no matching `/api/alerts/deactivate` endpoint. - `GET /api/alerts/active` (see [Active alerts](#active-alerts) for live `metricStatus` evaluation fields) - `GET /api/alerts/delivery-diagnosis?alertIdentifier=` (omit `alertIdentifier` to get the diagnosis array for every active alert) @@ -1588,6 +1598,12 @@ poll interval: `present`, `reason` and `nextRetry`. `nextRetry` does not schedule a poll. A later successful scheduled poll clears the dead-letter entry on current builds, though older builds may retain it after recovery. +- **`staleness`**: Per-connection freshness entries (`instance`, `type`, + `score`, `lastSuccess`, and optional `lastError`) computed locally inside + this monitor. Each `score` ages from `0` right after a successful poll up to + `1` at the maximum staleness window, or `1` after a recorded error with no + success. A success from a same-named connection monitored elsewhere does not + change this monitor's score. This endpoint covers scheduled polling only. Zero overdue queued tasks or advancing `lastSuccess` does not prove that a poll claimed by a worker finished, diff --git a/docs/AVAILABILITY.md b/docs/AVAILABILITY.md index 4829637ded..936fd97e8c 100644 --- a/docs/AVAILABILITY.md +++ b/docs/AVAILABILITY.md @@ -125,6 +125,16 @@ sender or a stale browser status read: After a restart, **Last interruption** records any monitoring gap of two minutes or longer and distinguishes a `clean restart` from an `unexpected stop`. +When monitoring progress recovers after a stall, **Monitoring stalled** clears +immediately and moves to **Starting** or **Delivery failing** if the recovery +heartbeat fails to deliver rather than staying stuck in **Monitoring stalled**. +Replacing, removing, or saving an invalid watchdog URL clears prior **Last +success** and **Last attempt** timestamps (and clears prior delivery alerts on +replacement) immediately, while re-saving the same configured URL preserves its +**Last success**. Concurrent shutdown or configuration replacement cancels +superseded watchdog cycles so an in-flight heartbeat cannot overwrite a clean +shutdown record or the new destination's status. + ## Check that DNS answers correctly Choose the **DNS resolution** protocol (or the **DNS resolver (Pi-hole / AdGuard / Unbound)** preset) to verify that a resolver such as Pi-hole, AdGuard Home, Technitium, or Unbound answers queries correctly. diff --git a/docs/TRUENAS.md b/docs/TRUENAS.md index c0ee4794f8..7a173dcb96 100644 --- a/docs/TRUENAS.md +++ b/docs/TRUENAS.md @@ -567,7 +567,11 @@ full refresh succeeds. When an edited TrueNAS connection fails client initialization, Pulse closes the previous live connection and clears stale cached records rather than continuing to poll the old endpoint. A valid edit that builds a new client preserves the last accepted cached records until -the rebuilt connection completes an accepted refresh. +the rebuilt connection completes an accepted refresh. When a saved TrueNAS +connection is edited, paused, or removed, Pulse retires the old poller +ownership before closing its transport and cancels in-flight RPC work +(including a socket blocked in negotiation) without waiting for an appliance +timeout or replaying interrupted operations. **Test connection** is not a complete poll. Some older builds, including Pulse 6.4.1 and 6.4.5, also let a saved-connection test update `lastAttemptAt` and diff --git a/frontend-modern/public/docs/API.md b/frontend-modern/public/docs/API.md index e23acf72cd..4f80c49ea2 100644 --- a/frontend-modern/public/docs/API.md +++ b/frontend-modern/public/docs/API.md @@ -769,7 +769,10 @@ This administrative inventory covers saved **PVE, PBS and PMG connections**, not individual VMs or agents. Keep its response private. Use the returned connection `id` for updates, deletion and tests; a display name, VMID or another installation's node name is not that ID. Re-read the inventory before a change -rather than guessing an ID from a list position. +rather than guessing an ID from a list position. Listing saved nodes returns +retained configuration for paused Proxmox VE connections without running +passive cluster discovery probes, while explicit tests and active discovery +stay unchanged. ### Add Node `POST /api/config/nodes` (admin, `settings:write`) @@ -1246,6 +1249,13 @@ it, use the snooze and unsnooze endpoints below. - `GET /api/alerts/deadman/status` — live watchdog health, monitor-loop progress, sanitized delivery failure state, and the most recent restart interruption; never includes the URL or endpoint fingerprint + When monitoring progress recovers after a stall, `monitor_stalled` clears + immediately and reports `starting` or `delivery_failed` if the recovery + heartbeat fails. Replacing, removing, or saving an invalid watchdog URL + clears stale `lastSuccessAt` and `lastAttemptAt` timestamps immediately while + re-saving the same configured URL preserves `lastSuccessAt`, and shutdown or + configuration changes fence superseded cycles from overwriting clean shutdown + records or the new destination's status. - `POST /api/alerts/activate` enables notification delivery and can notify about existing unacknowledged critical alerts. It is not a maintenance toggle, and there is no matching `/api/alerts/deactivate` endpoint. - `GET /api/alerts/active` (see [Active alerts](#active-alerts) for live `metricStatus` evaluation fields) - `GET /api/alerts/delivery-diagnosis?alertIdentifier=` (omit `alertIdentifier` to get the diagnosis array for every active alert) @@ -1588,6 +1598,12 @@ poll interval: `present`, `reason` and `nextRetry`. `nextRetry` does not schedule a poll. A later successful scheduled poll clears the dead-letter entry on current builds, though older builds may retain it after recovery. +- **`staleness`**: Per-connection freshness entries (`instance`, `type`, + `score`, `lastSuccess`, and optional `lastError`) computed locally inside + this monitor. Each `score` ages from `0` right after a successful poll up to + `1` at the maximum staleness window, or `1` after a recorded error with no + success. A success from a same-named connection monitored elsewhere does not + change this monitor's score. This endpoint covers scheduled polling only. Zero overdue queued tasks or advancing `lastSuccess` does not prove that a poll claimed by a worker finished, diff --git a/frontend-modern/public/docs/AVAILABILITY.md b/frontend-modern/public/docs/AVAILABILITY.md index 4829637ded..936fd97e8c 100644 --- a/frontend-modern/public/docs/AVAILABILITY.md +++ b/frontend-modern/public/docs/AVAILABILITY.md @@ -125,6 +125,16 @@ sender or a stale browser status read: After a restart, **Last interruption** records any monitoring gap of two minutes or longer and distinguishes a `clean restart` from an `unexpected stop`. +When monitoring progress recovers after a stall, **Monitoring stalled** clears +immediately and moves to **Starting** or **Delivery failing** if the recovery +heartbeat fails to deliver rather than staying stuck in **Monitoring stalled**. +Replacing, removing, or saving an invalid watchdog URL clears prior **Last +success** and **Last attempt** timestamps (and clears prior delivery alerts on +replacement) immediately, while re-saving the same configured URL preserves its +**Last success**. Concurrent shutdown or configuration replacement cancels +superseded watchdog cycles so an in-flight heartbeat cannot overwrite a clean +shutdown record or the new destination's status. + ## Check that DNS answers correctly Choose the **DNS resolution** protocol (or the **DNS resolver (Pi-hole / AdGuard / Unbound)** preset) to verify that a resolver such as Pi-hole, AdGuard Home, Technitium, or Unbound answers queries correctly. diff --git a/frontend-modern/public/docs/TRUENAS.md b/frontend-modern/public/docs/TRUENAS.md index c0ee4794f8..7a173dcb96 100644 --- a/frontend-modern/public/docs/TRUENAS.md +++ b/frontend-modern/public/docs/TRUENAS.md @@ -567,7 +567,11 @@ full refresh succeeds. When an edited TrueNAS connection fails client initialization, Pulse closes the previous live connection and clears stale cached records rather than continuing to poll the old endpoint. A valid edit that builds a new client preserves the last accepted cached records until -the rebuilt connection completes an accepted refresh. +the rebuilt connection completes an accepted refresh. When a saved TrueNAS +connection is edited, paused, or removed, Pulse retires the old poller +ownership before closing its transport and cancels in-flight RPC work +(including a socket blocked in negotiation) without waiting for an appliance +timeout or replaying interrupted operations. **Test connection** is not a complete poll. Some older builds, including Pulse 6.4.1 and 6.4.5, also let a saved-connection test update `lastAttemptAt` and diff --git a/scripts/tests/test_node_api_docs.py b/scripts/tests/test_node_api_docs.py index 3d31a139f0..d8e7987ce2 100644 --- a/scripts/tests/test_node_api_docs.py +++ b/scripts/tests/test_node_api_docs.py @@ -187,6 +187,16 @@ class NodeAPIDocsTest(unittest.TestCase): self.assertIn('--output "$result_file"', helper) self.assertNotIn('--retry', helper) + def test_paused_pve_passive_discovery_skip_matches_handler_source(self): + handlers = (ROOT / "internal/api/configapi/config_handlers.go").read_text(encoding="utf-8") + self.assertIn("if current == nil || current.Disabled {", handlers) + prose = " ".join(section().split()) + self.assertIn( + "Listing saved nodes returns retained configuration for paused Proxmox VE connections without running passive cluster discovery probes", + prose, + ) + self.assertIn("explicit tests and active discovery stay unchanged", prose) + if __name__ == "__main__": unittest.main() diff --git a/scripts/tests/test_scheduler_health_api_help_docs.py b/scripts/tests/test_scheduler_health_api_help_docs.py index 851b98c532..80d9566ea0 100644 --- a/scripts/tests/test_scheduler_health_api_help_docs.py +++ b/scripts/tests/test_scheduler_health_api_help_docs.py @@ -191,6 +191,42 @@ class SchedulerHealthAPIHelpDocsTest(unittest.TestCase): self.assertIn(f'ID: "{check_id}"', readiness) self.assertIn(f"`{check_id}`", api_text) + def test_staleness_locality_and_deadman_recovery_match_runtime_source(self) -> None: + api_text = " ".join(API_DOC.read_text(encoding="utf-8").split()) + section = " ".join(scheduler_section().split()) + monitor = (ROOT / "internal/monitoring/monitor.go").read_text(encoding="utf-8") + staleness = (ROOT / "internal/monitoring/staleness_tracker.go").read_text( + encoding="utf-8" + ) + deadman = (ROOT / "internal/monitoring/deadman.go").read_text(encoding="utf-8") + + self.assertIn('json:"staleness"', monitor) + for field in ("instance", "type", "score", "lastSuccess", "lastError"): + with self.subTest(staleness_field=field): + self.assertIn(f"`{field}`", section) + self.assertRegex(staleness, rf'json:"{re.escape(field)}(?:,omitempty)?"') + for phrase in ( + "computed locally inside this monitor", + "ages from `0` right after a successful poll up to `1` at the maximum staleness window", + "A success from a same-named connection monitored elsewhere does not change this monitor's score.", + ): + with self.subTest(staleness_phrase=phrase): + self.assertIn(phrase, section) + + for field in ("lastSuccessAt", "lastAttemptAt"): + with self.subTest(deadman_field=field): + self.assertRegex(deadman, rf'json:"{re.escape(field)}(?:,omitempty)?"') + self.assertIn(f"`{field}`", api_text) + self.assertIn("func (d *deadManRuntime) recordHealthyProgress(", deadman) + self.assertIn("func (d *deadManRuntime) notifyConfigChangedFor(", deadman) + for phrase in ( + "When monitoring progress recovers after a stall, `monitor_stalled` clears immediately and reports `starting` or `delivery_failed` if the recovery heartbeat fails.", + "Replacing, removing, or saving an invalid watchdog URL clears stale `lastSuccessAt` and `lastAttemptAt` timestamps immediately while re-saving the same configured URL preserves `lastSuccessAt`", + "shutdown or configuration changes fence superseded cycles from overwriting clean shutdown records or the new destination's status.", + ): + with self.subTest(deadman_phrase=phrase): + self.assertIn(phrase, api_text) + def test_in_app_links_target_real_shipped_docs_and_headings(self) -> None: section = scheduler_section() links = re.findall(r"\[[^\]]+\]\(([^)]+)\)", section) diff --git a/scripts/tests/test_truenas_docs.py b/scripts/tests/test_truenas_docs.py index fb5675c80f..6e8a4458b8 100644 --- a/scripts/tests/test_truenas_docs.py +++ b/scripts/tests/test_truenas_docs.py @@ -331,10 +331,15 @@ class TrueNASDocsTest(unittest.TestCase): "keeps the last accepted cached records and poll.lastSuccessAt until a full refresh succeeds", "fails client initialization, Pulse closes the previous live connection and clears stale cached records", "valid edit that builds a new client preserves the last accepted cached records", + "retires the old poller ownership before closing its transport and cancels in-flight RPC work (including a socket blocked in negotiation) without waiting for an appliance timeout or replaying interrupted operations", ): with self.subTest(phrase=phrase): self.assertIn(phrase, prose) + transport = (ROOT / "internal/truenas/transport.go").read_text(encoding="utf-8") + self.assertIn("var retired []*truenas.Provider", poller) + self.assertIn("func (c *Client) rpcLifetimeContext()", transport) + def test_polling_guidance_preserves_evidence_before_a_manual_test(self): text = DOC.read_text().split("### Stale TrueNAS data", 1)[1].split("### Disabling", 1)[0] # Markdown wrapping and sentence capitalization do not change the diff --git a/scripts/tests/test_watchdog_help_docs.py b/scripts/tests/test_watchdog_help_docs.py index d1001cea95..ec36b88f52 100644 --- a/scripts/tests/test_watchdog_help_docs.py +++ b/scripts/tests/test_watchdog_help_docs.py @@ -95,6 +95,30 @@ class WatchdogHelpDocsTest(unittest.TestCase): with self.subTest(phrase=phrase): self.assertIn(phrase, self.guide) + def test_watchdog_recovery_and_replacement_truthfulness_matches_deadman_source(self) -> None: + deadman = (ROOT / "internal/monitoring/deadman.go").read_text(encoding="utf-8") + for token in ( + "func (d *deadManRuntime) recordHealthyProgress(", + "func (d *deadManRuntime) recordSignalFailure(", + "func (d *deadManRuntime) notifyConfigChangedFor(", + "d.status.LastSuccessAt = nil", + "d.status.LastAttemptAt = nil", + "if d.stopping || ctx.Err() != nil {", + ): + with self.subTest(deadman_token=token): + self.assertIn(token, deadman) + + for phrase in ( + "Monitoring stalled clears immediately and moves to Starting or Delivery failing if the recovery heartbeat fails to deliver", + "Replacing, removing, or saving an invalid watchdog URL clears prior Last success and Last attempt timestamps", + "clears prior delivery alerts on replacement", + "re-saving the same configured URL preserves its Last success", + "Concurrent shutdown or configuration replacement cancels superseded watchdog cycles", + "cannot overwrite a clean shutdown record or the new destination's status", + ): + with self.subTest(phrase=phrase): + self.assertIn(phrase, self.guide) + if __name__ == "__main__": unittest.main()