diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.md index e437389784..6b405d7902 100644 --- a/docs/release-control/v6/internal/subsystems/alerts.md +++ b/docs/release-control/v6/internal/subsystems/alerts.md @@ -33,6 +33,14 @@ cover the admitted disk alerts, the excluded guest and sibling-node alerts, and the row accent. No alert evaluation, identity, history or notification behaviour changes. +The matcher also admits a node's own storage alerts (usage, offline and ZFS on +`local`, `local-zfs` and the like): alerts whose `metadata.resourceType` is +`storage`, whose `node` is the node's `proxmox.nodeName` and whose `instance` +matches its `proxmox.instance`. Storage sits on its own Proxmox tab, so the +node row is the Overview's only sign that its local pool is filling. Storage +shared across a cluster is recorded under the node `cluster` and never tints a +single node. + ### Runtime alert controls describe only supported scope (28 October 2026) Container Runtime rows expose their existing Offline Alerts control, not an diff --git a/frontend-modern/browser-verification/401542fcdda0e331.json b/frontend-modern/browser-verification/401542fcdda0e331.json new file mode 100644 index 0000000000..485c9edbec --- /dev/null +++ b/frontend-modern/browser-verification/401542fcdda0e331.json @@ -0,0 +1,35 @@ +{ + "version": 1, + "base_sha": "8918a53c3d2de7626e31bb2a847b20417c2e81b7", + "verified_at": "2026-11-02T11:26:40Z", + "result": "passed", + "changed_paths": [ + "frontend-modern/src/utils/alerts.ts" + ], + "content_sha256": { + "frontend-modern/src/utils/alerts.ts": "3dd113842a5694a94703f9426252912be899358dd6158dfaf21e1a32713591ab" + }, + "routes": [ + "/proxmox/overview" + ], + "viewports": [ + { + "width": 1440, + "height": 1000 + }, + { + "width": 390, + "height": 844 + } + ], + "states": [ + "production vite build of this change served by vite preview on pulse-dev against a mock backend (4 Proxmox nodes pve1-pve4 in instance Production West, dark theme)", + "active alerts: usage on pve1 local (resourceType Storage), ZFS pool and device alerts on pve3 local-zfs, usage on shared storage, guest and Docker alerts elsewhere" + ], + "interactions": [ + "read data-workload-alert-accent on every node row at 1440 and 390: West Production A (pve1) and C (pve3) warning, B and D none", + "confirmed from /api/alerts/active and /api/resources that each tinted row's storage alert carries the node's proxmox.nodeName and instance, and that the shared-storage alert tints no node", + "inspected node table screenshots at both widths: yellow stripe and tint on A and C only, rows stay single-line", + "no page errors at either width" + ] +} diff --git a/frontend-modern/src/features/proxmox/__tests__/ProxmoxNodesTable.test.tsx b/frontend-modern/src/features/proxmox/__tests__/ProxmoxNodesTable.test.tsx index f17abf0624..7204e8a3ef 100644 --- a/frontend-modern/src/features/proxmox/__tests__/ProxmoxNodesTable.test.tsx +++ b/frontend-modern/src/features/proxmox/__tests__/ProxmoxNodesTable.test.tsx @@ -566,6 +566,22 @@ describe('ProxmoxNodesTable', () => { 'data-workload-alert-accent', 'critical', ); + cleanup(); + + // Its own storage lives on the Storage tab; the row is the Overview's only sign of it. + activeAlertsMock.value = { + storage: { + ...nodeAlert('storage', 'homelab-pve-node-1-local-zfs'), + type: 'usage', + instance: 'homelab', + metadata: { resourceType: 'storage' }, + }, + }; + renderNode(); + expect(screen.getByText('pve-node-1').closest('tr')).toHaveAttribute( + 'data-workload-alert-accent', + 'critical', + ); }); it('does not present a retained stale update count as current in the node row', () => { diff --git a/frontend-modern/src/utils/__tests__/alerts.test.ts b/frontend-modern/src/utils/__tests__/alerts.test.ts index 7cfca54046..6bb7847ff4 100644 --- a/frontend-modern/src/utils/__tests__/alerts.test.ts +++ b/frontend-modern/src/utils/__tests__/alerts.test.ts @@ -338,6 +338,31 @@ describe('getAlertsForUnifiedResource', () => { ]); }); + it("matches a Proxmox node's own storage alerts but not shared or another node's storage", () => { + const node = resource({ + id: 'agent:pve1', + proxmox: { sourceId: 'homelab-pve1', instance: 'homelab', nodeName: 'pve1' }, + } as Partial); + const storage = (id: string, overrides: Partial) => + alert(id, `${id}-storage`, { + type: 'usage', + instance: 'homelab', + metadata: { resourceType: 'storage' }, + ...overrides, + }); + const active = byId( + storage('local-zfs', { node: 'pve1' }), + // Usage alerts carry the resource type as the backend capitalises it. + storage('local', { node: 'pve1', metadata: { resourceType: 'Storage' } }), + storage('shared-nfs', { node: 'cluster' }), + storage('pve2-local', { node: 'pve2' }), + storage('other-cluster', { node: 'pve1', instance: 'lab' }), + alert('guest-memory', 'homelab:pve1:101', { node: 'pve1', instance: 'homelab' }), + ); + + expect(ids(getAlertsForUnifiedResource(node, active, true))).toEqual(['local-zfs', 'local']); + }); + it("matches a Docker container's alerts on its host and container ID, or its name", () => { const container = resource({ id: 'app-container-b858bc8f1caf601a', diff --git a/frontend-modern/src/utils/alerts.ts b/frontend-modern/src/utils/alerts.ts index 5de41bba25..a845faacc1 100644 --- a/frontend-modern/src/utils/alerts.ts +++ b/frontend-modern/src/utils/alerts.ts @@ -183,7 +183,11 @@ const ALERT_LEVEL_RANK: Record = { critical: 0, warning: // "agent:/raid:", "docker:/". const getUnifiedResourceAlertKeys = ( resource: Resource, -): { exact: Set; componentPrefixes: string[] } => { +): { + exact: Set; + componentPrefixes: string[]; + localStorage?: { node: string; instance?: string }; +} => { const exact = new Set(); const add = (value: string | undefined) => { const trimmed = value?.trim(); @@ -212,6 +216,7 @@ const getUnifiedResourceAlertKeys = ( const machine = new Set(); const componentPrefixes: string[] = []; + let localStorage: { node: string; instance?: string } | undefined; if (resource.type === 'agent' || resource.type === 'docker-host') { const agentId = getActionableAgentIdFromResource(resource); if (agentId) machine.add(agentId.startsWith('agent:') ? agentId : `agent:${agentId}`); @@ -233,10 +238,26 @@ const getUnifiedResourceAlertKeys = ( const instance = resource.proxmox?.instance?.trim(); const nodeName = resource.proxmox?.nodeName?.trim(); if (instance && nodeName) componentPrefixes.push(`${instance}:${nodeName}:disk:`); + // Its own storage (local, local-zfs) raises usage, offline and ZFS alerts + // on the storage id under the node's name. Storage shared across a cluster + // is recorded under "cluster", so it never matches one node. + if (nodeName) localStorage = { node: nodeName, instance }; } machine.forEach(add); componentPrefixes.push(...[...machine].map((key) => `${key}/`)); - return { exact, componentPrefixes }; + return { exact, componentPrefixes, localStorage }; +}; + +const isLocalStorageAlert = ( + alert: Alert, + localStorage: { node: string; instance?: string } | undefined, +): boolean => { + if (!localStorage || alert.node !== localStorage.node) return false; + const resourceType = alert.metadata?.resourceType; + if (typeof resourceType !== 'string' || resourceType.trim().toLowerCase() !== 'storage') { + return false; + } + return !localStorage.instance || !alert.instance || alert.instance === localStorage.instance; }; /** @@ -259,12 +280,13 @@ export function getAlertsForUnifiedResource( alertsEnabled: boolean | undefined = isAlertsDetectionEnabled(), ): Alert[] { if (!alertsEnabled) return []; - const { exact, componentPrefixes } = getUnifiedResourceAlertKeys(resource); + const { exact, componentPrefixes, localStorage } = getUnifiedResourceAlertKeys(resource); return Object.values(activeAlerts) .filter( (alert) => exact.has(alert.resourceId) || - componentPrefixes.some((prefix) => alert.resourceId?.startsWith(prefix)), + componentPrefixes.some((prefix) => alert.resourceId?.startsWith(prefix)) || + isLocalStorageAlert(alert, localStorage), ) .sort( (a, b) =>