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.

Invalidate stale summary chart caches

rcourtman97da398d2b66
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
index f0a554c0e9..8d6e074f97 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -238,6 +238,12 @@ scroll-preserving row focus must extend
`frontend-modern/src/components/shared/contextualFocus.ts` instead of
rebuilding page-local `Set` scans or scroll repair logic in dashboard,
infrastructure, or workloads hot paths.
+That same hot-path ownership now includes summary cache invalidation.
+Infrastructure and workload summary caches may hydrate charts for fast remounts,
+but when the summary chart timeline contract changes, the cache version must
+advance and stale payloads must be purged on read so long-lived browser sessions
+cannot keep rendering pre-fix sparkline shapes after the backend timeline model
+has been corrected.
That same hot-path rule now applies to infrastructure summary resource
filtering: `frontend-modern/src/components/Infrastructure/useInfrastructureSummaryState.ts`
must include API-backed systems such as top-level TrueNAS appliances through
diff --git a/frontend-modern/src/components/Workloads/WorkloadsSummary.test.tsx b/frontend-modern/src/components/Workloads/WorkloadsSummary.test.tsx
index ad015137d9..4c6f8bf011 100644
--- a/frontend-modern/src/components/Workloads/WorkloadsSummary.test.tsx
+++ b/frontend-modern/src/components/Workloads/WorkloadsSummary.test.tsx
@@ -219,10 +219,11 @@ describe('WorkloadsSummary performance behavior', () => {
});
});
- it('ignores stale cache versions while waiting for live fetch', async () => {
+ it('ignores and purges stale cache versions on failed live fetch', async () => {
const staleWorkloadId = 'cluster-a:pve1:stale';
+ const cacheKey = 'pulse.workloadsSummaryCharts.default::1h::__all__';
localStorage.setItem(
- 'pulse.workloadsSummaryCharts.default::1h::__all__',
+ cacheKey,
JSON.stringify({
version: 0,
range: '1h',
@@ -232,7 +233,7 @@ describe('WorkloadsSummary performance behavior', () => {
dockerData: {},
}),
);
- mockGetWorkloadCharts.mockImplementationOnce(() => new Promise(() => {}));
+ mockGetWorkloadCharts.mockRejectedValueOnce(new Error('network down'));
render(() => (
<WorkloadsSummary
@@ -246,8 +247,11 @@ describe('WorkloadsSummary performance behavior', () => {
expect(mockGetWorkloadCharts).toHaveBeenCalledTimes(1);
});
- expect(screen.queryByTestId('sparkline')).not.toBeInTheDocument();
- expect(screen.getAllByTestId('sparkline-skeleton')).toHaveLength(4);
+ await waitFor(() => {
+ expect(screen.queryByTestId('sparkline')).not.toBeInTheDocument();
+ expect(screen.getAllByText('Trend data unavailable')).toHaveLength(4);
+ expect(localStorage.getItem(cacheKey)).toBeNull();
+ });
});
it('requests fewer chart points for large workload sets', async () => {
diff --git a/frontend-modern/src/components/Workloads/WorkloadsSummary.tsx b/frontend-modern/src/components/Workloads/WorkloadsSummary.tsx
index e36ccd58a2..adf3294f12 100644
--- a/frontend-modern/src/components/Workloads/WorkloadsSummary.tsx
+++ b/frontend-modern/src/components/Workloads/WorkloadsSummary.tsx
@@ -102,7 +102,7 @@ const WORKLOAD_COLORS = [
];
const WORKLOADS_SUMMARY_CACHE_PREFIX = 'pulse.workloadsSummaryCharts.';
-const WORKLOADS_SUMMARY_CACHE_VERSION = 5;
+const WORKLOADS_SUMMARY_CACHE_VERSION = 6;
const WORKLOADS_SUMMARY_CACHE_MAX_AGE_MS = 5 * 60_000;
const WORKLOADS_SUMMARY_CACHE_MAX_POINTS_PER_SERIES = 360;
const WORKLOADS_SUMMARY_CACHE_MAX_CHARS = 900_000;
@@ -233,6 +233,7 @@ const readWorkloadsSummaryCache = (
parsed.nodeScope !== nodeScope ||
typeof parsed.cachedAt !== 'number'
) {
+ window.localStorage.removeItem(cacheKeyFor(range, nodeScope, orgScope));
return null;
}
if (Date.now() - parsed.cachedAt > WORKLOADS_SUMMARY_CACHE_MAX_AGE_MS) {
diff --git a/frontend-modern/src/utils/infrastructureSummaryCache.ts b/frontend-modern/src/utils/infrastructureSummaryCache.ts
index a92aff1604..a6591ad167 100644
--- a/frontend-modern/src/utils/infrastructureSummaryCache.ts
+++ b/frontend-modern/src/utils/infrastructureSummaryCache.ts
@@ -11,7 +11,7 @@ import { eventBus } from '@/stores/events';
export const INFRA_SUMMARY_CACHE_PREFIX = 'pulse.infrastructureSummaryCharts.';
export const INFRA_SUMMARY_CACHE_MAX_AGE_MS = 5 * 60_000;
-const INFRA_SUMMARY_CACHE_VERSION = 2;
+const INFRA_SUMMARY_CACHE_VERSION = 4;
const INFRA_SUMMARY_CACHE_MAX_CHARS = 900_000;
const INFRA_SUMMARY_CACHE_MAX_POINTS_PER_SERIES = 360;
@@ -233,6 +233,7 @@ export function readInfrastructureSummaryCache(
parsed.range !== range ||
typeof parsed.cachedAt !== 'number'
) {
+ window.localStorage.removeItem(cacheKeyForRange(range, scopedOrg));
return null;
}