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.

Keep guest SMART read failures across a quick drawer remount

pulse-triage[bot]c92e7c71ea8b
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 01b09b1a2e..6ecb2e5a6e 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -26,7 +26,10 @@
A failed guest physical-disk resource read must not leave cached health words,
temperatures or open SMART/history panels presented as current below an error.
The guest consumer withholds that entire disk list until a successful scoped
-read. It renders no response text, no zero-disk inference and no recovery action
+read. Its opt-in retained read error survives a quick drawer remount; cached
+rows cannot clear it. Other parents, organisations and default consumers do not
+inherit it. The shared hook reports background failure for this opt-in consumer
+as well; a successful scoped read clears the retained failure. It renders no response text, no zero-disk inference and no recovery action
against the guest. An explicit retry uses the same parent-scoped resource query;
pending retries stay focusable, announce their busy state and reject duplicate
activation. Failed retries keep the same control. Recovery shows only the newly
@@ -37,7 +40,9 @@ still get no empty card on first inspection.
When read failure or recovery removes focused content, focus returns to the
surviving inspection heading, including empty recovery. It must not steal focus
moved elsewhere, focus a hidden Overview or restore focus after leaving the guest.
-`GuestPhysicalDisks.test.tsx` covers retained/open evidence, failure/pending/retry,
+`useUnifiedResources.test.ts` covers retained read errors, remount, successful
+empty retry and scope/default isolation. `GuestPhysicalDisks.test.tsx` covers
+retained/open evidence, failure/pending/retry,
recovery/empty, literal-response suppression and focus ownership. Desktop/narrow
browser proof must exercise the actual resource reader through the guest drawer,
scoped failure, keyboard/touch retry, recovery and inspected pixels. Resource and
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index d2b7cdca90..01aa648446 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -28,7 +28,10 @@ and sort the complete canonical change table while startup and ingestion wait.
A failed guest physical-disk resource read must not leave cached health words,
temperatures or open SMART/history panels presented as current below an error.
The guest consumer withholds that entire disk list until a successful scoped
-read. It renders no response text, no zero-disk inference and no recovery action
+read. Its opt-in retained read error survives a quick drawer remount; cached
+rows cannot clear it. Other parents, organisations and default consumers do not
+inherit it. The shared hook reports background failure for this opt-in consumer
+as well; a successful scoped read clears the retained failure. It renders no response text, no zero-disk inference and no recovery action
against the guest. An explicit retry uses the same parent-scoped resource query;
pending retries stay focusable, announce their busy state and reject duplicate
activation. Failed retries keep the same control. Recovery shows only the newly
@@ -39,7 +42,9 @@ still get no empty card on first inspection.
When read failure or recovery removes focused content, focus returns to the
surviving inspection heading, including empty recovery. It must not steal focus
moved elsewhere, focus a hidden Overview or restore focus after leaving the guest.
-`GuestPhysicalDisks.test.tsx` covers retained/open evidence, failure/pending/retry,
+`useUnifiedResources.test.ts` covers retained read errors, remount, successful
+empty retry and scope/default isolation. `GuestPhysicalDisks.test.tsx` covers
+retained/open evidence, failure/pending/retry,
recovery/empty, literal-response suppression and focus ownership. Desktop/narrow
browser proof must exercise the actual resource reader through the guest drawer,
scoped failure, keyboard/touch retry, recovery and inspected pixels. Resource and
diff --git a/frontend-modern/src/components/Workloads/GuestPhysicalDisks.tsx b/frontend-modern/src/components/Workloads/GuestPhysicalDisks.tsx
index 7290dd14d9..6fd601aec6 100644
--- a/frontend-modern/src/components/Workloads/GuestPhysicalDisks.tsx
+++ b/frontend-modern/src/components/Workloads/GuestPhysicalDisks.tsx
@@ -153,6 +153,7 @@ export const GuestPhysicalDisks: Component<{
const source = useUnifiedResources({
query: `type=physical_disk&parent=${encodeURIComponent(parentId)}`,
cacheKey: `guest-physical-disks:${parentId}`,
+ retainReadError: true,
enabled: () => parentId.length > 0,
realtimeEnabled: () => parentId.length > 0 && props.historyEnabled !== false,
});
diff --git a/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts b/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts
index 2790c45218..3690c9eadc 100644
--- a/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts
+++ b/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts
@@ -3437,6 +3437,90 @@ describe('useUnifiedResources', () => {
dispose();
});
+ it('retains a scoped failed read across remounts until a real successful retry', async () => {
+ const options = {
+ query: 'type=physical_disk&parent=vm-alpha',
+ cacheKey: 'guest-physical-disks:vm-alpha',
+ retainReadError: true,
+ };
+ const mount = () => {
+ let dispose!: () => void;
+ let result!: ReturnType<typeof useUnifiedResources>;
+ createRoot((d) => {
+ dispose = d;
+ result = useUnifiedResources(options);
+ });
+ return { result, dispose };
+ };
+ const first = mount();
+ await waitForResourceCount(() => first.result.resources().length);
+ const failure = new Error('scoped read unavailable');
+ apiFetchMock.mockRejectedValueOnce(failure);
+ await expect(first.result.refetch()).rejects.toBe(failure);
+ expect(first.result.error()).toBe(failure);
+ expect(first.result.resources()).toHaveLength(1);
+ first.dispose();
+
+ const calls = apiFetchMock.mock.calls.length;
+ const reopened = mount();
+ await flushAsync();
+ expect(reopened.result.error()).toBe(failure);
+ expect(apiFetchMock).toHaveBeenCalledTimes(calls);
+ // The normal cache/cadence is unchanged; cached bytes do not clear failure.
+ apiFetchMock.mockResolvedValueOnce(resourceResponse([]));
+ await reopened.result.refetch();
+ expect(reopened.result.error()).toBeUndefined();
+ expect(reopened.result.resources()).toHaveLength(0);
+ reopened.dispose();
+
+ const recovered = mount();
+ await flushAsync();
+ expect(recovered.result.error()).toBeUndefined();
+ expect(recovered.result.resources()).toHaveLength(0);
+ recovered.dispose();
+ });
+
+ it('does not lend a retained read failure to another parent, organisation or default consumer', async () => {
+ const options = {
+ query: 'type=physical_disk&parent=vm-alpha',
+ cacheKey: 'guest-physical-disks:vm-alpha',
+ retainReadError: true,
+ };
+ let dispose!: () => void;
+ let first!: ReturnType<typeof useUnifiedResources>;
+ createRoot((d) => {
+ dispose = d;
+ first = useUnifiedResources(options);
+ });
+ await waitForResourceCount(() => first.resources().length);
+ const failure = new Error('unavailable');
+ apiFetchMock.mockRejectedValueOnce(failure);
+ await expect(first.refetch()).rejects.toBe(failure);
+ dispose();
+
+ const disposals: (() => void)[] = [];
+ let peer!: ReturnType<typeof useUnifiedResources>;
+ let defaultConsumer!: ReturnType<typeof useUnifiedResources>;
+ createRoot((d) => {
+ disposals.push(d);
+ peer = useUnifiedResources({
+ ...options,
+ query: 'type=physical_disk&parent=vm-beta',
+ cacheKey: 'guest-physical-disks:vm-beta',
+ });
+ defaultConsumer = useUnifiedResources({ ...options, retainReadError: false });
+ });
+ await flushAsync();
+ expect(peer.error()).toBeUndefined();
+ expect(defaultConsumer.error()).toBeUndefined();
+ // No organisation may inherit the other organisation's unavailable read.
+ eventBus.emit('org_switched', 'other-org');
+ await flushAsync();
+ expect(peer.error()).toBeUndefined();
+ expect(defaultConsumer.error()).toBeUndefined();
+ for (const cleanup of disposals) cleanup();
+ });
+
it('uses the shared org scope helper for cache and fetch state', () => {
expect(useUnifiedResourcesSource).toContain('normalizeOrgScope(getOrgID())');
expect(useUnifiedResourcesSource).toContain('supportsCanonicalWsHydration');
diff --git a/frontend-modern/src/hooks/useUnifiedResources.ts b/frontend-modern/src/hooks/useUnifiedResources.ts
index 3423a86343..dc22472b76 100644
--- a/frontend-modern/src/hooks/useUnifiedResources.ts
+++ b/frontend-modern/src/hooks/useUnifiedResources.ts
@@ -588,6 +588,9 @@ type UnifiedResourcesSnapshot = {
};
type UnifiedResourcesCacheEntry = {
+ // Opt-in scoped consumers must not forget a failed read on a quick remount.
+ // Retained rows remain available internally; only a successful read clears it.
+ readError?: unknown;
resources: Resource[];
policyPosture: ResourcePolicyPostureSummary | null;
aggregations: UnifiedResourceAggregations | null;
@@ -1507,6 +1510,8 @@ type UseUnifiedResourcesOptions = {
enabled?: Accessor<boolean>;
/** Keep cached/background data inert while another retained route is visible. */
realtimeEnabled?: Accessor<boolean>;
+ /** Retain scoped read failures across remounts until a successful read. */
+ retainReadError?: boolean;
};
export function useUnifiedResources(options?: UseUnifiedResourcesOptions) {
@@ -1550,7 +1555,9 @@ export function useUnifiedResources(options?: UseUnifiedResourcesOptions) {
);
const [facets, setFacets] = createSignal<UnifiedResourceFacets | null>(initialFacets);
const [loading, setLoading] = createSignal(!hasCachedResources);
- const [error, setError] = createSignal<unknown>(undefined);
+ const [error, setError] = createSignal<unknown>(
+ options?.retainReadError ? cacheEntry.readError : undefined,
+ );
const wsStore = getGlobalWebSocketStore();
let refreshHandle: ReturnType<typeof setTimeout> | undefined;
let initialHydrationHandle: ReturnType<typeof setTimeout> | undefined;
@@ -1625,14 +1632,16 @@ export function useUnifiedResources(options?: UseUnifiedResourcesOptions) {
enrichCanonicalAllResourcesCache(allResourcesEntry, fetched);
entryForRequest.realtimeVersion = allResourcesEntry.realtimeVersion;
}
+ if (options?.retainReadError) entryForRequest.readError = undefined;
batch(() => {
applyResources(fetched, entryForRequest);
setError(undefined);
});
return fetched;
} catch (err) {
- if (!background && isCurrentRequest()) {
- setError(err);
+ if (isCurrentRequest()) {
+ if (options?.retainReadError) entryForRequest.readError = err;
+ if (!background || options?.retainReadError) setError(err);
}
throw err;
} finally {
@@ -2141,7 +2150,7 @@ export function useUnifiedResources(options?: UseUnifiedResourcesOptions) {
const scopedAggregations = cacheEntry.aggregations;
const scopedFacets = cacheEntry.facets;
batch(() => {
- setError(undefined);
+ setError(options?.retainReadError ? nextCacheEntry.readError : undefined);
setResources(reconcile(scopedResources, { key: 'id' }));
setResourceSnapshotChange({ version: ++resourceSnapshotVersion, changedIds: null });
setPolicyPosture(scopedPolicyPosture);