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.

Let the newest settled watchdog read decide availability

rcourtmanc933241cf23f
diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.md
index ca02ea2373..56139aec7d 100644
--- a/docs/release-control/v6/internal/subsystems/alerts.md
+++ b/docs/release-control/v6/internal/subsystems/alerts.md
@@ -3174,12 +3174,16 @@ heartbeat stopped while Pulse kept pinging every minute, and a status that is
never re-read kept its read-time age through a real stall, which is the one
case this panel exists to show. A background re-read leaves the Refresh control
alone, and a failed one keeps the last status and marks it unavailable. The
-status read has no timeout, so reads carry a sequence number and an answer
-applies only when it is newer than the last one applied: a slow or hung read can
-neither overwrite a newer status nor block later reads, reads slower than the
-poll still land in order, the next background read goes out at the first poll
-once the newest has been pending a full interval, and a Refresh still pending at
-such a poll frees the button (within two intervals of the click).
+status read has no timeout, so reads carry a sequence number and a read's
+outcome applies only when it is newer than the last read that settled: a
+success shows its status and clears the unavailable mark, a failure sets it. A
+slow or hung read can therefore neither overwrite a newer outcome nor block
+later reads, and reads slower than the poll still land in order. While the
+panel's poll runs, the next background read goes out at the first poll once the
+newest read has been pending at least 29 seconds (one second of slack absorbs
+timer jitter), and a Refresh is released by its own read, by any newer read that
+settles, or by the first poll at which it has been pending that long, so a hung
+Refresh frees within about two intervals of the click.
The delivery log's relative hover time on each row reads the same clock: a
logged attempt's time never changes, so its age is correct over a log that is
only re-read on demand.
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 9ba9f2d3e8..19606688a1 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -5219,10 +5219,9 @@ not re-read stays the age at read time, because a moving age over a snapshot
that never refreshes claims the reading stopped when it may not have. Such a
surface either re-reads the snapshot in the background, as Proxmox replication
and the external watchdog panel do, or keeps the read-time age, as the Patrol
-attention detail does for Last seen. A background re-read applies an answer
-only when it is newer than the last one applied, so a slow or hung read can
-neither pin the surface to an older snapshot nor overwrite a newer one while
-its ages keep moving. An immutable event time (when a delivery
+attention detail does for Last seen. The external watchdog panel orders its
+re-reads by request, so a slow or hung read can neither pin it to an older
+snapshot nor overwrite a newer outcome while its ages keep moving. An immutable event time (when a delivery
was attempted, a transition happened, a policy was set) ages correctly over any
snapshot and reads the clock.
Read-only metadata badges follow the same primitive-owned shell rule.
diff --git a/frontend-modern/browser-verification/d7b9435b593e965e.json b/frontend-modern/browser-verification/d7b9435b593e965e.json
new file mode 100644
index 0000000000..23522425f0
--- /dev/null
+++ b/frontend-modern/browser-verification/d7b9435b593e965e.json
@@ -0,0 +1,38 @@
+{
+ "version": 1,
+ "base_sha": "b81f0478d3d779f8c6e2be856f1e2b99acfc6437",
+ "verified_at": "2026-10-06T19:52:24Z",
+ "result": "passed",
+ "changed_paths": [
+ "frontend-modern/src/features/alerts/AlertDeadManDestinationSection.tsx"
+ ],
+ "content_sha256": {
+ "frontend-modern/src/features/alerts/AlertDeadManDestinationSection.tsx": "ba80adc764c5b0e8055345654bf4fb0bf0aaeb17338ad0c0f5be820ff680dea5"
+ },
+ "routes": [
+ "/alerts/destinations"
+ ],
+ "viewports": [
+ {
+ "width": 1440,
+ "height": 900
+ },
+ {
+ "width": 390,
+ "height": 844
+ }
+ ],
+ "states": [
+ "Private mock stack (backend :7731, Vite :5251 serving this branch) with Playwright page.clock installed before load and every /api/alerts/deadman/status read held until the script answers it, with a status or an HTTP 500",
+ "Failures slower than the poll: with two reads in flight the older one fails, and the badge changes from Heartbeat healthy to Status unavailable; the newest read then fails and an older read succeeds late, and the badge stays Status unavailable (no false recovery)",
+ "Successes slower than the poll still apply in order (10 mins ago -> 3 mins ago -> 1 min ago) and an older late success does not overwrite a newer one",
+ "A hung Refresh followed by a hung background read: the button is enabled again at the first poll after a full interval, and a second Refresh applies",
+ "Control with the previous loader under the running Vite: the slow failure was hidden and the badge stayed Heartbeat healthy",
+ "No page errors at either viewport"
+ ],
+ "interactions": [
+ "Loaded /alerts/destinations at 1440x900 and 390x844, ran the page clock in 30-second steps answering held reads in and out of order with successes and HTTP 500s",
+ "Clicked Refresh with the read held, ran the clock 61 seconds, clicked Refresh again",
+ "Repeated with the previous loader as the control"
+ ]
+}
diff --git a/frontend-modern/src/features/alerts/AlertDeadManDestinationSection.tsx b/frontend-modern/src/features/alerts/AlertDeadManDestinationSection.tsx
index 8450336946..7347d76fb2 100644
--- a/frontend-modern/src/features/alerts/AlertDeadManDestinationSection.tsx
+++ b/frontend-modern/src/features/alerts/AlertDeadManDestinationSection.tsx
@@ -62,17 +62,17 @@ export function AlertDeadManDestinationSection(props: AlertDeadManDestinationSec
const [unavailable, setUnavailable] = createSignal(false);
const [showUrl, setShowUrl] = createSignal(false);
- // The status read has no timeout. Every read gets a sequence number and an
- // answer applies only when it is newer than the last one applied, so a slow
- // or hung read can neither overwrite a newer status nor block later reads,
- // and reads slower than the poll interval still land in order. A background
- // read waits while the newest read is younger than one poll interval; a
- // Refresh still pending at such a poll counts as stalled and frees the
- // button. Only
- // the newest read's failure marks the status unavailable, and nothing
- // applies after the panel unmounts.
+ // The status read has no timeout. Every read gets a sequence number, and a
+ // read's outcome applies only when it is newer than the last read that
+ // settled: a success shows its status and clears the unavailable mark, a
+ // failure sets it. A slow or hung read therefore cannot overwrite a newer
+ // outcome or block later reads, and reads slower than the poll interval
+ // still land in order. A background read waits while the newest read is
+ // younger than one poll interval (less a second of timer slack); a Refresh
+ // still pending at such a poll counts as stalled and frees the button.
+ // Nothing applies after the panel unmounts.
let latestStarted = 0;
- let latestApplied = 0;
+ let latestSettled = 0;
let pendingSince: number | undefined;
let foregroundRequest = 0;
let foregroundSince = 0;
@@ -101,19 +101,20 @@ export function AlertDeadManDestinationSection(props: AlertDeadManDestinationSec
}
try {
const next = await AlertsAPI.getDeadManStatus();
- if (disposed || request < latestApplied) return;
- latestApplied = request;
+ if (disposed || request < latestSettled) return;
+ latestSettled = request;
setStatus(next);
setUnavailable(false);
- if (request >= foregroundRequest) setLoading(false);
} catch (error) {
- if (disposed || request !== latestStarted) return;
+ if (disposed || request < latestSettled) return;
+ latestSettled = request;
logger.error('Failed to load external watchdog status', error);
setUnavailable(true);
} finally {
if (!disposed) {
if (request === latestStarted) pendingSince = undefined;
- if (request === foregroundRequest) setLoading(false);
+ // A Refresh is answered by its own read or by any newer one.
+ if (request >= foregroundRequest) setLoading(false);
}
}
};
diff --git a/frontend-modern/src/features/alerts/__tests__/AlertDeadManDestinationSection.test.tsx b/frontend-modern/src/features/alerts/__tests__/AlertDeadManDestinationSection.test.tsx
index 1740cab1aa..b82779126a 100644
--- a/frontend-modern/src/features/alerts/__tests__/AlertDeadManDestinationSection.test.tsx
+++ b/frontend-modern/src/features/alerts/__tests__/AlertDeadManDestinationSection.test.tsx
@@ -300,4 +300,61 @@ describe('AlertDeadManDestinationSection', () => {
vi.useRealTimers();
}
});
+
+ it('lets the newest settled read decide availability, even when reads outlast the poll', async () => {
+ const start = Date.parse('2026-08-27T12:10:00Z');
+ vi.useFakeTimers({ toFake: ['Date', 'setInterval', 'clearInterval'], now: start });
+ const base = await AlertsAPI.getDeadManStatus();
+ vi.mocked(AlertsAPI.getDeadManStatus).mockReset();
+ const pending: Array<{
+ resolve: (value: typeof base) => void;
+ reject: (error: Error) => void;
+ }> = [];
+ vi.mocked(AlertsAPI.getDeadManStatus).mockImplementation(
+ () =>
+ new Promise((resolve, reject) => {
+ pending.push({ resolve, reject });
+ }),
+ );
+ const [pingUrl, setPingUrl] = createSignal('***REDACTED***');
+ const badge = () => screen.getByText(/^(Status unavailable|Heartbeat healthy|Not configured)$/);
+ const settle = async () => {
+ await Promise.resolve();
+ await Promise.resolve();
+ };
+
+ try {
+ render(() => (
+ <AlertDeadManDestinationSection
+ pingUrl={pingUrl}
+ setPingUrl={setPingUrl}
+ setHasUnsavedChanges={vi.fn()}
+ />
+ ));
+ await waitFor(() => expect(pending).toHaveLength(1));
+ pending[0].resolve(base);
+ await waitFor(() => expect(badge()).toHaveTextContent('Heartbeat healthy'));
+
+ // Every read now fails, and each failure arrives after the next poll has
+ // already started a newer read. The failures still mark the status.
+ vi.advanceTimersByTime(DEAD_MAN_STATUS_POLL_MS);
+ await waitFor(() => expect(pending).toHaveLength(2));
+ vi.advanceTimersByTime(DEAD_MAN_STATUS_POLL_MS);
+ await waitFor(() => expect(pending).toHaveLength(3));
+ pending[1].reject(new Error('timeout'));
+ await waitFor(() => expect(badge()).toHaveTextContent('Status unavailable'));
+
+ // The newest read fails; an older read then succeeds late. The older
+ // success must not report a recovery.
+ vi.advanceTimersByTime(DEAD_MAN_STATUS_POLL_MS);
+ await waitFor(() => expect(pending).toHaveLength(4));
+ pending[3].reject(new Error('timeout'));
+ await settle();
+ pending[2].resolve(base);
+ await settle();
+ expect(badge()).toHaveTextContent('Status unavailable');
+ } finally {
+ vi.useRealTimers();
+ }
+ });
});