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
fix(alerts): key docker container overrides by name so toggles survive updates
rcourtman69b5ec22fd77
diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.mdindex eb1856bdc9..aaa0beac2a 100644--- a/docs/release-control/v6/internal/subsystems/alerts.md+++ b/docs/release-control/v6/internal/subsystems/alerts.md@@ -603,6 +603,21 @@ and identity first-seen tracking. Generic threshold reevaluation must not keepor resurrect image-update alerts after their owning Docker alert configurationhas disabled them.+Docker container alert overrides key on stable container identity. The+canonical override key is `docker:{hostID}/{containerName}`; container IDs+change on every recreate, so runtime-ID keys orphaned each image update and+accumulated dead entries in alerts.json (#1601). The evaluator resolves the+name key first and falls back to the legacy `docker:{hostID}/{containerID}`+key for pre-migration entries, `MigrateDockerContainerOverrideKeys`+(`internal/alerts/docker_override_migration.go`) re-homes live legacy and+unified-hash keys onto the name key on the monitor sync cadence and prunes+orphaned ID-shaped entries while keeping name-keyed overrides for absent+containers, and the UI writes only the name key while binding rows through the+shared `dockerContainerOverrideIdCandidates` chain (name first; container-ID,+short-ID, unified-hash, and slash-tail forms as trailing lookup candidates).+Container override work must not reintroduce a runtime-container-ID+persistence key.+Backup orphan evaluation is also inventory-scoped. The alerts runtime mayevaluate recovery rollups for backup age, but unresolved Proxmox PVE backupsubjects must not be treated as orphaned until monitoring has supplied thediff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex bd15136a02..1954f622ae 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -2837,6 +2837,18 @@ storage rows onto the storage metrics target id before the thresholds tablederives rows, so old Ceph override records and newly projected Ceph pooloverrides survive the v6 feature-shell path instead of silently disappearingfrom the live editor.+Docker container override identity follows the same single-owner rule.+`dockerContainerOverrideIdCandidates` in+`frontend-modern/src/features/alerts/alertOverridesModel.ts` is the only+builder of container override keys (re-exported by+`thresholdsResourceModel.ts`): it leads with the stable+`docker:{host}/{containerName}` key that survives container recreates (#1601)+and trails the legacy container-ID, short-ID, unified-hash, and slash-tail+forms as lookup candidates. Threshold rows carry that chain as+`overrideIdCandidates`/`overrideStorageId` so every mutation path (toggle,+connectivity, offline state, edit, remove) strips the historical keys and+writes only the name key; docker surfaces must not derive container override+keys locally from resource-id parsing.The frontend already has several guardrail tests. The next step is to keepturning repeated local patterns into explicit shared primitives with hard usagediff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.mdindex c0f58384cb..9be0c4ef7f 100644--- a/docs/release-control/v6/internal/subsystems/monitoring.md+++ b/docs/release-control/v6/internal/subsystems/monitoring.md@@ -1150,6 +1150,17 @@ that correlation outcome; monitoring never substitutes a matched host orservice identity for the configured check. Monitoring does not perform thecorrelation decision itself; it only forwards the link hint for the registryto resolve.+The monitor sync cadence also keeps Docker container alert-override keys on+stable identity. Alongside `MigrateCanonicalOverrideKeys`,+`syncUnifiedResourceAlertsToState` runs+`alerts.MigrateDockerContainerOverrideKeys` over the unified resource+snapshot, re-homing container overrides stored under runtime container IDs or+v6 unified hash ids onto the durable `docker:{host}/{containerName}` key and+pruning ID-shaped orphans left by past container recreates (#1601); a changed+config persists through `SaveAlertConfig` before `UpdateConfig` republishes+it. Regression coverage:+`TestSyncUnifiedResourceAlertsMigratesDockerContainerOverrideKeys` in+`internal/monitoring/monitor_alert_override_migration_test.go`.Monitoring does own keeping that stored link hint current across canonical-IDeras. On the same cadence as the alert-override migration,`migrateAvailabilityLinksToCanonicalIDs`diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.mdindex 87fe98a507..92ffe58a30 100644--- a/docs/release-control/v6/internal/subsystems/unified-resources.md+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md@@ -2045,6 +2045,12 @@ lifecycle controls from runtime-shaped metadata alone. After a governed requestcompletes, the owning surface may ask its existing `useUnifiedResources` queryto refetch the resource snapshot, but refresh is not an alternate execution,verification, or provider-control path.+Alert-threshold identity on those Docker rows is also resource-facet backed:+`DockerContainersTable.tsx` resolves per-container alert thresholds by handing+the full app-container resource (name plus `docker.containerId` facet) to the+shared `dockerContainerOverrideIdCandidates` chain, so override identity keys+on `docker:{host}/{containerName}` (#1601) rather than on parsed unified+resource-id tails.Proxmox VM and LXC lifecycle affordances follow the same resource-owned rule:the backend advertises only status-appropriate `start`, `shutdown`, `reboot`,and `stop` capabilities for non-template, unlocked Proxmox guests, filters themdiff --git a/frontend-modern/browser-verification.json b/frontend-modern/browser-verification.jsonindex 5ade515243..bc47001b16 100644--- a/frontend-modern/browser-verification.json+++ b/frontend-modern/browser-verification.json@@ -1,18 +1,27 @@{"version": 1,- "base_sha": "eac9ffcabf8f2c108c0c2d67f43c91ac4db5023a",- "verified_at": "2026-08-06T19:54:45Z",+ "base_sha": "ed0f3613aeda63f41248cd1ef981b5ca2639bd8b",+ "verified_at": "2026-08-06T21:47:15Z","result": "passed","changed_paths": [- "frontend-modern/src/features/alerts/alertHistoryModel.ts",- "frontend-modern/src/useAppRuntimeState.ts"+ "frontend-modern/src/features/alerts/alertOverridesModel.ts",+ "frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsAvailabilityMutations.ts",+ "frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsDockerData.ts",+ "frontend-modern/src/features/alerts/thresholds/thresholdsResourceModel.ts",+ "frontend-modern/src/features/docker/DockerContainersTable.tsx",+ "frontend-modern/src/utils/alertThresholdsPresentation.ts"],"content_sha256": {- "frontend-modern/src/features/alerts/alertHistoryModel.ts": "71c9123482dcbbeb2dc319063f3e00e56e6a7ec7fdae4df6c0e9aa78aac8ea6d",- "frontend-modern/src/useAppRuntimeState.ts": "7061dbfc8aed3b569526af9018e4f70034c6dee02752295fc449d19283df7753"+ "frontend-modern/src/features/alerts/alertOverridesModel.ts": "9729ff9ad413c3b9ece2a1ab3449939cba563bf80acd16e678b52d668751ed63",+ "frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsAvailabilityMutations.ts": "b8b89dd3d756b13dc730f6cc7e0c3fe2f4a79525753eeaa6fa203766c7e592ba",+ "frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsDockerData.ts": "92b0fd9836d86930cae26e5ccecb3dc56babdba2170a454e820a12dd27549f2b",+ "frontend-modern/src/features/alerts/thresholds/thresholdsResourceModel.ts": "e71f230e5fb8ad5f970cf9385afa31b18221aedd81453febbce64a0d0f60783c",+ "frontend-modern/src/features/docker/DockerContainersTable.tsx": "45b125474f0d5058e9861c44fab0a33cf93b4a82952001d7f9010f18419dac4e",+ "frontend-modern/src/utils/alertThresholdsPresentation.ts": "6605976a9b561c26578f1eb78785ccd5d6739c2a0a3b91246e23828c8433a49c"},"routes": [- "/alerts/history"+ "/alerts/thresholds/docker",+ "/docker"],"viewports": [{@@ -20,22 +29,21 @@"height": 800},{- "width": 390,- "height": 844+ "width": 375,+ "height": 812}],"states": [- "Browser locale resolved as en-GB for the whole check, so a hardcoded en-US format is visibly distinguishable from the viewer's own",- "Last refresh footer renders 20:52:55 on a 24 hour clock; the previous hardcoded en-US with hour12 true produced 8:52:55 PM for the same instant",- "Alert history day group header carries the full-date title 'Thursday, 6 August 2026' in UK day-month order rather than the previous 'Thursday, August 6, 2026'",- "Alert history page renders normally at 1280px and 390px with the reformatted labels and no horizontal document overflow",- "Canonical platform audit passes clean across src with the new locale rule active",- "Reintroducing a hardcoded en-US locale into useAppRuntimeState.ts makes the audit fail at that exact line, then passes again once reverted"+ "Docker thresholds tab with mock container rows grouped by host, ignored-container-patterns card showing the new wildcard copy",+ "loki container rows rendering the persisted docker:orion-2-mock/loki name-keyed override as disabled after a full page reload",+ "alerts.json converged to name-keyed overrides after live monitor-sync migration re-homed a seeded legacy container-ID key and a unified-hash key and pruned an orphaned 12-hex key",+ "Docker page containers table with CPU/memory meters resolving thresholds through the new name-first candidate chain",+ "mobile 375px docker thresholds view rendering the wildcard copy and container sections"],"interactions": [- "Read the rendered Last refresh footer text and the day group header title attribute directly from the DOM in an en-GB browser",- "Swept the whole of frontend-modern/src with the audit's own regex to confirm no remaining hardcoded locale literals before adding the rule",- "Temporarily reverted one fix to confirm the new audit rule fires on the regression, then restored it and re-ran the audit clean",- "Reloaded the history route at both viewports after the change"+ "searched containers for 'loki' in the thresholds table",+ "toggled the per-container alert disable switch on 'loki' and clicked Save Changes; verified alerts.json stored docker:orion-2-mock/loki (host+name key)",+ "reloaded /alerts/thresholds/docker and confirmed the saved override re-bound to the container rows via the name candidate",+ "seeded legacy docker:{host}/{containerID}, docker:{host}/{unified-hash} and orphan hex overrides via PUT /api/alerts/config and watched the monitor sync migrate all of them to the name key on disk"]}diff --git a/frontend-modern/src/components/Alerts/__tests__/ThresholdsTable.test.tsx b/frontend-modern/src/components/Alerts/__tests__/ThresholdsTable.test.tsxindex 2d8e43eb4e..311c9e257a 100644--- a/frontend-modern/src/components/Alerts/__tests__/ThresholdsTable.test.tsx+++ b/frontend-modern/src/components/Alerts/__tests__/ThresholdsTable.test.tsx@@ -687,17 +687,17 @@ describe('ThresholdsTable Resource Rendering', () => {/>));+ // Rows key on the stable docker:{host}/{containerName} override id, which+ // survives container recreates (#1601).await waitFor(() => {- expect(- screen.getByTestId('resource-name-docker:docker-host-1/container-governed'),- ).toBeTruthy();+ expect(screen.getByTestId('resource-name-docker:docker-host-1/secret-nginx')).toBeTruthy();});+ expect(screen.getByTestId('resource-name-docker:docker-host-1/secret-nginx')).toHaveTextContent(+ 'Secret Nginx',+ );expect(- screen.getByTestId('resource-name-docker:docker-host-1/container-governed'),- ).toHaveTextContent('Secret Nginx');- expect(- screen.getByTestId('resource-name-docker:docker-host-1/container-governed'),+ screen.getByTestId('resource-name-docker:docker-host-1/secret-nginx'),).not.toHaveTextContent('redacted by policy');});@@ -740,10 +740,10 @@ describe('ThresholdsTable Resource Rendering', () => {});expect(screen.getByTestId('resource-name-truenas-resource')).toHaveTextContent('TrueNAS');- expect(- screen.getByTestId('resource-name-docker:truenas-resource/ix-nextcloud'),- ).toHaveTextContent('Nextcloud');- expect(screen.queryByText('Ignored container prefixes')).not.toBeInTheDocument();+ expect(screen.getByTestId('resource-name-docker:truenas-resource/nextcloud')).toHaveTextContent(+ 'Nextcloud',+ );+ expect(screen.queryByText('Ignored container patterns')).not.toBeInTheDocument();expect(screen.queryByText('Swarm service alerts')).not.toBeInTheDocument();});diff --git a/frontend-modern/src/features/alerts/alertOverridesModel.ts b/frontend-modern/src/features/alerts/alertOverridesModel.tsindex 2f33d098ca..15dc09a37e 100644--- a/frontend-modern/src/features/alerts/alertOverridesModel.ts+++ b/frontend-modern/src/features/alerts/alertOverridesModel.ts@@ -198,8 +198,32 @@ export const dockerHostOverrideIdCandidates = (resource: Resource): string[] =>);};-export const dockerContainerOverrideIdCandidates = (host: Resource, shortId: string): string[] =>- uniqueIds(...dockerHostOverrideIdCandidates(host).map((hostId) => `docker:${hostId}/${shortId}`));+// Container override keys must survive container recreates: the durable key+// is docker:{hostId}/{containerName}, which is what the backend evaluator+// resolves first. ID-based forms trail as lookup candidates so overrides+// written under the runtime container ID (the legacy backend key) or the+// unified hash id (what this UI keyed on before #1601) still bind to the row+// and re-home onto the stable name key on the next save.+export const dockerContainerOverrideIdCandidates = (+ host: Resource,+ container: Resource,+): string[] => {+ const containerId =+ asString(container.docker?.containerId) ?? asString(platformData(container)?.containerId);+ const keyParts = uniqueIds(+ asString(container.name)?.replace(/^\/+/, ''),+ containerId,+ containerId && containerId.length > 12 ? containerId.slice(0, 12) : undefined,+ container.id,+ // Historical slash-form resource ids stored their tail as the key part.+ container.id.includes('/') ? container.id.split('/').pop() : undefined,+ );+ return uniqueIds(+ ...keyParts.flatMap((part) =>+ dockerHostOverrideIdCandidates(host).map((hostId) => `docker:${hostId}/${part}`),+ ),+ );+};// Kubernetes / TrueNAS / VMware resources are keyed by their unified resource// IDs in the overrides map (the same candidates buildProjectedOverrides@@ -404,8 +428,9 @@ export const buildProjectedOverrides = ({const containers = getChildren(host.id).filter((resource) => resource.type === 'app-container');containers.forEach((container) => {- const shortId = container.id.includes('/') ? container.id.split('/').pop()! : container.id;- dockerContainerOverrideIdCandidates(host, shortId).forEach((resourceId) => {+ const containerId = asString(container.docker?.containerId);+ const shortId = containerId ? containerId.slice(0, 12) : container.id;+ dockerContainerOverrideIdCandidates(host, container).forEach((resourceId) => {dockerContainerMap.set(resourceId, { host, container, containerShortId: shortId });});});diff --git a/frontend-modern/src/features/alerts/thresholds/__tests__/thresholdsResourceModel.branchcov0723pm.test.ts b/frontend-modern/src/features/alerts/thresholds/__tests__/thresholdsResourceModel.branchcov0723pm.test.tsindex f9210d53e2..97378ef594 100644--- a/frontend-modern/src/features/alerts/thresholds/__tests__/thresholdsResourceModel.branchcov0723pm.test.ts+++ b/frontend-modern/src/features/alerts/thresholds/__tests__/thresholdsResourceModel.branchcov0723pm.test.ts@@ -71,50 +71,54 @@ describe('thresholdsResourceModel branch coverage 0723pm', () => {});describe('dockerContainerOverrideIdCandidates', () => {- it('prefixes every host candidate as docker:<hostId>/<shortId>, preserving order', () => {+ const fullContainerId = 'a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2';+ const makeContainer = (overrides: Partial<Resource> = {}): Resource =>+ makeAgent({+ id: 'app-container-0011223344556677',+ type: 'app-container',+ name: 'media-server',+ docker: { containerId: fullContainerId },+ ...overrides,+ });++ it('keys on the container name first, then the legacy ID forms, per host candidate', () => {const host = makeAgent({id: 'runtime-1',- discoveryTarget: {- resourceType: 'app-container',- resourceId: 'container-123',- agentId: 'agent-7',- },- platformData: {- docker: { hostSourceId: 'docker-platform' },- hostSourceId: 'host-platform',- },+ platformData: { docker: { hostSourceId: 'docker-platform' } },});- expect(dockerContainerOverrideIdCandidates(host, 'a1b2c3d4e5f6')).toEqual([- 'docker:container-123/a1b2c3d4e5f6',- 'docker:docker-platform/a1b2c3d4e5f6',- 'docker:host-platform/a1b2c3d4e5f6',- 'docker:agent-7/a1b2c3d4e5f6',- 'docker:runtime-1/a1b2c3d4e5f6',+ expect(dockerContainerOverrideIdCandidates(host, makeContainer())).toEqual([+ `docker:docker-platform/media-server`,+ `docker:runtime-1/media-server`,+ `docker:docker-platform/${fullContainerId}`,+ `docker:runtime-1/${fullContainerId}`,+ `docker:docker-platform/${fullContainerId.slice(0, 12)}`,+ `docker:runtime-1/${fullContainerId.slice(0, 12)}`,+ `docker:docker-platform/app-container-0011223344556677`,+ `docker:runtime-1/app-container-0011223344556677`,]);});- it('produces a single prefixed entry when the host exposes only its resource id', () => {+ it('strips a leading slash from the container name and skips absent ID forms', () => {const host = makeAgent({ id: 'lone-host' });- expect(dockerContainerOverrideIdCandidates(host, 'deadbeef')).toEqual([- 'docker:lone-host/deadbeef',+ const container = makeContainer({ name: '/proxy', docker: undefined });+ expect(dockerContainerOverrideIdCandidates(host, container)).toEqual([+ 'docker:lone-host/proxy',+ 'docker:lone-host/app-container-0011223344556677',]);});- it('falls back to platformData.docker.hostSourceId when discoveryTarget is absent', () => {- const host = makeAgent({- id: 'host-1',- platformData: { docker: { hostSourceId: 'docker-src' } },- });- expect(dockerContainerOverrideIdCandidates(host, 'cid')).toEqual([- 'docker:docker-src/cid',- 'docker:host-1/cid',+ it('falls back to the unified resource id when the container carries no name', () => {+ const host = makeAgent({ id: 'host-1' });+ const container = makeContainer({ name: undefined, docker: undefined });+ expect(dockerContainerOverrideIdCandidates(host, container)).toEqual([+ 'docker:host-1/app-container-0011223344556677',]);});it('returns an empty array when the host has no usable id signal at all', () => {- // resource.id is whitespace -> readString drops it -> uniqueIds yields [].+ // resource.id is whitespace -> asString drops it -> uniqueIds yields [].const host = makeAgent({ id: ' ' });- expect(dockerContainerOverrideIdCandidates(host, 'cid')).toEqual([]);+ expect(dockerContainerOverrideIdCandidates(host, makeContainer())).toEqual([]);});});diff --git a/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsAvailabilityMutations.ts b/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsAvailabilityMutations.tsindex 13d911f9d7..0c7df6c540 100644--- a/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsAvailabilityMutations.ts+++ b/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsAvailabilityMutations.ts@@ -181,9 +181,14 @@ export function useThresholdsAvailabilityMutations({(matchesAlertIdentifier(alert, offlineId) || alert.type === 'offline'),);} else if (resource.type === 'dockerContainer') {+ // Active docker alerts are keyed by the runtime container ID, which+ // may differ from the stable row id; match any known candidate.+ const alertResourceIds = resource.overrideIdCandidates?.length+ ? resource.overrideIdCandidates+ : [resourceId];props.removeAlerts((alert) =>- alert.resourceId === resourceId &&+ alertResourceIds.includes(alert.resourceId) &&(alert.type === 'docker-container-state' || alert.type === 'docker-container-health'),);}@@ -353,9 +358,12 @@ export function useThresholdsAvailabilityMutations({(alert) => alert.resourceId === resourceId && alert.type === 'powered-off',);} else if (resource.type === 'dockerContainer') {+ const alertResourceIds = resource.overrideIdCandidates?.length+ ? resource.overrideIdCandidates+ : [resourceId];props.removeAlerts((alert) =>- alert.resourceId === resourceId &&+ alertResourceIds.includes(alert.resourceId) &&(alert.type === 'docker-container-state' || alert.type === 'docker-container-health'),);}diff --git a/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsDockerData.ts b/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsDockerData.tsindex 6ac8de0669..3fe978a85b 100644--- a/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsDockerData.ts+++ b/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsDockerData.ts@@ -121,13 +121,15 @@ export function useThresholdsDockerData(inputs: ThresholdsDataInputs) {const containers = dockerContainersByHostId().get(host.id) ?? [];containers.forEach((container) => {- const shortId = container.id.includes('/')- ? (container.id.split('/').pop() ?? container.id)- : container.id;- const resourceIdCandidates = dockerContainerOverrideIdCandidates(host, shortId);+ const containerId = container.docker?.containerId?.trim();+ const shortId = containerId ? containerId.slice(0, 12) : container.id;+ const resourceIdCandidates = dockerContainerOverrideIdCandidates(host, container);const override = findOverrideByCandidates(overridesMap, resourceIdCandidates);- const resourceId =- override?.id || resourceIdCandidates[0] || `docker:${dockerHostIdForActions}/${shortId}`;+ // The row keys on the stable name-based candidate so it survives+ // container recreates; every candidate is marked seen so an override+ // still stored under a legacy ID key doesn't also surface as an+ // "Unassigned Containers" duplicate.+ const resourceId = resourceIdCandidates[0] || `docker:${dockerHostIdForActions}/${shortId}`;const overrideSeverity = override?.poweredOffSeverity;const hasCustomThresholds = hasThresholdDiff(override,@@ -166,12 +168,15 @@ export function useThresholdsDockerData(inputs: ThresholdsDataInputs) {hostId: dockerHostIdForActions,image,poweredOffSeverity: overrideSeverity,+ overrideIdCandidates: resourceIdCandidates,+ overrideStorageId: resourceId,};if (!groups[groupKey]) {groups[groupKey] = [];}groups[groupKey].push(resource);+ resourceIdCandidates.forEach((candidate) => seen.add(candidate));seen.add(resourceId);});});diff --git a/frontend-modern/src/features/alerts/thresholds/thresholdsResourceModel.ts b/frontend-modern/src/features/alerts/thresholds/thresholdsResourceModel.tsindex 2589662a09..a7c3f7a158 100644--- a/frontend-modern/src/features/alerts/thresholds/thresholdsResourceModel.ts+++ b/frontend-modern/src/features/alerts/thresholds/thresholdsResourceModel.ts@@ -88,8 +88,9 @@ export const dockerHostOverrideIdCandidates = (resource: Resource): string[] =>);};-export const dockerContainerOverrideIdCandidates = (host: Resource, shortId: string): string[] =>- uniqueIds(...dockerHostOverrideIdCandidates(host).map((hostId) => `docker:${hostId}/${shortId}`));+// Single implementation shared with the overrides projection so the lookup+// chain (stable name key first, legacy ID forms trailing) cannot drift.+export { dockerContainerOverrideIdCandidates } from '../alertOverridesModel';export const findOverrideByCandidates = (overridesMap: Map<string, Override>,diff --git a/frontend-modern/src/features/docker/DockerContainersTable.tsx b/frontend-modern/src/features/docker/DockerContainersTable.tsxindex a0be9912a2..eecace62e0 100644--- a/frontend-modern/src/features/docker/DockerContainersTable.tsx+++ b/frontend-modern/src/features/docker/DockerContainersTable.tsx@@ -461,13 +461,13 @@ export const DockerContainersTable: Component<DockerContainersTableProps> = (proconst host = () => dockerHostName(resource);const running = () => isContainerRunning(resource);const metricsKey = () => buildMetricKeyForUnifiedResource(resource);- // Overrides are keyed as docker:<hostId>/<shortId>; without the backing- // host resource only the docker-scope defaults can apply.+ // Overrides key on docker:<hostId>/<containerName> with legacy ID forms+ // as fallbacks; without the backing host resource only the docker-scope+ // defaults can apply.const alertResourceIds = () => {const hostResource = hostResourceByName().get(host());if (!hostResource) return [];- const shortId = resource.id.includes('/') ? resource.id.split('/').pop()! : resource.id;- return dockerContainerOverrideIdCandidates(hostResource, shortId);+ return dockerContainerOverrideIdCandidates(hostResource, resource);};const cpuThresholds = () =>alertsActivation.getMetricThresholds('docker', 'cpu', alertResourceIds());diff --git a/frontend-modern/src/features/docker/__tests__/dockerContainerTableModel.test.ts b/frontend-modern/src/features/docker/__tests__/dockerContainerTableModel.test.tsindex 573c54ea18..158df4e80d 100644--- a/frontend-modern/src/features/docker/__tests__/dockerContainerTableModel.test.ts+++ b/frontend-modern/src/features/docker/__tests__/dockerContainerTableModel.test.ts@@ -105,3 +105,18 @@ describe('dockerContainerTableModel', () => {expect(wideIds).toContain('mounts');});});++describe('docker container alert override identity', () => {+ it('resolves alert thresholds through the shared name-first override candidate chain', async () => {+ // Overrides key on docker:{host}/{containerName} so they survive+ // container recreates (#1601). The table must hand the full container+ // resource to the shared candidate builder instead of parsing an id+ // tail locally.+ const source = (await import('../DockerContainersTable.tsx?raw')).default;+ expect(source).toContain(+ "import { dockerContainerOverrideIdCandidates } from '@/features/alerts/alertOverridesModel'",+ );+ expect(source).toContain('dockerContainerOverrideIdCandidates(hostResource, resource)');+ expect(source).not.toContain("split('/')");+ });+});diff --git a/frontend-modern/src/utils/__tests__/alertThresholdsPresentation.test.ts b/frontend-modern/src/utils/__tests__/alertThresholdsPresentation.test.tsindex 1ea0ce479c..0cee8cbb09 100644--- a/frontend-modern/src/utils/__tests__/alertThresholdsPresentation.test.ts+++ b/frontend-modern/src/utils/__tests__/alertThresholdsPresentation.test.ts@@ -139,9 +139,9 @@ describe('alertThresholdsPresentation', () => {ignoreVmidsPlaceholder: '100, 200, 10*',});expect(getAlertThresholdsDockerIgnoredPrefixesPresentation()).toEqual({- title: 'Ignored container prefixes',+ title: 'Ignored container patterns',description:- 'Containers whose name or ID starts with any prefix below are skipped for container alerts. Enter one prefix per line; matching is case-insensitive.',+ 'Containers whose name or ID matches any pattern below are skipped for container alerts. A bare entry matches as a prefix; use * as a wildcard (runner-*, *-dev, *staging*). Enter one pattern per line; matching is case-insensitive.',resetLabel: 'Reset',placeholder: 'runner-',});diff --git a/frontend-modern/src/utils/alertThresholdsPresentation.ts b/frontend-modern/src/utils/alertThresholdsPresentation.tsindex 9eb569fa67..2a1c572e91 100644--- a/frontend-modern/src/utils/alertThresholdsPresentation.ts+++ b/frontend-modern/src/utils/alertThresholdsPresentation.ts@@ -49,9 +49,9 @@ export const ALERT_THRESHOLDS_BACKUP_IGNORE_VMIDS_LABEL = 'Ignore VMIDs';export const ALERT_THRESHOLDS_BACKUP_IGNORE_VMIDS_DESCRIPTION ='One per line. Use a trailing * to match a prefix (example: 10*).';export const ALERT_THRESHOLDS_BACKUP_IGNORE_VMIDS_PLACEHOLDER = '100, 200, 10*';-export const ALERT_THRESHOLDS_DOCKER_IGNORED_PREFIXES_TITLE = 'Ignored container prefixes';+export const ALERT_THRESHOLDS_DOCKER_IGNORED_PREFIXES_TITLE = 'Ignored container patterns';export const ALERT_THRESHOLDS_DOCKER_IGNORED_PREFIXES_DESCRIPTION =- 'Containers whose name or ID starts with any prefix below are skipped for container alerts. Enter one prefix per line; matching is case-insensitive.';+ 'Containers whose name or ID matches any pattern below are skipped for container alerts. A bare entry matches as a prefix; use * as a wildcard (runner-*, *-dev, *staging*). Enter one pattern per line; matching is case-insensitive.';export const ALERT_THRESHOLDS_DOCKER_IGNORED_PREFIXES_RESET_LABEL = 'Reset';export const ALERT_THRESHOLDS_DOCKER_IGNORED_PREFIXES_PLACEHOLDER = 'runner-';export const ALERT_THRESHOLDS_DOCKER_SERVICES_TITLE = 'Swarm service alerts';diff --git a/internal/alerts/alerts_test.go b/internal/alerts/alerts_test.goindex 1be0869047..b9bb56737b 100644--- a/internal/alerts/alerts_test.go+++ b/internal/alerts/alerts_test.go@@ -19795,3 +19795,87 @@ func TestManagerSkipsPersistedAlertRestoreForMockMode(t *testing.T) {t.Fatalf("mock mode must not resurface real persisted alerts, got %+v", alert)}}++func TestDockerContainerOverrideSurvivesContainerRecreate(t *testing.T) {+ // #1601: the disable toggle must key on host+name, not the container ID,+ // because the ID changes on every recreate (image update, compose up).+ exitedContainer := func(id string) models.DockerContainer {+ return models.DockerContainer{+ ID: id,+ Name: "media-server",+ State: "exited",+ Status: "Exited (1) seconds ago",+ }+ }+ hostWith := func(ct models.DockerContainer) models.DockerHost {+ return models.DockerHost{+ ID: "host-1",+ DisplayName: "Docker Host",+ Hostname: "docker.local",+ Containers: []models.DockerContainer{ct},+ }+ }+ stateAlertID := func(hostID, containerID string) string {+ return fmt.Sprintf("docker-container-state-%s", dockerResourceID(hostID, containerID))+ }++ // Subtests keep the two managers in separate lifetimes: newTestManager+ // holds a process-wide env mutex until its test cleanup runs.+ t.Run("control alert without override", func(t *testing.T) {+ control := newTestManager(t)+ control.CheckDockerHost(hostWith(exitedContainer("aaaaaaaaaaaa")))+ control.CheckDockerHost(hostWith(exitedContainer("aaaaaaaaaaaa")))+ if !testHasActiveAlert(t, control, stateAlertID("host-1", "aaaaaaaaaaaa")) {+ t.Fatalf("control: expected state alert for exited container without override")+ }+ })++ t.Run("name-keyed override survives recreate", func(t *testing.T) {+ m := newTestManager(t)+ m.mu.Lock()+ m.config.Overrides[dockerContainerOverrideKey("host-1", "media-server")] = ThresholdConfig{Disabled: true}+ m.mu.Unlock()++ m.CheckDockerHost(hostWith(exitedContainer("aaaaaaaaaaaa")))+ m.CheckDockerHost(hostWith(exitedContainer("aaaaaaaaaaaa")))+ if testHasActiveAlert(t, m, stateAlertID("host-1", "aaaaaaaaaaaa")) {+ t.Fatalf("expected name-keyed override to disable alerts for the original container")+ }++ // Recreate: same name, new container ID.+ m.CheckDockerHost(hostWith(exitedContainer("bbbbbbbbbbbb")))+ m.CheckDockerHost(hostWith(exitedContainer("bbbbbbbbbbbb")))+ if testHasActiveAlert(t, m, stateAlertID("host-1", "bbbbbbbbbbbb")) {+ t.Fatalf("expected name-keyed override to survive the container recreate")+ }+ })+}++func TestDockerContainerOverrideLegacyIDKeyStillHonoured(t *testing.T) {+ m := newTestManager(t)++ container := models.DockerContainer{+ ID: "cccccccccccc",+ Name: "batch-worker",+ State: "exited",+ Status: "Exited (0) seconds ago",+ }+ host := models.DockerHost{+ ID: "host-legacy",+ DisplayName: "Docker Host",+ Hostname: "docker.legacy",+ Containers: []models.DockerContainer{container},+ }++ m.mu.Lock()+ m.config.Overrides[dockerResourceID(host.ID, container.ID)] = ThresholdConfig{Disabled: true}+ m.mu.Unlock()++ m.CheckDockerHost(host)+ m.CheckDockerHost(host)++ alertID := fmt.Sprintf("docker-container-state-%s", dockerResourceID(host.ID, container.ID))+ if testHasActiveAlert(t, m, alertID) {+ t.Fatalf("expected legacy ID-keyed override to still disable container alerts")+ }+}diff --git a/internal/alerts/canonical_override_migration_test.go b/internal/alerts/canonical_override_migration_test.goindex 44cd55ce89..9f1e05ebb6 100644--- a/internal/alerts/canonical_override_migration_test.go+++ b/internal/alerts/canonical_override_migration_test.go@@ -121,3 +121,132 @@ func TestMigrateCanonicalOverrideKeysRetainsUnknownOrphanUntilSuccessionIsProvent.Fatal("transiently absent TrueNAS override was not retained for a later repoll")}}++func TestMigrateDockerContainerOverrideKeys(t *testing.T) {+ fullID := "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ appContainer := func(id, hostID, containerID, name string) unifiedresources.Resource {+ return unifiedresources.Resource{+ ID: id,+ Type: unifiedresources.ResourceTypeAppContainer,+ Name: name,+ Docker: &unifiedresources.DockerData{+ HostSourceID: hostID,+ ContainerID: containerID,+ },+ }+ }++ config := AlertConfig{Overrides: map[string]ThresholdConfig{+ // Live legacy key: re-homed onto the name key.+ "docker:host-1/aaaaaaaaaaaa": {Disabled: true},+ // Live legacy key whose name key already exists: dropped, name key wins.+ "docker:host-1/" + fullID: {Disabled: false},+ "docker:host-1/db": {Disabled: true},+ // Orphaned container-ID keys: pruned (12 and 64 char hex).+ "docker:host-1/dddddddddddd": {Disabled: true},+ // Unified hash key the v6 UI wrote: re-homed via the resource snapshot.+ "docker:host-1/app-container-0011223344556677": {Disabled: true},+ // Orphaned unified hash key: pruned.+ "docker:host-1/app-container-8899aabbccddeeff": {Disabled: true},+ // Name-keyed override for an absent container: kept.+ "docker:host-1/retired-cron": {Disabled: true},+ // Swarm service key: untouched.+ "docker:host-1/service/web": {Disabled: true},+ // A host not in the snapshot: untouched.+ "docker:host-9/eeeeeeeeeeee": {Disabled: true},+ // Docker host override (no slash): untouched.+ "host-1": {DisableConnectivity: true},+ }}++ resources := []unifiedresources.Resource{+ appContainer("app-container-1111111111111111", "host-1", "aaaaaaaaaaaa", "media-server"),+ appContainer("app-container-2222222222222222", "host-1", fullID, "db"),+ appContainer("app-container-0011223344556677", "host-1", "ffffffffffff", "proxy"),+ }++ original := config.Overrides+ if !MigrateDockerContainerOverrideKeys(&config, resources) {+ t.Fatalf("expected migration to report changes")+ }++ if _, exists := original["docker:host-1/aaaaaaaaaaaa"]; !exists {+ t.Fatalf("migration must be copy-on-write; the input map was mutated in place")+ }++ got := config.Overrides+ if override, exists := got["docker:host-1/media-server"]; !exists || !override.Disabled {+ t.Fatalf("expected live legacy key to move onto the name key, got %#v", got)+ }+ if override, exists := got["docker:host-1/proxy"]; !exists || !override.Disabled {+ t.Fatalf("expected live unified hash key to move onto the name key, got %#v", got)+ }+ for _, gone := range []string{+ "docker:host-1/aaaaaaaaaaaa",+ "docker:host-1/" + fullID,+ "docker:host-1/dddddddddddd",+ "docker:host-1/app-container-0011223344556677",+ "docker:host-1/app-container-8899aabbccddeeff",+ } {+ if _, exists := got[gone]; exists {+ t.Fatalf("expected %s to be removed", gone)+ }+ }+ if override := got["docker:host-1/db"]; !override.Disabled {+ t.Fatalf("expected existing name key to win over the legacy key")+ }+ for _, kept := range []string{+ "docker:host-1/retired-cron",+ "docker:host-1/service/web",+ "docker:host-9/eeeeeeeeeeee",+ "host-1",+ } {+ if _, exists := got[kept]; !exists {+ t.Fatalf("expected %s to be kept", kept)+ }+ }+}++func TestMigrateDockerContainerOverrideKeysNoChanges(t *testing.T) {+ resources := []unifiedresources.Resource{{+ ID: "app-container-1111111111111111",+ Type: unifiedresources.ResourceTypeAppContainer,+ Name: "media-server",+ Docker: &unifiedresources.DockerData{+ HostSourceID: "host-1",+ ContainerID: "aaaaaaaaaaaa",+ },+ }}++ config := AlertConfig{Overrides: map[string]ThresholdConfig{+ "docker:host-1/media-server": {Disabled: true},+ }}+ if MigrateDockerContainerOverrideKeys(&config, resources) {+ t.Fatalf("expected no changes when overrides already use stable keys")+ }++ // A host with no docker-sourced app-containers in the snapshot may be a+ // transient collection failure; nothing under it may be pruned.+ config = AlertConfig{Overrides: map[string]ThresholdConfig{+ "docker:host-9/aaaaaaaaaaaa": {Disabled: true},+ }}+ if MigrateDockerContainerOverrideKeys(&config, resources) {+ t.Fatalf("expected hosts absent from the snapshot to be untouched")+ }+}++func TestLooksLikeDockerContainerID(t *testing.T) {+ cases := map[string]bool{+ "aaaaaaaaaaaa": true,+ "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef": true,+ "ABCDEF123456": true,+ "media-server": false,+ "aaaaaaaaaaa": false, // 11 chars+ "gggggggggggg": false, // non-hex+ "": false,+ }+ for value, want := range cases {+ if got := looksLikeDockerContainerID(value); got != want {+ t.Errorf("looksLikeDockerContainerID(%q) = %v, want %v", value, got, want)+ }+ }+}diff --git a/internal/alerts/config_runtime.go b/internal/alerts/config_runtime.goindex ec2b06dadc..90839be404 100644--- a/internal/alerts/config_runtime.go+++ b/internal/alerts/config_runtime.go@@ -436,17 +436,21 @@ func (m *Manager) reevaluateActiveAlertsLocked() {alertsToResolve = append(alertsToResolve, alertID)continue}- containerName := strings.ToLower(strings.TrimSpace(alert.ResourceName))+ containerName := strings.TrimSpace(alert.ResourceName)containerID := ""+ hostID := ""if alert.Metadata != nil {if val, ok := alert.Metadata["containerId"].(string); ok {containerID = strings.ToLower(strings.TrimSpace(val))}if val, ok := alert.Metadata["containerName"].(string); ok && containerName == "" {- containerName = strings.ToLower(strings.TrimSpace(val))+ containerName = strings.TrimSpace(val)+ }+ if val, ok := alert.Metadata["hostId"].(string); ok {+ hostID = val}}- if matchesDockerIgnoredPrefix(containerName, containerID, m.config.DockerIgnoredContainerPrefixes) {+ if matchesDockerIgnoredPrefix(strings.ToLower(containerName), containerID, m.config.DockerIgnoredContainerPrefixes) {alertsToResolve = append(alertsToResolve, alertID)continue}@@ -455,7 +459,7 @@ func (m *Manager) reevaluateActiveAlertsLocked() {Memory: cloneThreshold(&m.config.DockerDefaults.Memory),Disk: cloneThreshold(&m.config.DockerDefaults.Disk),}- if override, exists := m.config.Overrides[resourceID]; exists {+ if override, exists := m.lookupDockerContainerOverrideNoLock(hostID, containerName, resourceID); exists {if override.Disabled {alertsToResolve = append(alertsToResolve, alertID)continuediff --git a/internal/alerts/docker.go b/internal/alerts/docker.goindex 2deb7e979b..59b4d27ad5 100644--- a/internal/alerts/docker.go+++ b/internal/alerts/docker.go@@ -47,6 +47,38 @@ func dockerContainerDisplayName(container models.DockerContainer) string {return name}+// dockerContainerOverrideKey builds the durable override key for a container:+// host + container *name*. Container IDs change on every recreate (image+// update, compose up), so ID-keyed overrides orphan the moment a container is+// updated; the name is the identity that survives (#1601). Returns "" when+// either part is missing so callers fall back to the legacy ID key.+func dockerContainerOverrideKey(hostID, containerName string) string {+ hostID = strings.TrimSpace(hostID)+ name := strings.TrimLeft(strings.TrimSpace(containerName), "/")+ if hostID == "" || name == "" {+ return ""+ }+ return fmt.Sprintf("docker:%s/%s", hostID, name)+}++// lookupDockerContainerOverrideNoLock resolves a container override,+// preferring the stable host+name key and falling back to the legacy+// container-ID resource ID so pre-migration entries keep working.+// Callers must hold m.mu.+func (m *Manager) lookupDockerContainerOverrideNoLock(hostID, containerName, legacyResourceID string) (ThresholdConfig, bool) {+ if stableKey := dockerContainerOverrideKey(hostID, containerName); stableKey != "" {+ if override, ok := m.config.Overrides[stableKey]; ok {+ return override, true+ }+ }+ if legacyResourceID != "" {+ if override, ok := m.config.Overrides[legacyResourceID]; ok {+ return override, true+ }+ }+ return ThresholdConfig{}, false+}+// dockerResourceID builds a stable identifier for Docker container alerts.func dockerResourceID(hostID, containerID string) string {hostID = strings.TrimSpace(hostID)@@ -285,7 +317,7 @@ func (m *Manager) evaluateDockerContainer(host models.DockerHost, container modecontainerTags := dockerLabelTags(container.Labels)m.mu.RLock()- overrideConfig, hasOverride := m.config.Overrides[resourceID]+ overrideConfig, hasOverride := m.lookupDockerContainerOverrideNoLock(host.ID, container.Name, resourceID)m.mu.RUnlock()if hasOverride && overrideConfig.Disabled {// Alerts disabled via override; clear any existing alerts and skip evaluation.@@ -749,7 +781,7 @@ func (m *Manager) checkDockerContainerState(host models.DockerHost, container mostateKey := resourceIDm.mu.RLock()- override, hasOverride := m.config.Overrides[resourceID]+ override, hasOverride := m.lookupDockerContainerOverrideNoLock(host.ID, container.Name, resourceID)defaultDisable := m.config.DockerDefaults.StateDisableConnectivitydefaultSeverity := NormalizePoweredOffSeverity(m.config.DockerDefaults.StatePoweredOffSeverity)m.mu.RUnlock()@@ -1242,13 +1274,9 @@ func (m *Manager) shouldResolveDockerContainerUpdateAlertLocked(alert *Alert) boreturn true}- if override, exists := m.config.Overrides[alert.ResourceID]; exists && override.Disabled {- m.clearDockerContainerUpdateStateLocked(alert)- return true- }-containerName := strings.TrimSpace(alert.ResourceName)containerID := ""+ hostID := ""if alert.Metadata != nil {if value, ok := alert.Metadata["containerName"].(string); ok && containerName == "" {containerName = value@@ -1256,6 +1284,14 @@ func (m *Manager) shouldResolveDockerContainerUpdateAlertLocked(alert *Alert) boif value, ok := alert.Metadata["containerId"].(string); ok {containerID = value}+ if value, ok := alert.Metadata["hostId"].(string); ok {+ hostID = value+ }+ }++ if override, exists := m.lookupDockerContainerOverrideNoLock(hostID, containerName, alert.ResourceID); exists && override.Disabled {+ m.clearDockerContainerUpdateStateLocked(alert)+ return true}if matchesDockerIgnoredPrefix(containerName, containerID, m.config.DockerIgnoredContainerPrefixes) {m.clearDockerContainerUpdateStateLocked(alert)diff --git a/internal/alerts/docker_override_migration.go b/internal/alerts/docker_override_migration.gonew file mode 100644index 0000000000..fd14733656--- /dev/null+++ b/internal/alerts/docker_override_migration.go@@ -0,0 +1,159 @@+package alerts++import (+ "strings"++ "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"+)++// MigrateDockerContainerOverrideKeys re-homes container overrides onto the+// stable host+name key and prunes entries whose container no longer exists.+// Container IDs change on every recreate, so an image update orphaned the+// user's per-container alert toggle and left a dead entry in alerts.json+// forever (#1601). Three key shapes exist in the wild:+//+// docker:{host}/{name} stable (target, written by the UI now)+// docker:{host}/{container ID} legacy backend key (v5-era writes)+// docker:{host}/app-container-{16 hex} unified hash IDs the v6 UI wrote+//+// Live legacy and hash keys are moved onto the stable key; orphaned ID-shaped+// keys are pruned. Only hosts with at least one docker-sourced app-container+// in the snapshot are touched (an empty set can be a transient collection+// failure), and name-keyed overrides for absent containers are kept so a+// later recreate under the same name still honours them. Like+// MigrateCanonicalOverrideKeys, the config is mutated copy-on-write: callers+// hand in a GetConfig() snapshot whose Overrides map is shared with the live+// manager config.+func MigrateDockerContainerOverrideKeys(config *AlertConfig, resources []unifiedresources.Resource) bool {+ if config == nil || len(config.Overrides) == 0 || len(resources) == 0 {+ return false+ }++ changed := false+ overrides := make(map[string]ThresholdConfig, len(config.Overrides))+ for resourceID, override := range config.Overrides {+ overrides[resourceID] = override+ }++ rehome := func(fromKey, toKey string) {+ override, exists := overrides[fromKey]+ if !exists {+ return+ }+ if toKey != "" && toKey != fromKey {+ if _, taken := overrides[toKey]; !taken {+ overrides[toKey] = override+ }+ }+ delete(overrides, fromKey)+ changed = true+ }++ liveKeysByHost := make(map[string]map[string]struct{})+ for _, resource := range resources {+ if unifiedresources.CanonicalResourceType(resource.Type) != unifiedresources.ResourceTypeAppContainer {+ continue+ }+ if resource.Docker == nil {+ continue+ }+ hostID := strings.TrimSpace(resource.Docker.HostSourceID)+ if hostID == "" {+ continue+ }++ live := liveKeysByHost[hostID]+ if live == nil {+ live = make(map[string]struct{})+ liveKeysByHost[hostID] = live+ }++ stableKey := dockerContainerOverrideKey(hostID, resource.Name)+ if stableKey != "" {+ live[stableKey] = struct{}{}+ }++ legacyKey := ""+ if containerID := strings.TrimSpace(resource.Docker.ContainerID); containerID != "" {+ legacyKey = dockerResourceID(hostID, containerID)+ live[legacyKey] = struct{}{}+ }+ if legacyKey != "" && legacyKey != stableKey {+ rehome(legacyKey, stableKey)+ }++ // The v6 thresholds UI keyed container overrides by the unified hash+ // ID, which the evaluator never read. Re-home them while the hash is+ // still resolvable to a live container.+ if resourceID := strings.TrimSpace(resource.ID); resourceID != "" {+ if hashKey := "docker:" + hostID + "/" + resourceID; hashKey != stableKey {+ rehome(hashKey, stableKey)+ }+ }+ }++ for hostID, live := range liveKeysByHost {+ if len(live) == 0 {+ continue+ }+ prefix := "docker:" + hostID + "/"+ for key := range overrides {+ if !strings.HasPrefix(key, prefix) {+ continue+ }+ rest := key[len(prefix):]+ // "service/<name>" keys belong to Swarm services.+ if strings.Contains(rest, "/") {+ continue+ }+ if _, isLive := live[key]; isLive {+ continue+ }+ // A suffix that is neither a container ID nor a unified hash ID+ // is a name-keyed override for a currently absent container; keep+ // it so a recreate under the same name still honours it.+ if !looksLikeDockerContainerID(rest) && !looksLikeUnifiedAppContainerID(rest) {+ continue+ }+ delete(overrides, key)+ changed = true+ }+ }++ if changed {+ config.Overrides = overrides+ }+ return changed+}++// looksLikeDockerContainerID reports whether the value has the shape of a+// Docker container ID (12-char short or 64-char full hex).+func looksLikeDockerContainerID(value string) bool {+ if len(value) != 12 && len(value) != 64 {+ return false+ }+ return isHexString(value)+}++// looksLikeUnifiedAppContainerID reports whether the value has the shape of a+// unified app-container resource ID ("app-container-" + 16 hex chars).+func looksLikeUnifiedAppContainerID(value string) bool {+ const prefix = "app-container-"+ if !strings.HasPrefix(value, prefix) {+ return false+ }+ suffix := value[len(prefix):]+ return len(suffix) == 16 && isHexString(suffix)+}++func isHexString(value string) bool {+ if value == "" {+ return false+ }+ for _, r := range value {+ if (r < '0' || r > '9') && (r < 'a' || r > 'f') && (r < 'A' || r > 'F') {+ return false+ }+ }+ return true+}diff --git a/internal/alerts/unified_eval.go b/internal/alerts/unified_eval.goindex 63e0a8ecf4..e7777703b5 100644--- a/internal/alerts/unified_eval.go+++ b/internal/alerts/unified_eval.go@@ -21,7 +21,9 @@ import (// Storage: storage.ID e.g. "local-lvm"// PBS: pbs.ID e.g. "pbs-1"// PMG: pmg.ID e.g. "pmg-1"-// Docker Container: "docker:{hostID}/{containerID}"+// Docker Container: "docker:{hostID}/{containerName}" (stable across+// container recreates; legacy "docker:{hostID}/{containerID}"+// entries are still honoured and migrated, #1601)// Kubernetes: canonical unified resource ID for cluster/node/namespace/deployment/pod// TrueNAS System: canonical unified agent resource ID// TrueNAS Storage: canonical unified storage resource ID for pool/datasetdiff --git a/internal/alerts/unified_eval_test.go b/internal/alerts/unified_eval_test.goindex 58d041485a..00dcf229ff 100644--- a/internal/alerts/unified_eval_test.go+++ b/internal/alerts/unified_eval_test.go@@ -1492,3 +1492,29 @@ func TestCheckPMGAnomalyAnnotatesCanonicalSpecMetadata(t *testing.T) {t.Fatalf("canonicalSpecID = %v, want pmg-1-anomaly-spamIn", got)}}++func TestUnifiedResourceInputExcludesDockerAppContainers(t *testing.T) {+ // Docker containers are evaluated by CheckDockerHost against the+ // docker:{host}/{containerName} override key (#1601); unified eval must+ // not double-evaluate them under a second identity.+ resource := unifiedresources.Resource{+ ID: "app-container-1234567890abcdef",+ Type: unifiedresources.ResourceTypeAppContainer,+ Name: "media-server",+ Docker: &unifiedresources.DockerData{+ HostSourceID: "host-1",+ ContainerID: "aaaaaaaaaaaa",+ },+ }+ if input, ok := UnifiedResourceInputFromResource(resource); ok {+ t.Fatalf("docker app-containers must stay owned by CheckDockerHost, got unified input %+v", input)+ }++ // TrueNAS apps remain unified-eval owned.+ resource.Docker = nil+ resource.TrueNAS = &unifiedresources.TrueNASData{}+ input, ok := UnifiedResourceInputFromResource(resource)+ if !ok || input.Type != "truenas-app" {+ t.Fatalf("truenas app containers must stay unified-eval owned, got %+v ok=%v", input, ok)+ }+}diff --git a/internal/monitoring/monitor_alert_override_migration_test.go b/internal/monitoring/monitor_alert_override_migration_test.goindex 91be7ae53b..6fe6b23203 100644--- a/internal/monitoring/monitor_alert_override_migration_test.go+++ b/internal/monitoring/monitor_alert_override_migration_test.go@@ -302,3 +302,77 @@ func TestMigrateAvailabilityLinkedResourcesFailsClosedOnAmbiguity(t *testing.T)t.Fatalf("ambiguous claims must not migrate, got %+v", migrated)}}++func TestSyncUnifiedResourceAlertsMigratesDockerContainerOverrideKeys(t *testing.T) {+ dockerApp := func(id, hostID, containerID, name string) unifiedresources.Resource {+ return unifiedresources.Resource{+ ID: id,+ Type: unifiedresources.ResourceTypeAppContainer,+ Name: name,+ Docker: &unifiedresources.DockerData{+ HostSourceID: hostID,+ ContainerID: containerID,+ },+ }+ }++ dataDir := t.TempDir()+ persistence := config.NewConfigPersistence(dataDir)+ manager := alerts.NewManagerWithDataDir(dataDir)+ t.Cleanup(manager.Stop)++ alertConfig := manager.GetConfig()+ alertConfig.Enabled = true+ alertConfig.ActivationState = alerts.ActivationActive+ alertConfig.Overrides = map[string]alerts.ThresholdConfig{+ // Container IDs change on every recreate; the sync loop must re-home+ // this live legacy key onto docker:{host}/{name} (#1601).+ "docker:host-1/aaaaaaaaaaaa": {Disabled: true},+ // The v6 UI keyed overrides by the unified hash id; re-homed too.+ "docker:host-1/app-container-0011223344556677": {Disabled: true},+ // Orphan from a past recreate: pruned.+ "docker:host-1/bbbbbbbbbbbb": {Disabled: true},+ }+ manager.UpdateConfig(alertConfig)+ if err := persistence.SaveAlertConfig(manager.GetConfig()); err != nil {+ t.Fatalf("seed legacy alert config: %v", err)+ }++ monitor := &Monitor{+ alertManager: manager,+ configPersist: persistence,+ state: models.NewState(),+ }+ monitor.syncUnifiedResourceAlertsToState([]unifiedresources.Resource{+ dockerApp("app-container-1111111111111111", "host-1", "aaaaaaaaaaaa", "media-server"),+ dockerApp("app-container-0011223344556677", "host-1", "cccccccccccc", "proxy"),+ })++ inMemory := manager.GetConfig()+ for _, gone := range []string{+ "docker:host-1/aaaaaaaaaaaa",+ "docker:host-1/app-container-0011223344556677",+ "docker:host-1/bbbbbbbbbbbb",+ } {+ if _, exists := inMemory.Overrides[gone]; exists {+ t.Fatalf("in-memory override remained under retired docker key %s", gone)+ }+ }+ if override := inMemory.Overrides["docker:host-1/media-server"]; !override.Disabled {+ t.Fatalf("legacy container-ID override did not re-home onto the name key: %+v", inMemory.Overrides)+ }+ if override := inMemory.Overrides["docker:host-1/proxy"]; !override.Disabled {+ t.Fatalf("unified-hash override did not re-home onto the name key: %+v", inMemory.Overrides)+ }++ reloaded, err := config.NewConfigPersistence(dataDir).LoadAlertConfig()+ if err != nil {+ t.Fatalf("reload migrated alert config: %v", err)+ }+ if _, exists := reloaded.Overrides["docker:host-1/aaaaaaaaaaaa"]; exists {+ t.Fatalf("persisted override remained under the retired container-ID key")+ }+ if override := reloaded.Overrides["docker:host-1/media-server"]; !override.Disabled {+ t.Fatalf("persisted config missing the re-homed name-keyed override: %+v", reloaded.Overrides)+ }+}diff --git a/internal/monitoring/monitor_alert_sync.go b/internal/monitoring/monitor_alert_sync.goindex 234310c3c1..ccf1940a89 100644--- a/internal/monitoring/monitor_alert_sync.go+++ b/internal/monitoring/monitor_alert_sync.go@@ -97,7 +97,11 @@ func (m *Monitor) syncUnifiedResourceAlertsToState(resources []unifiedresources.}config := m.alertManager.GetConfig()- if alerts.MigrateCanonicalOverrideKeys(&config, resources) {+ migrated := alerts.MigrateCanonicalOverrideKeys(&config, resources)+ if alerts.MigrateDockerContainerOverrideKeys(&config, resources) {+ migrated = true+ }+ if migrated {if m.configPersist == nil {log.Warn().Msg("cannot persist canonical alert override migration without config persistence")} else if err := m.configPersist.SaveAlertConfig(config); err != nil {