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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Alert on failed PBS datastore jobs, apart from guest health
rcourtman24c9bfb8f1f1
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex 1f19cde52f..d14260738b 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -10745,6 +10745,14 @@ through both monitor initialization paths, including explicit and legacydefault organizations. These notifications refresh inventory presentation;they do not grant enrollment, removal, re-enrollment or command authority.+### PBS job failure carry preserves lifecycle authority (3 November 2026)++`State.PBSJobHealthEvidence` is a read-only copy of the job results already+stored for one PBS instance, read by the PBS poller to carry a failed job+across polls. It adds no agent enrollment, credential, command, collection or+remediation authority, never triggers a poll or a job, and leaves agent+records untouched.+### Backup jobs history preserves lifecycle authority (2 November 2026)`GET /api/backups/jobs` reads current tenant inventory and retained `pve-task:`diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex 323f130ce5..6f1c94d060 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -590,6 +590,16 @@ the widest datastore share. The table therefore no longer consumesfrom that rule's required consumers. The memory cell's multi-line "Last known"qualifier went with it, so every row is now single-line by construction.+### Backup health lists datastore job failures in their own rows (3 November 2026)++`ProxmoxBackupsCoverageStrip` takes `datastoreProblems` and renders them as a+separate "Datastores with failed jobs" list under the guest rows, on the same+row grid: amber dot, "Sync failed", a datastore-count pill, and the datastore+names where a reason row's share bar sits, since a datastore is not a share of+rated guests. Rows stay 32px and single-line; names truncate on phones and the+accessible name and title carry them in full. The list renders even when no+guests are rated.+### Datastore fill forecast stays on one row line (2 November 2026)`ProxmoxBackupServersTable` shows a PBS datastore's fill forecast as thediff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.mdindex d4db747e21..d43897b90f 100644--- a/docs/release-control/v6/internal/subsystems/monitoring.md+++ b/docs/release-control/v6/internal/subsystems/monitoring.md@@ -142,6 +142,21 @@ admission, cancellation, runtime/client replacement and old-worker completion.Source-bound desktop/narrow Backups proof consumes produced partial/recoveryframes. This is truthful collection, not original frozen-guest recovery.+### PBS job failures persist until a newer outcome is observed (3 November 2026)++`pollPBSInstance` now passes each poll's job results through+`carryPBSJobFailures` with the results last stored for that instance+(`State.PBSJobHealthEvidence`). A job whose last completed run failed stays+`critical`/`last-run-failed` while PBS reports no newer outcome: `/admin`+drops the previous result while the next run is in progress, an overdue or+unreadable job reports none, and a failed read lists no jobs. The carried+failure clears on an observed success or warning, or when a complete read+drops or disables the job. Jobs are keyed by family plus id, since PBS ids are+unique only within a family. `pbsJobHealthPosture` now ranks a failed last+run above overdue, so a failed job that has also missed its next run reads+failed, not late. This keeps the datastore job alert from flapping (#1815).+Mock PBS instances report job results with one failed secondary sync.+### PBS job run status comes from the admin endpoints (2 November 2026)`pkg/pbs.Client.GetJobHealthEvidence` reads configured sync, verify and prunediff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.mdindex 41ccee1175..bfff95c08d 100644--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md@@ -15,6 +15,15 @@## Purpose+### PBS job failure carry is bounded per instance (3 November 2026)++Each PBS poll copies only that instance's stored job results+(`State.PBSJobHealthEvidence`) rather than a full state snapshot, and+`carryPBSJobFailures` is linear in that instance's jobs. Datastore job+incidents add at most one incident per failed job to the datastore resource.+The mock fixture adds seven PBS job results across two instances, so large+mock estates gain no per-guest work.+### Drawer live-readings strip adds no history work (2 November 2026)`GuestDrawerHistory` renders its "Latest readings" strip only in place ofdiff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex 50b60114f1..e84eb2daf9 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -5103,6 +5103,21 @@ keeps its columns aligned. Rows stay 32px, the accessible names are unchanged,and the phone bar narrows from 5rem to 4rem to make room. Which workloads eachreason selects is unchanged.+### Failed PBS jobs are datastore problems, with an alert (3 November 2026)++A PBS sync, verify, prune or garbage-collection job whose newest run failed on+a datastore is now that datastore's problem, not a guest's. Backup health lists+it in its own "Datastores with failed jobs" rows below the guest reasons ("Sync+failed", the datastore count, the names), and each row brings the Backup+servers table into view. The guest verdict is unchanged: in the #1815 case the+guest's primary backup succeeded and stays protected while the failed copy to+the second store shows and alerts on its own. The rows and the alert use the+Jobs column's judgment (`summarizeDatastoreJobs`): only a failure pinned to the+datastore counts, the newest run of each job speaks, and storeless task history+or a late, warned or unknown job never does. Durable PBS task history, a Tasks+view, secondary-copy lag and PBS jobs in the 14-day Backup jobs chart remain+open under the cross-system task outcomes entry.+### Task history no longer marks a datastore job family unknown (2 November 2026)`summarizeDatastoreJobs` treats a family as unread for every datastore onlydiff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.mdindex caeedb6a33..cc508c9d37 100644--- a/docs/release-control/v6/internal/subsystems/unified-resources.md+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md@@ -222,6 +222,27 @@ narrow browser proof exercises the same producer through the inventory consumerwith native interactions and inspected pixels. No API, provider, guest, polling,auth, resource identity or protection-policy change, nor installed recovery claim.+### PBS datastores carry failed jobs as incidents (3 November 2026)++`resourceFromPBSDatastore` appends one `pbs_job_failed` incident per sync,+verify, prune or GC job whose newest run failed on that datastore+(`pbsDatastoreJobIncidents`). Severity is warning, the category is+recoverability, the native id is `pbs-datastore:<store>:job:<family>:<job id>`+(PBS job ids are unique only within a family), and the+summary names the job and a sync's remote without times, because incidents+merge on their summary. The existing unified-incident pipeline raises a+`backup-storage-incident` alert on the datastore and clears it when the job's+newest run succeeds; the storage disable switch and per-resource overrides+apply. Storeless task history, disabled jobs, backup-family jobs and warning,+late or unknown runs raise nothing. So the alert neither flaps nor clears+early, the PBS poller carries a job's last completed failure+(`carryPBSJobFailures`) through polls that report no newer outcome: a run in+progress (PBS drops the previous result meanwhile), an overdue or unreadable+job, or a failed read. It clears on an observed success or warning, or when a+complete read drops or disables the job. A failed last run now outranks+overdue in `pbsJobHealthPosture`. Mock PBS instances now report job results,+with one failed sync on the secondary server.+### Storeless PBS task history is not an unread job family (2 November 2026)The Backups Jobs column reads `PBSJobHealthEvidence.evidenceScope`: adiff --git a/frontend-modern/browser-verification/c75402bb5105192c.json b/frontend-modern/browser-verification/c75402bb5105192c.jsonnew file mode 100644index 0000000000..049d227169--- /dev/null+++ b/frontend-modern/browser-verification/c75402bb5105192c.json@@ -0,0 +1,40 @@+{+ "version": 1,+ "base_sha": "a315a4878070098435213143ea6587f15dbda12e",+ "verified_at": "2026-11-03T10:23:03Z",+ "result": "passed",+ "changed_paths": [+ "frontend-modern/src/features/proxmox/ProxmoxBackupsCoverageStrip.tsx",+ "frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx",+ "frontend-modern/src/features/proxmox/proxmoxBackupServerJobs.ts"+ ],+ "content_sha256": {+ "frontend-modern/src/features/proxmox/ProxmoxBackupsCoverageStrip.tsx": "2feadfd18f169131ba4a3aeff3e69d83010d7fc5c5ebe659d82f0534bf3fea41",+ "frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx": "af734a64cec4347f31f947b16c0bb670f0074dd92423266c4d21e16bfc31a2e9",+ "frontend-modern/src/features/proxmox/proxmoxBackupServerJobs.ts": "e37dcdca685e690eeae8750140adbe02120e5b37b2384ea0c89f4ec9a216655e"+ },+ "routes": [+ "/proxmox/backups/coverage",+ "/api/alerts/active"+ ],+ "viewports": [+ {+ "width": 1024,+ "height": 607+ },+ {+ "width": 375,+ "height": 812+ }+ ],+ "states": [+ "mock mode built from this change on pulse-dev: dr-vault reports a failed sync job into its primary-vault datastore (copying from backup-vault) while every backup succeeded; all other PBS jobs report OK",+ "desktop and phone layouts, dark theme"+ ],+ "interactions": [+ "Backup health keeps the guest verdict (457 / 929 protected) and adds a DATASTORE JOBS heading with one 32px row: amber dot, Sync failed, count 1, primary-vault (dr-vault); its accessible name is Sync failed on 1 datastore: primary-vault (dr-vault)",+ "the Backup servers Jobs column shows OK, OK and Sync failed on the same datastore",+ "/api/alerts/active carries one warning backup-storage-incident: Sync job s-primary-vault failed on datastore primary-vault (copying from backup-vault)",+ "at 1024px clicking the row scrolls the Backup servers table to the top of the view; at 375x812 the row stays single-line with the name truncated and no horizontal overflow, the State column reads Sync failed; smooth scroll did not run in this pane emulation for this row or the existing exception rows, while a direct scrollIntoView did"+ ]+}diff --git a/frontend-modern/src/features/proxmox/ProxmoxBackupsCoverageStrip.tsx b/frontend-modern/src/features/proxmox/ProxmoxBackupsCoverageStrip.tsxindex 84d7d17c2f..53c5d041b5 100644--- a/frontend-modern/src/features/proxmox/ProxmoxBackupsCoverageStrip.tsx+++ b/frontend-modern/src/features/proxmox/ProxmoxBackupsCoverageStrip.tsx@@ -9,6 +9,7 @@ import type {BackupVerdict,BackupVerdictTone,} from './proxmoxBackupVerdict';+import type { DatastoreJobFailureGroup } from './proxmoxBackupServerJobs';// The Backup health card answers "is everything backed up?" the way the// Proxmox overview tables do: the protected count sits in the header strip,@@ -27,6 +28,10 @@ export interface CoverageStripProps {rule?: JSX.Element;isGroupPressed?: (key: string) => boolean;onSelectGroup?: (key: string) => void;+ // Failed datastore jobs: problems with the backups' home, not with any+ // guest, so they never count against the protected verdict.+ datastoreProblems?: readonly DatastoreJobFailureGroup[];+ onSelectDatastoreProblem?: () => void;}const TONE_DOT_CLASS: Record<BackupVerdictTone, string> = {@@ -87,6 +92,22 @@ const previewNames = (group: BackupExceptionGroup, pressed: boolean): string =>const accessibleName = (group: BackupExceptionGroup): string =>`${group.rows.length} ${group.label.charAt(0).toLowerCase()}${group.label.slice(1)}`;+const datastoreProblemName = (group: DatastoreJobFailureGroup): string =>+ `${group.label} on ${group.datastores.length} ${+ group.datastores.length === 1 ? 'datastore' : 'datastores'+ }: ${group.datastores.join(', ')}`;++// Same grid as a reason row; the datastore names stand where the share bar+// would, since a datastore is not a share of rated guests.+const DatastoreProblemCells: Component<{ group: DatastoreJobFailureGroup }> = (props) => (+ <>+ <span class={`h-2 w-2 rounded-full ${ROW_TONE.attention.dot}`} aria-hidden="true" />+ <span class="min-w-0 truncate text-left text-base-content">{props.group.label}</span>+ <span class={`${PILL_BASE} ${ROW_TONE.attention.pill}`}>{props.group.datastores.length}</span>+ <span class="min-w-0 truncate text-left text-muted">{props.group.datastores.join(', ')}</span>+ </>+);+const percentOf = (count: number, total: number): number =>total > 0 ? Math.round((count / total) * 100) : 0;@@ -229,6 +250,47 @@ export const ProxmoxBackupsCoverageStrip: Component<CoverageStripProps> = (props</div></Show></Show>+ <Show when={(props.datastoreProblems?.length ?? 0) > 0}>+ {/* A heading keeps these apart from the guest counts above them. */}+ <div+ class="border-t border-border px-3 pt-2 pb-0.5 text-[10px] font-semibold uppercase tracking-wide text-muted"+ aria-hidden="true"+ >+ Datastore jobs+ </div>+ <ul class="divide-y divide-border" aria-label="Datastores with failed jobs">+ <For each={props.datastoreProblems}>+ {(group) => (+ <li class="flex" data-backup-datastore-problem={group.family}>+ <Show+ when={props.onSelectDatastoreProblem}+ fallback={+ <span class={`${ROW_GRID} h-8`} title={datastoreProblemName(group)}>+ <DatastoreProblemCells group={group} />+ </span>+ }+ >+ {(onSelect) => (+ <button+ type="button"+ class={`${ROW_GRID} group/reason h-8 hover:bg-surface-hover focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-blue-500`}+ aria-label={datastoreProblemName(group)}+ title={`Show in Backup servers: ${group.datastores.join(', ')}`}+ onClick={() => onSelect()()}+ >+ <DatastoreProblemCells group={group} />+ <ChevronRightIcon+ class="h-3.5 w-3.5 justify-self-end text-muted group-hover/reason:text-base-content"+ aria-hidden="true"+ />+ </button>+ )}+ </Show>+ </li>+ )}+ </For>+ </ul>+ </Show><Show when={props.rule}><detailsclass="group border-t border-border px-3 py-1.5 text-[11px] text-muted"diff --git a/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsxindex 705e2a5fa4..9212bc607a 100644--- a/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx+++ b/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx@@ -74,6 +74,7 @@ import {describeUnreadBackupSources,} from './proxmoxBackupUnreadSources';import { ProxmoxBackupServersTable } from './ProxmoxBackupServersTable';+import { collectDatastoreJobFailures } from './proxmoxBackupServerJobs';import { ProxmoxCoverageTable } from './ProxmoxCoverageTable';import { resolveBackupLocationFilter } from './proxmoxBackupLocation';import { ProxmoxRecoverableTable } from './ProxmoxRecoverableTable';@@ -516,6 +517,7 @@ export const ProxmoxBackupsTable: Component<{const backupVerdict = createMemo(() =>buildBackupVerdict(recoveryModel().coverageRows, protectionPostures.policy()),);+ const datastoreJobFailures = createMemo(() => collectDatastoreJobFailures(props.servers ?? []));const view = (): BackupView => routeView() ?? legacyQueryView() ?? PROXMOX_BACKUPS_DEFAULT_VIEW;const backupViewPath = (next: BackupView): string => {@@ -547,6 +549,16 @@ export const ProxmoxBackupsTable: Component<{// Restore points sit below the summary and the backup servers. On a phone an// exception tap would otherwise filter a list the reader cannot see, so// bring it into view; when it already shows, leave the page where it is.+ // A failed datastore job points at its row in Backup servers, which sits+ // right below the summary; bring it into view the same way.+ let backupServers: HTMLDivElement | undefined;+ const revealBackupServers = (): void => {+ if (!backupServers?.isConnected || typeof backupServers.scrollIntoView !== 'function') return;+ const reduceMotion =+ typeof window.matchMedia === 'function' &&+ window.matchMedia('(prefers-reduced-motion: reduce)').matches;+ backupServers.scrollIntoView({ block: 'start', behavior: reduceMotion ? 'auto' : 'smooth' });+ };const revealRestorePoints = (): void => {queueMicrotask(() => {const target = restorePoints;@@ -819,6 +831,8 @@ export const ProxmoxBackupsTable: Component<{<div class="grid gap-3 xl:[&:has([data-backup-jobs])]:grid-cols-[minmax(0,3fr)_minmax(0,2fr)]"><ProxmoxBackupsCoverageStriptitle="Backup health"+ datastoreProblems={datastoreJobFailures()}+ onSelectDatastoreProblem={revealBackupServers}rule={<Show when={getBackupPostureRuleText(protectionPostures.policy())}>{(rule) => <span data-coverage-posture-rule>{rule()}</span>}@@ -871,14 +885,20 @@ export const ProxmoxBackupsTable: Component<{Keep this owner mounted through loading, failure and ordinary retries,between the summary above and the restore points below. */}<Show when={(props.servers?.length ?? 0) > 0}>- <ProxmoxBackupServersTable- servers={props.servers ?? []}- backups={pbsArtifacts()}- datastoreAlerts={props.datastoreAlerts}- backupInventoryState={- pbsBackups.error() ? 'unavailable' : pbsBackups.resolvedOnce() ? 'available' : 'loading'- }- />+ <div ref={backupServers} class="scroll-mt-4" data-backup-servers-section>+ <ProxmoxBackupServersTable+ servers={props.servers ?? []}+ backups={pbsArtifacts()}+ datastoreAlerts={props.datastoreAlerts}+ backupInventoryState={+ pbsBackups.error()+ ? 'unavailable'+ : pbsBackups.resolvedOnce()+ ? 'available'+ : 'loading'+ }+ />+ </div></Show>{/* Restore points come last: By date and Coverage, reached by search orby tapping an exception above. Same readiness as the summary, whosediff --git a/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx b/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsxindex dc1558340e..3acf73aec8 100644--- a/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx+++ b/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx@@ -770,6 +770,64 @@ describe('ProxmoxBackupsTable', () => {});});+ it('lists a failed PBS sync as a datastore problem while the guest stays protected (#1815)', async () => {+ mockBackupAPIs();+ window.history.replaceState({}, '', '/proxmox/backups/coverage');+ const scrollIntoView = vi.fn();+ const prototype = HTMLElement.prototype as { scrollIntoView?: (arg?: unknown) => void };+ const original = prototype.scrollIntoView;+ prototype.scrollIntoView = scrollIntoView;+ try {+ const server = {+ ...pbsServerResource,+ pbs: {+ ...pbsServerResource.pbs!,+ jobHealthEvidence: [+ {+ id: 's-main',+ family: 'sync',+ store: 'main',+ remote: 'pbs-offsite',+ enabled: true,+ confidence: 'config-last-run',+ posture: 'critical',+ postureReason: 'last-run-failed',+ },+ ],+ },+ } as Resource;+ renderInRouter(() => (+ <ProxmoxBackupsTable+ emptyIcon={<span />}+ workloads={[workloadResource]}+ servers={[server]}+ />+ ));++ await waitFor(() =>+ expect(document.querySelector('[data-backup-verdict]')).toHaveTextContent(+ '1 of 1 protected',+ ),+ );+ const problems = within(screen.getByRole('list', { name: 'Datastores with failed jobs' }));+ const row = problems.getByRole('button', { name: 'Sync failed on 1 datastore: main' });+ expect(row).toHaveTextContent('Sync failed');+ expect(row).toHaveAttribute('title', 'Show in Backup servers: main');+ // The datastore problem is not a guest: no guest exception appears.+ expect(+ screen.queryByRole('list', { name: 'Backups that are not protected' }),+ ).toBeEmptyDOMElement();++ fireEvent.click(row);+ expect(scrollIntoView).toHaveBeenCalledTimes(1);+ expect(scrollIntoView.mock.contexts[0]).toBe(+ document.querySelector('[data-backup-servers-section]'),+ );+ } finally {+ prototype.scrollIntoView = original;+ }+ });+it('states the verdict and names each exception group by its reason', async () => {mockBackupAPIs('attention');window.history.replaceState({}, '', '/proxmox/backups/date');diff --git a/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupServerJobs.test.ts b/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupServerJobs.test.tsindex 547e08a620..80ea70ec3e 100644--- a/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupServerJobs.test.ts+++ b/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupServerJobs.test.ts@@ -2,7 +2,13 @@ import { describe, expect, it } from 'vitest';import type { PBSJobHealthEvidence } from '@/types/api';-import { describeDatastoreJobs, summarizeDatastoreJobs } from '../proxmoxBackupServerJobs';+import type { Resource } from '@/types/resource';++import {+ collectDatastoreJobFailures,+ describeDatastoreJobs,+ summarizeDatastoreJobs,+} from '../proxmoxBackupServerJobs';const job = (overrides: Partial<PBSJobHealthEvidence>): PBSJobHealthEvidence => ({id: 'job',@@ -73,6 +79,18 @@ describe('summarizeDatastoreJobs', () => {expect(summary.entries).toHaveLength(1);});+ it('keeps families that share a job id apart', () => {+ const summary = summarizeDatastoreJobs(+ [+ job({ id: 'daily', family: 'sync', posture: 'critical', postureReason: 'last-run-failed' }),+ job({ id: 'daily', family: 'verify', 'last-run-endtime': 2_000 }),+ ],+ 'main',+ );+ expect(summary.label).toBe('Sync failed');+ expect(summary.entries).toHaveLength(2);+ });+it('never reports a family as OK when its server-wide read failed', () => {const summary = summarizeDatastoreJobs([@@ -167,3 +185,51 @@ describe('summarizeDatastoreJobs', () => {expect(summarizeDatastoreJobs([job({})], undefined).label).toBe('—');});});++describe('collectDatastoreJobFailures', () => {+ const server = (name: string, evidence: PBSJobHealthEvidence[]): Resource =>+ ({+ id: name,+ name,+ type: 'pbs',+ pbs: {+ datastores: [+ { name: 'main', total: 1, used: 0 },+ { name: 'offsite', total: 1, used: 0 },+ ],+ jobHealthEvidence: evidence,+ },+ }) as unknown as Resource;++ it('groups failed jobs by family and names the datastores they hit (#1815)', () => {+ const groups = collectDatastoreJobFailures([+ server('vault', [+ job({ id: 'b-1', family: 'backup', store: 'main' }),+ job({ id: 's-1', family: 'sync', store: 'offsite', posture: 'critical' }),+ job({ id: 'v-1', family: 'verify', store: 'offsite', posture: 'warning' }),+ job({ id: 'garbage:main', family: 'garbage', store: 'main', posture: 'critical' }),+ ]),+ ]);+ expect(groups).toEqual([+ { family: 'sync', label: 'Sync failed', datastores: ['offsite'] },+ { family: 'garbage', label: 'GC failed', datastores: ['main'] },+ ]);+ });++ it('leaves out storeless failures and a job whose newest run succeeded', () => {+ const groups = collectDatastoreJobFailures([+ server('vault', [+ job({ id: 'sync:task', family: 'sync', store: undefined, posture: 'critical' }),+ job({ id: 'v-1', posture: 'critical', 'last-run-endtime': 1_000 }),+ job({ id: 'v-1', 'last-run-endtime': 2_000 }),+ ]),+ ]);+ expect(groups).toEqual([]);+ });++ it('names the server once more than one is connected', () => {+ const failed = [job({ id: 's-1', family: 'sync', store: 'offsite', posture: 'critical' })];+ const groups = collectDatastoreJobFailures([server('vault', failed), server('dr', failed)]);+ expect(groups[0].datastores).toEqual(['offsite (dr)', 'offsite (vault)']);+ });+});diff --git a/frontend-modern/src/features/proxmox/proxmoxBackupServerJobs.ts b/frontend-modern/src/features/proxmox/proxmoxBackupServerJobs.tsindex e66cc113e7..74b6974717 100644--- a/frontend-modern/src/features/proxmox/proxmoxBackupServerJobs.ts+++ b/frontend-modern/src/features/proxmox/proxmoxBackupServerJobs.ts@@ -1,4 +1,5 @@import type { PBSJobHealthEvidence } from '@/types/api';+import type { Resource } from '@/types/resource';// "Is my PBS OK?" needs the datastore's housekeeping, not just its fill: a// failed sync means the offsite copy is stale, a failed verify means restores@@ -106,13 +107,14 @@ export function summarizeDatastoreJobs(.filter(isDatastoreFamily),);- // Task history can repeat a job; the newest run of each job id speaks for it.+ // Task history can repeat a job; the newest run of each job speaks for it.+ // Job ids are unique only within a family, so the family is part of the key.const newestById = new Map<string, PBSJobHealthEvidence>();for (const entry of evidence) {const family = normalize(entry.family);if (!isDatastoreFamily(family) || entry.enabled === false) continue;if (entry.store?.trim() !== store) continue;- const id = entry.id?.trim() || `${family}:${store}`;+ const id = `${family}:${entry.id?.trim() || store}`;const previous = newestById.get(id);if (!previous || runTime(entry) >= runTime(previous)) newestById.set(id, entry);}@@ -157,3 +159,40 @@ export const describeDatastoreJobs = (summary: DatastoreJobSummary): string =>summary.entries.length === 0? 'No PBS jobs reported for this datastore': summary.entries.map((entry) => `${entry.familyLabel} ${entry.outcomeLabel}`).join(' · ');++// Backup health lists guests, but a failed sync, verify, prune or GC run is a+// datastore problem: the guests' own backups can be fine while the offsite+// copy is stale (#1815). Each failed family becomes one row naming the+// datastores it hit, from the same judgment the Jobs column shows. Only a+// failure pinned to a datastore counts; storeless history stays "unknown" in+// that column and never reaches this list, matching the backend alert.+export interface DatastoreJobFailureGroup {+ family: string;+ label: string;+ datastores: string[];+}++const FAILURE_ROW_ORDER = ['sync', 'verify', 'prune', 'garbage'] as const;++export function collectDatastoreJobFailures(+ servers: readonly Resource[],+): DatastoreJobFailureGroup[] {+ const pbsServers = servers.filter((server) => server.type === 'pbs');+ const nameServer = pbsServers.length > 1;+ const byFamily = new Map<string, string[]>();+ for (const server of pbsServers) {+ for (const datastore of server.pbs?.datastores ?? []) {+ const summary = summarizeDatastoreJobs(server.pbs?.jobHealthEvidence, datastore.name);+ const failed = new Set(+ summary.entries.filter((entry) => entry.state === 'critical').map((entry) => entry.family),+ );+ const name = nameServer ? `${datastore.name} (${server.name})` : datastore.name;+ for (const family of failed) byFamily.set(family, [...(byFamily.get(family) ?? []), name]);+ }+ }+ return FAILURE_ROW_ORDER.filter((family) => byFamily.has(family)).map((family) => ({+ family,+ label: `${FAMILY_LABEL[family]} failed`,+ datastores: [...byFamily.get(family)!].sort((left, right) => left.localeCompare(right)),+ }));+}diff --git a/internal/alerts/unified_incidents_test.go b/internal/alerts/unified_incidents_test.goindex 37976b396b..7e1443f327 100644--- a/internal/alerts/unified_incidents_test.go+++ b/internal/alerts/unified_incidents_test.go@@ -1423,3 +1423,51 @@ func TestPBSCapacityUsesStoragePolicyNotTopologyBands(t *testing.T) {t.Fatal("capacity policy hid datastore failure")}}++// #1815: a failed PBS-to-PBS sync raises its own alert on the store the sync+// writes to, through the ordinary incident pipeline, and the alert clears once+// the job's newest run succeeds. Guest protection is not involved.+func TestSyncUnifiedResourceIncidentsAlertsOnFailedPBSSyncJob(t *testing.T) {+ m := newTestManager(t)+ configureUnifiedEvalManager(t, m, unifiedEvalBaseConfig())++ ranAt := time.Now().Add(-time.Hour).UTC().Truncate(time.Second)+ snapshot := func(posture string) []unifiedresources.Resource {+ instance := models.PBSInstance{+ ID: "pbs-main", Name: "main", Status: "online", LastSeen: time.Now(),+ Datastores: []models.PBSDatastore{+ {Name: "fast", Status: "available", Total: 1000, Used: 100, Free: 900, Usage: 10},+ {Name: "offsite", Status: "available", Total: 1000, Used: 100, Free: 900, Usage: 10},+ },+ JobHealthEvidence: []models.PBSJobHealthEvidence{{+ ID: "s-offsite", Family: "sync", Store: "offsite", Remote: "pbs-main", Enabled: true,+ Posture: posture, LastRunEndtime: ranAt.Unix(),+ Freshness: models.PBSJobHealthFreshness{LastRunEndTime: ranAt},+ }},+ }+ registry := unifiedresources.NewRegistry(unifiedresources.NewMemoryStore())+ registry.IngestSnapshot(models.StateSnapshot{PBSInstances: []models.PBSInstance{instance}})+ return registry.List()+ }++ m.SyncUnifiedResourceIncidents(snapshot("critical"))+ active := m.GetActiveAlerts()+ if len(active) != 1 {+ t.Fatalf("expected one failed-sync alert, got %d: %+v", len(active), active)+ }+ alert := active[0]+ if alert.Type != "backup-storage-incident" || alert.Level != AlertLevelWarning {+ t.Fatalf("alert type/level = %q/%q, want backup-storage-incident/warning", alert.Type, alert.Level)+ }+ if want := "Sync job s-offsite failed on datastore offsite (copying from pbs-main)"; alert.Message != want {+ t.Fatalf("message = %q, want %q", alert.Message, want)+ }+ if alert.ResourceName != "offsite" {+ t.Fatalf("resource name = %q, want the sync's store", alert.ResourceName)+ }++ m.SyncUnifiedResourceIncidents(snapshot("healthy"))+ if active := m.GetActiveAlerts(); len(active) != 0 {+ t.Fatalf("a succeeded sync must clear the alert, got %+v", active)+ }+}diff --git a/internal/mock/demo_scenarios.go b/internal/mock/demo_scenarios.goindex 83f761d369..01e60fe57d 100644--- a/internal/mock/demo_scenarios.go+++ b/internal/mock/demo_scenarios.go@@ -1183,12 +1183,25 @@ func applyDemoStorageScenario(state *models.StateSnapshot, now time.Time) {state.PBSInstances[i].LastSeen = demoRecentSeenAt(now, "pbs", state.PBSInstances[i].ID, state.PBSInstances[i].Name)if len(state.PBSInstances[i].Datastores) > 0 {datastoreNames := []string{"primary-vault", "offsite-vault", "replica-vault"}+ renamed := make(map[string]string, len(state.PBSInstances[i].Datastores))for j := range state.PBSInstances[i].Datastores {if j < len(datastoreNames) {+ renamed[state.PBSInstances[i].Datastores[j].Name] = datastoreNames[j]state.PBSInstances[i].Datastores[j].Name = datastoreNames[j]}state.PBSInstances[i].Datastores[j].Status = "online"}+ // Job results name their datastore; keep them on the renamed store.+ for j := range state.PBSInstances[i].JobHealthEvidence {+ job := &state.PBSInstances[i].JobHealthEvidence[j]+ if name, ok := renamed[job.Store]; ok {+ job.ID = strings.ReplaceAll(job.ID, job.Store, name)+ job.Store = name+ }+ if job.Family == "sync" {+ job.Remote = "backup-vault"+ }+ }}}diff --git a/internal/mock/generator.go b/internal/mock/generator.goindex 6eed541169..f66ea9d739 100644--- a/internal/mock/generator.go+++ b/internal/mock/generator.go@@ -6010,9 +6010,54 @@ func generatePBSInstances() []models.PBSInstance {})}+ // Job results as the PBS poller reports them, so the Jobs column and+ // datastore job alerts have something to show. The secondary's sync from+ // the primary failed while every backup succeeded: the #1815 case.+ now := time.Now()+ pbsInstances[0].JobHealthEvidence = []models.PBSJobHealthEvidence{+ mockPBSJobEvidence("garbage:backup-store", "garbage", "backup-store", "", "OK", now.Add(-5*time.Hour)),+ mockPBSJobEvidence("v-backup-store", "verify", "backup-store", "", "OK", now.Add(-3*time.Hour)),+ mockPBSJobEvidence("p-backup-store", "prune", "backup-store", "", "OK", now.Add(-4*time.Hour)),+ mockPBSJobEvidence("garbage:offsite-backup", "garbage", "offsite-backup", "", "OK", now.Add(-6*time.Hour)),+ mockPBSJobEvidence("v-offsite-backup", "verify", "offsite-backup", "", "OK", now.Add(-2*time.Hour)),+ }+ pbsInstances[1].JobHealthEvidence = []models.PBSJobHealthEvidence{+ mockPBSJobEvidence("garbage:replica-store", "garbage", "replica-store", "", "OK", now.Add(-7*time.Hour)),+ mockPBSJobEvidence("s-replica-store", "sync", "replica-store", "pbs-main", "connection error", now.Add(-90*time.Minute)),+ }+return pbsInstances}+func mockPBSJobEvidence(id, family, store, remote, state string, endedAt time.Time) models.PBSJobHealthEvidence {+ posture, reason := "healthy", "last-run-success"+ if state != "OK" {+ posture, reason = "critical", "last-run-failed"+ }+ endedAt = endedAt.UTC().Truncate(time.Second)+ return models.PBSJobHealthEvidence{+ ID: id,+ Family: family,+ Store: store,+ Remote: remote,+ Schedule: "daily",+ Enabled: true,+ LastRunState: state,+ LastRunEndtime: endedAt.Unix(),+ Confidence: "config-last-run",+ EvidenceSource: "pbs-job-config",+ EvidenceScope: "configured-job",+ Freshness: models.PBSJobHealthFreshness{+ ObservedAt: time.Now().UTC(),+ LastRunEndTime: endedAt,+ AgeSeconds: int64(time.Since(endedAt).Seconds()),+ State: "observed",+ },+ Posture: posture,+ PostureReason: reason,+ }+}+// generatePBSBackups generates mock PBS backup datafunc generatePBSBackups(vms []models.VM, containers []models.Container) []models.PBSBackup {var backups []models.PBSBackupdiff --git a/internal/mock/generator_test.go b/internal/mock/generator_test.goindex e6ce6fe28e..869b750d18 100644--- a/internal/mock/generator_test.go+++ b/internal/mock/generator_test.go@@ -1784,3 +1784,33 @@ func TestUpdateHostsRefreshesNativeSensorInventory(t *testing.T) {t.Fatalf("host without an inventory gained one: %+v", data.Hosts[1].Sensors.Native)}}++// Mock PBS servers report job results so the Jobs column and datastore job+// alerts have data: every job succeeded except the secondary's sync (#1815).+func TestGeneratePBSInstancesReportsJobResultsWithOneFailedSync(t *testing.T) {+ instances := generatePBSInstances()+ failed := 0+ for _, instance := range instances {+ stores := make(map[string]bool, len(instance.Datastores))+ for _, datastore := range instance.Datastores {+ stores[datastore.Name] = true+ }+ if len(instance.JobHealthEvidence) == 0 {+ t.Fatalf("%s reports no job results", instance.Name)+ }+ for _, job := range instance.JobHealthEvidence {+ if !stores[job.Store] {+ t.Fatalf("%s job %s names unknown datastore %q", instance.Name, job.ID, job.Store)+ }+ if job.Posture == "critical" {+ failed+++ if job.Family != "sync" || job.PostureReason != "last-run-failed" || job.Remote == "" {+ t.Fatalf("unexpected failed job %+v", job)+ }+ }+ }+ }+ if failed != 1 {+ t.Fatalf("failed jobs = %d, want exactly one", failed)+ }+}diff --git a/internal/models/metrics_types_test.go b/internal/models/metrics_types_test.goindex ca0ec1a2c1..3c6be897a7 100644--- a/internal/models/metrics_types_test.go+++ b/internal/models/metrics_types_test.go@@ -613,3 +613,26 @@ func TestAlertSummaryIsOptionalJSON(t *testing.T) {t.Fatalf("empty summary serialized in %s", without)}}++// The PBS poller reads the last stored job results to tell a job's recovery+// from a missing read; the accessor returns a copy, never the state's slice.+func TestStatePBSJobHealthEvidenceReturnsACopyPerInstance(t *testing.T) {+ state := &State{}+ state.UpdatePBSInstance(PBSInstance{ID: "pbs-a", JobHealthEvidence: []PBSJobHealthEvidence{{ID: "s-1", Family: "sync", Posture: "critical"}}})+ state.UpdatePBSInstance(PBSInstance{ID: "pbs-b"})++ got := state.PBSJobHealthEvidence("pbs-a")+ if len(got) != 1 || got[0].ID != "s-1" {+ t.Fatalf("pbs-a evidence = %+v", got)+ }+ got[0].Posture = "healthy"+ if again := state.PBSJobHealthEvidence("pbs-a"); again[0].Posture != "critical" {+ t.Fatalf("accessor exposed the stored slice: %+v", again)+ }+ if other := state.PBSJobHealthEvidence("pbs-b"); len(other) != 0 {+ t.Fatalf("pbs-b evidence = %+v, want none", other)+ }+ if missing := state.PBSJobHealthEvidence("pbs-missing"); missing != nil {+ t.Fatalf("unknown instance evidence = %+v, want nil", missing)+ }+}diff --git a/internal/models/models.go b/internal/models/models.goindex f42a266391..27e279206b 100644--- a/internal/models/models.go+++ b/internal/models/models.go@@ -6229,6 +6229,19 @@ func (s *State) UpdatePBSInstance(instance PBSInstance) {s.LastUpdate = time.Now()}+// PBSJobHealthEvidence returns the job results last stored for one PBS+// instance, so the next poll can tell a job's recovery from a missing read.+func (s *State) PBSJobHealthEvidence(instanceID string) []PBSJobHealthEvidence {+ s.mu.RLock()+ defer s.mu.RUnlock()+ for _, instance := range s.PBSInstances {+ if instance.ID == instanceID {+ return append([]PBSJobHealthEvidence(nil), instance.JobHealthEvidence...)+ }+ }+ return nil+}+// UpdatePMGInstances replaces the entire PMG instance listfunc (s *State) UpdatePMGInstances(instances []PMGInstance) {s.mu.Lock()diff --git a/internal/monitoring/monitor_pbs_coverage_test.go b/internal/monitoring/monitor_pbs_coverage_test.goindex bb7006bf59..5b1db601ef 100644--- a/internal/monitoring/monitor_pbs_coverage_test.go+++ b/internal/monitoring/monitor_pbs_coverage_test.go@@ -862,3 +862,91 @@ func TestPBSNamespaceDiscoveryLegacyRootOnlyRemainsComplete(t *testing.T) {func TestPBSBudgetOwnerWithdrawsLatePublication(t *testing.T) {exercisePBSBudgetOwnerWithdrawal(t)}++func carriedJob(id, family, posture, reason string) models.PBSJobHealthEvidence {+ return models.PBSJobHealthEvidence{+ ID: id,+ Family: family,+ Store: "offsite",+ Enabled: true,+ Posture: posture,+ PostureReason: reason,+ }+}++func postureOf(evidence []models.PBSJobHealthEvidence, family, id string) string {+ for _, entry := range evidence {+ if entry.Family == family && entry.ID == id {+ return entry.Posture + "/" + entry.PostureReason+ }+ }+ return "absent"+}++// A failed sync stays failed through the polls that cannot report a newer+// outcome (#1815): otherwise its alert would clear and fire again each time.+func TestCarryPBSJobFailuresHoldsAFailureUntilAnOutcomeIsObserved(t *testing.T) {+ failed := []models.PBSJobHealthEvidence{carriedJob("s-1", "sync", "critical", "last-run-failed")}++ cases := []struct {+ name string+ current []models.PBSJobHealthEvidence+ readFailed bool+ want string+ }{+ {"next run in progress", []models.PBSJobHealthEvidence{carriedJob("s-1", "sync", "healthy", "running")}, false, "critical/last-run-failed"},+ {"overdue with no newer run", []models.PBSJobHealthEvidence{carriedJob("s-1", "sync", "warning", "job-overdue")}, false, "critical/last-run-failed"},+ {"state unreadable", []models.PBSJobHealthEvidence{carriedJob("s-1", "sync", "unknown", "no-run-observed")}, false, "critical/last-run-failed"},+ {"whole read failed", nil, true, "critical/last-run-failed"},+ {"family read failed", []models.PBSJobHealthEvidence{{ID: "sync:partial", Family: "sync", Error: "403"}}, false, "critical/last-run-failed"},+ {"retry succeeded", []models.PBSJobHealthEvidence{carriedJob("s-1", "sync", "healthy", "last-run-success")}, false, "healthy/last-run-success"},+ {"retry warned", []models.PBSJobHealthEvidence{carriedJob("s-1", "sync", "warning", "last-run-warning")}, false, "warning/last-run-warning"},+ {"job removed", []models.PBSJobHealthEvidence{}, false, "absent"},+ }+ for _, tc := range cases {+ t.Run(tc.name, func(t *testing.T) {+ got := carryPBSJobFailures(failed, tc.current, tc.readFailed)+ if posture := postureOf(got, "sync", "s-1"); posture != tc.want {+ t.Fatalf("posture = %s, want %s", posture, tc.want)+ }+ })+ }++ disabled := carriedJob("s-1", "sync", "unknown", "no-run-observed")+ disabled.Enabled = false+ got := carryPBSJobFailures(failed, []models.PBSJobHealthEvidence{disabled}, false)+ if len(got) != 1 || got[0].Enabled {+ t.Fatalf("a disabled job must replace its carried failure, got %+v", got)+ }+}++func TestCarryPBSJobFailuresKeysJobsByFamily(t *testing.T) {+ previous := []models.PBSJobHealthEvidence{carriedJob("daily", "sync", "critical", "last-run-failed")}+ current := []models.PBSJobHealthEvidence{+ carriedJob("daily", "verify", "healthy", "last-run-success"),+ carriedJob("daily", "sync", "healthy", "running"),+ }+ got := carryPBSJobFailures(previous, current, false)+ if posture := postureOf(got, "sync", "daily"); posture != "critical/last-run-failed" {+ t.Fatalf("sync daily = %s, want the carried failure", posture)+ }+ if posture := postureOf(got, "verify", "daily"); posture != "healthy/last-run-success" {+ t.Fatalf("verify daily = %s, want its own success", posture)+ }+}++func TestPBSJobHealthPostureRanksAFailedRunAboveOverdue(t *testing.T) {+ observedAt := time.Unix(1700010000, 0)+ evidence := pbsJobHealthEvidenceFromFacts([]pbs.JobHealthEvidence{{+ ID: "s-1",+ Family: "sync",+ Store: "offsite",+ Enabled: true,+ LastRunState: "connection error",+ LastRunEndtime: 1700000000,+ NextRun: 1700003600,+ }}, observedAt)+ if got := evidence[0]; got.Freshness.State != "overdue" || got.Posture != "critical" || got.PostureReason != "last-run-failed" {+ t.Fatalf("freshness/posture = %s %s/%s, want overdue critical/last-run-failed", got.Freshness.State, got.Posture, got.PostureReason)+ }+}diff --git a/internal/monitoring/monitor_pbs_pmg.go b/internal/monitoring/monitor_pbs_pmg.goindex 3e368705d8..0a1075c912 100644--- a/internal/monitoring/monitor_pbs_pmg.go+++ b/internal/monitoring/monitor_pbs_pmg.go@@ -151,6 +151,11 @@ func pbsJobHealthPosture(fact pbs.JobHealthEvidence, freshness models.PBSJobHealif fact.Error != "" {return "unknown", strings.TrimSpace(fact.Confidence)}+ // A failed last run outranks a missed next one: an overdue job whose last+ // run failed is still failed, not merely late.+ if strings.Contains(status, "fail") || strings.Contains(status, "error") {+ return "critical", "last-run-failed"+ }if freshness.State == "overdue" {return "warning", "job-overdue"}@@ -170,6 +175,72 @@ func pbsJobHealthPosture(fact pbs.JobHealthEvidence, freshness models.PBSJobHeal}}+// pbsJobKey identifies one job across polls. PBS job ids are only unique+// within a family, so a sync and a verify job may share one.+func pbsJobKey(entry models.PBSJobHealthEvidence) string {+ return strings.ToLower(strings.TrimSpace(entry.Family)) + "\x00" + strings.TrimSpace(entry.ID)+}++// carryPBSJobFailures keeps a job's last completed failure known while PBS+// cannot report a newer outcome. PBS's /admin job status drops the previous+// result while the next run is in progress, an overdue or unreadable job+// reports none, and a failed read lists no jobs at all; treating any of those+// as recovery would clear a failed-job alert and raise it again on the next+// poll. A carried failure clears only when the job's newest run is observed to+// succeed or warn, or when a complete read no longer lists the job (removed),+// or lists it disabled.+func carryPBSJobFailures(previous, current []models.PBSJobHealthEvidence, readFailed bool) []models.PBSJobHealthEvidence {+ failed := make(map[string]models.PBSJobHealthEvidence)+ for _, entry := range previous {+ if entry.Posture == "critical" && entry.PostureReason == "last-run-failed" && strings.TrimSpace(entry.ID) != "" {+ failed[pbsJobKey(entry)] = entry+ }+ }+ if len(failed) == 0 {+ return current+ }++ unreadFamilies := make(map[string]bool)+ for _, entry := range current {+ if strings.TrimSpace(entry.Error) != "" {+ unreadFamilies[strings.ToLower(strings.TrimSpace(entry.Family))] = true+ }+ }++ out := make([]models.PBSJobHealthEvidence, 0, len(current)+len(failed))+ seen := make(map[string]bool, len(current))+ for _, entry := range current {+ key := pbsJobKey(entry)+ seen[key] = true+ if prior, ok := failed[key]; ok && entry.Enabled && !pbsJobReportsOutcome(entry) {+ out = append(out, prior)+ continue+ }+ out = append(out, entry)+ }+ for key, prior := range failed {+ if seen[key] {+ continue+ }+ if readFailed || unreadFamilies[strings.ToLower(strings.TrimSpace(prior.Family))] {+ out = append(out, prior)+ }+ }+ return out+}++// pbsJobReportsOutcome says whether this poll observed how the job's newest+// run ended: success, warning or failure, rather than running, overdue or an+// unreadable state.+func pbsJobReportsOutcome(entry models.PBSJobHealthEvidence) bool {+ switch entry.PostureReason {+ case "last-run-success", "last-run-warning", "last-run-failed":+ return true+ default:+ return false+ }+}+// pollPBSInstance polls a single PBS instancefunc (m *Monitor) pollPBSInstance(ctx context.Context, instanceName string, client *pbs.Client) {start := time.Now()@@ -485,7 +556,11 @@ func (m *Monitor) pollPBSInstance(ctx context.Context, instanceName string, clieStr("instance", instanceName).Msg("Failed to collect PBS job health evidence")}- pbsInst.JobHealthEvidence = pbsJobHealthEvidenceFromFacts(jobFacts, time.Now())+ pbsInst.JobHealthEvidence = carryPBSJobFailures(+ m.state.PBSJobHealthEvidence(pbsInst.ID),+ pbsJobHealthEvidenceFromFacts(jobFacts, time.Now()),+ err != nil,+ )}// Convert PBS datastores to Storage entries for unified storage viewdiff --git a/internal/unifiedresources/adapters.go b/internal/unifiedresources/adapters.goindex 323d7e14bb..4d825aa6b5 100644--- a/internal/unifiedresources/adapters.go+++ b/internal/unifiedresources/adapters.go@@ -1654,6 +1654,7 @@ func resourceFromPBSDatastore(instance models.PBSInstance, datastore models.PBSDdatastoreStatus, _ := statusFromStorageState(datastore.Status)status := storageStatus(datastoreStatus, risk)incidents := incidentsFromAssessment("pulse", string(SourcePBS), "pbs-datastore:"+name, assessment, instance.LastSeen)+ incidents = append(incidents, pbsDatastoreJobIncidents(instance, name)...)status = incidentsStatus(status, incidents)resource := Resource{diff --git a/internal/unifiedresources/adapters_test.go b/internal/unifiedresources/adapters_test.goindex 2c6b918794..516faeb49e 100644--- a/internal/unifiedresources/adapters_test.go+++ b/internal/unifiedresources/adapters_test.go@@ -2189,3 +2189,50 @@ func TestHostUpdateEvidenceSurvivesCanonicalAdapterViewAndClone(t *testing.T) {t.Fatal("absent updater status became evidence")}}++// #1815: the guest's backup to the primary store succeeded, then the sync that+// copies it to the second store failed. The failure belongs to the store the+// sync writes to, as its own incident, and leaves the primary store clean.+func TestResourceFromPBSDatastoreRaisesIncidentForFailedSync(t *testing.T) {+ now := time.Date(2026, 11, 3, 6, 0, 0, 0, time.UTC)+ sync := pbsJobEvidence("s-offsite", "sync", "offsite", "critical", now.Add(-time.Hour))+ sync.Remote = "pbs-main"+ instance := models.PBSInstance{+ ID: "pbs-1",+ Name: "pbs-main",+ LastSeen: now,+ JobHealthEvidence: []models.PBSJobHealthEvidence{+ pbsJobEvidence("backup:vm/100", "backup", "main", "healthy", now.Add(-2*time.Hour)),+ sync,+ },+ }++ offsite, _ := resourceFromPBSDatastore(instance, models.PBSDatastore{Name: "offsite", Status: "available", Total: 100, Used: 10})+ if len(offsite.Incidents) != 1 {+ t.Fatalf("expected one job incident on the sync's store, got %+v", offsite.Incidents)+ }+ incident := offsite.Incidents[0]+ if incident.Code != PBSJobFailedIncidentCode || incident.Severity != storagehealth.RiskWarning {+ t.Fatalf("incident = %+v, want a warning %s", incident, PBSJobFailedIncidentCode)+ }+ if want := "Sync job s-offsite failed on datastore offsite (copying from pbs-main)"; incident.Summary != want {+ t.Fatalf("summary = %q, want %q", incident.Summary, want)+ }+ if incident.NativeID != "pbs-datastore:offsite:job:sync:s-offsite" {+ t.Fatalf("native id = %q", incident.NativeID)+ }+ if !incident.StartedAt.Equal(now.Add(-time.Hour)) {+ t.Fatalf("started at = %v, want the failed run's end", incident.StartedAt)+ }+ if offsite.Status != StatusWarning {+ t.Fatalf("status = %q, want %q", offsite.Status, StatusWarning)+ }+ if got := IncidentCategoryForResource(&offsite, incident); got != IncidentCategoryRecoverability {+ t.Fatalf("category = %q, want %q", got, IncidentCategoryRecoverability)+ }++ main, _ := resourceFromPBSDatastore(instance, models.PBSDatastore{Name: "main", Status: "available", Total: 100, Used: 10})+ if len(main.Incidents) != 0 || main.Status != StatusOnline {+ t.Fatalf("primary store must stay clean, got status %q incidents %+v", main.Status, main.Incidents)+ }+}diff --git a/internal/unifiedresources/incident_categories.go b/internal/unifiedresources/incident_categories.goindex 3da9774abb..caba6f9e0c 100644--- a/internal/unifiedresources/incident_categories.go+++ b/internal/unifiedresources/incident_categories.go@@ -29,7 +29,7 @@ func IncidentCategoryForResource(resource *Resource, incident ResourceIncident)return IncidentCategoryRecoverability}return IncidentCategoryCapacity- case "pbs_datastore_state", "pbs_datastore_error", "backup_target_degraded":+ case "pbs_datastore_state", "pbs_datastore_error", "backup_target_degraded", PBSJobFailedIncidentCode:return IncidentCategoryRecoverabilitycase "disk_failed", "disk_unavailable", "disk_smart_failed", "disk_wearout", "disk_health", "zfs_pool_errors", "zfs_device_errors", "zfs_scan_errors", "zfs_scan_failed":return IncidentCategoryDiskHealthdiff --git a/internal/unifiedresources/pbs_job_incidents.go b/internal/unifiedresources/pbs_job_incidents.gonew file mode 100644index 0000000000..d9c1983653--- /dev/null+++ b/internal/unifiedresources/pbs_job_incidents.go@@ -0,0 +1,124 @@+package unifiedresources++import (+ "sort"+ "strings"+ "time"++ "github.com/rcourtman/pulse-go-rewrite/internal/models"+ "github.com/rcourtman/pulse-go-rewrite/internal/storagehealth"+)++// PBSJobFailedIncidentCode marks a datastore whose sync, verify, prune or+// garbage-collection job failed on its newest run.+const PBSJobFailedIncidentCode = "pbs_job_failed"++// A failed sync leaves the offsite copy stale, a failed verify leaves restores+// unproven, and failed GC or prune let the store fill faster than it should.+// None of them says a guest's primary backup failed, so they belong to the+// datastore and never to guest protection (#1815). Backup jobs are already+// answered per guest by protection posture.+var pbsDatastoreJobFamilyLabels = map[string]string{+ "sync": "Sync job",+ "verify": "Verify job",+ "prune": "Prune job",+ "garbage": "Garbage collection",+}++// pbsDatastoreJobIncidents turns the datastore's failed PBS jobs into incidents+// on that datastore. The judgment is the poller's own (posture "critical" is a+// failed last run); this only picks which runs speak for the store. Storeless+// task history cannot be pinned to one datastore, and a late, warned or+// unknown job is not a failure, so neither raises an incident. The newest run+// of each job speaks for it, matching the Backups page Jobs column.+func pbsDatastoreJobIncidents(instance models.PBSInstance, datastore string) []ResourceIncident {+ store := strings.TrimSpace(datastore)+ if store == "" || len(instance.JobHealthEvidence) == 0 {+ return nil+ }++ newest := make(map[string]models.PBSJobHealthEvidence)+ for _, entry := range instance.JobHealthEvidence {+ family := strings.ToLower(strings.TrimSpace(entry.Family))+ if _, ok := pbsDatastoreJobFamilyLabels[family]; !ok || !entry.Enabled {+ continue+ }+ if strings.TrimSpace(entry.Store) != store {+ continue+ }+ id := strings.TrimSpace(entry.ID)+ if id == "" {+ id = store+ }+ // Job ids are unique only within a family: a sync and a verify job may+ // share one, and neither may hide the other.+ key := family + ":" + id+ if previous, ok := newest[key]; ok && pbsJobRunTime(entry).Before(pbsJobRunTime(previous)) {+ continue+ }+ newest[key] = entry+ }++ keys := make([]string, 0, len(newest))+ for key, entry := range newest {+ if strings.EqualFold(strings.TrimSpace(entry.Posture), "critical") {+ keys = append(keys, key)+ }+ }+ if len(keys) == 0 {+ return nil+ }+ sort.Strings(keys)++ incidents := make([]ResourceIncident, 0, len(keys))+ for _, key := range keys {+ entry := newest[key]+ id := strings.TrimSpace(entry.ID)+ if id == "" {+ id = store+ }+ startedAt := pbsJobRunTime(entry)+ if startedAt.IsZero() {+ startedAt = instance.LastSeen+ }+ incidents = append(incidents, ResourceIncident{+ Provider: "pulse",+ NativeID: "pbs-datastore:" + store + ":job:" + key,+ Code: PBSJobFailedIncidentCode,+ Severity: storagehealth.RiskWarning,+ Source: string(SourcePBS),+ Summary: pbsJobFailedSummary(entry, id, store),+ StartedAt: startedAt,+ })+ }+ return incidents+}++// The summary is the alert message, so it names the job and, for a sync, the+// remote it copies from. It holds no times: incidents merge on their summary.+func pbsJobFailedSummary(entry models.PBSJobHealthEvidence, id, store string) string {+ family := strings.ToLower(strings.TrimSpace(entry.Family))+ label := pbsDatastoreJobFamilyLabels[family]+ subject := label+ if family != "garbage" {+ subject = label + " " + id+ }+ summary := subject + " failed on datastore " + store+ if remote := strings.TrimSpace(entry.Remote); family == "sync" && remote != "" {+ summary += " (copying from " + remote + ")"+ }+ return summary+}++func pbsJobRunTime(entry models.PBSJobHealthEvidence) time.Time {+ if !entry.Freshness.LastRunEndTime.IsZero() {+ return entry.Freshness.LastRunEndTime+ }+ if entry.LastRunEndtime > 0 {+ return time.Unix(entry.LastRunEndtime, 0).UTC()+ }+ if entry.TaskEndTime > 0 {+ return time.Unix(entry.TaskEndTime, 0).UTC()+ }+ return time.Time{}+}diff --git a/internal/unifiedresources/pbs_pmg_registry_test.go b/internal/unifiedresources/pbs_pmg_registry_test.goindex cb7ac971b3..4bdbcea98f 100644--- a/internal/unifiedresources/pbs_pmg_registry_test.go+++ b/internal/unifiedresources/pbs_pmg_registry_test.go@@ -866,3 +866,84 @@ func TestStatusFromStorageStateCoversPBSAndPVEVocabulary(t *testing.T) {}}}++func pbsJobEvidence(id, family, store, posture string, endedAt time.Time) models.PBSJobHealthEvidence {+ return models.PBSJobHealthEvidence{+ ID: id,+ Family: family,+ Store: store,+ Enabled: true,+ LastRunEndtime: endedAt.Unix(),+ Posture: posture,+ Freshness: models.PBSJobHealthFreshness{LastRunEndTime: endedAt},+ }+}++func TestPBSDatastoreJobIncidentsFollowTheNewestRunOfEachJob(t *testing.T) {+ now := time.Date(2026, 11, 3, 6, 0, 0, 0, time.UTC)+ recovered := models.PBSInstance{JobHealthEvidence: []models.PBSJobHealthEvidence{+ pbsJobEvidence("v-1", "verify", "main", "critical", now.Add(-48*time.Hour)),+ pbsJobEvidence("v-1", "verify", "main", "healthy", now.Add(-time.Hour)),+ }}+ if got := pbsDatastoreJobIncidents(recovered, "main"); len(got) != 0 {+ t.Fatalf("a job whose newest run succeeded must not raise an incident, got %+v", got)+ }++ regressed := models.PBSInstance{JobHealthEvidence: []models.PBSJobHealthEvidence{+ pbsJobEvidence("v-1", "verify", "main", "healthy", now.Add(-48*time.Hour)),+ pbsJobEvidence("v-1", "verify", "main", "critical", now.Add(-time.Hour)),+ }}+ got := pbsDatastoreJobIncidents(regressed, "main")+ if len(got) != 1 || got[0].Summary != "Verify job v-1 failed on datastore main" {+ t.Fatalf("expected the newest failed run to speak, got %+v", got)+ }+}++func TestPBSDatastoreJobIncidentsOnlyCountFailuresPinnedToTheStore(t *testing.T) {+ now := time.Date(2026, 11, 3, 6, 0, 0, 0, time.UTC)+ disabled := pbsJobEvidence("p-off", "prune", "main", "critical", now)+ disabled.Enabled = false+ instance := models.PBSInstance{JobHealthEvidence: []models.PBSJobHealthEvidence{+ // Storeless task history cannot be pinned to one datastore.+ pbsJobEvidence("sync:task", "sync", "", "critical", now),+ pbsJobEvidence("s-other", "sync", "other", "critical", now),+ disabled,+ // Backup outcomes belong to guest protection posture.+ pbsJobEvidence("backup:vm/100", "backup", "main", "critical", now),+ // Late, warned and unknown are not failures.+ pbsJobEvidence("v-late", "verify", "main", "warning", now),+ pbsJobEvidence("p-unknown", "prune", "main", "unknown", now),+ }}+ if got := pbsDatastoreJobIncidents(instance, "main"); len(got) != 0 {+ t.Fatalf("expected no incidents, got %+v", got)+ }+}++func TestPBSDatastoreJobIncidentsNameGarbageCollectionByStore(t *testing.T) {+ now := time.Date(2026, 11, 3, 6, 0, 0, 0, time.UTC)+ instance := models.PBSInstance{JobHealthEvidence: []models.PBSJobHealthEvidence{+ pbsJobEvidence("garbage:main", "garbage", "main", "critical", now),+ pbsJobEvidence("p-1", "prune", "main", "critical", now),+ }}+ got := pbsDatastoreJobIncidents(instance, "main")+ if len(got) != 2 {+ t.Fatalf("expected one incident per failed job, got %+v", got)+ }+ if got[0].Summary != "Garbage collection failed on datastore main" || got[1].Summary != "Prune job p-1 failed on datastore main" {+ t.Fatalf("summaries = %q, %q", got[0].Summary, got[1].Summary)+ }+}++// PBS job ids are unique only within a family; a later successful verify job+// named like a failed sync must not hide the sync, in either input order.+func TestPBSDatastoreJobIncidentsKeepFamiliesSharingAJobID(t *testing.T) {+ now := time.Date(2026, 11, 3, 6, 0, 0, 0, time.UTC)+ sync := pbsJobEvidence("daily", "sync", "main", "critical", now.Add(-2*time.Hour))+ verify := pbsJobEvidence("daily", "verify", "main", "healthy", now.Add(-time.Hour))+ for _, evidence := range [][]models.PBSJobHealthEvidence{{sync, verify}, {verify, sync}} {+ got := pbsDatastoreJobIncidents(models.PBSInstance{JobHealthEvidence: evidence}, "main")+ if len(got) != 1 || got[0].NativeID != "pbs-datastore:main:job:sync:daily" {+ t.Fatalf("expected the failed sync alone, got %+v", got)+ }+ }+}