mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-12-01 01:52:30 +01:00
Tint a Proxmox node row for its own storage alerts (#3762)
PR 3752 limited the node row's alert accent to the node's own alerts so that a guest's alert no longer tinted its host. It also dropped alerts on the node's own storage pools (local, local-zfs), which the old node-name match caught. Storage sits on its own Proxmox tab, so the node row was the Overview's only sign that a node's local pool is filling or its ZFS pool is degraded. The unified matcher now admits storage alerts (metadata resourceType storage, in any case) whose node and instance are the node's own. Storage shared across a cluster is recorded under the node "cluster" and still tints no single node; guest alerts still stay on guest rows.
This commit is contained in:
@@ -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
|
||||
|
||||
35
frontend-modern/browser-verification/401542fcdda0e331.json
Normal file
35
frontend-modern/browser-verification/401542fcdda0e331.json
Normal file
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -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', () => {
|
||||
|
||||
@@ -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<Resource>);
|
||||
const storage = (id: string, overrides: Partial<Alert>) =>
|
||||
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',
|
||||
|
||||
@@ -183,7 +183,11 @@ const ALERT_LEVEL_RANK: Record<Alert['level'], number> = { critical: 0, warning:
|
||||
// "agent:<id>/raid:<device>", "docker:<id>/<container>".
|
||||
const getUnifiedResourceAlertKeys = (
|
||||
resource: Resource,
|
||||
): { exact: Set<string>; componentPrefixes: string[] } => {
|
||||
): {
|
||||
exact: Set<string>;
|
||||
componentPrefixes: string[];
|
||||
localStorage?: { node: string; instance?: string };
|
||||
} => {
|
||||
const exact = new Set<string>();
|
||||
const add = (value: string | undefined) => {
|
||||
const trimmed = value?.trim();
|
||||
@@ -212,6 +216,7 @@ const getUnifiedResourceAlertKeys = (
|
||||
|
||||
const machine = new Set<string>();
|
||||
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) =>
|
||||
|
||||
Reference in New Issue
Block a user