Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Share demo generation and stabilize workload parent groups

rcourtmance8c8f918c50
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md
index 21f5c3b914..aea3a46119 100644
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@ -3792,49 +3792,44 @@ and alert outage precaution until that operational outcome is verified.
### Mock-mode unified view applies operator links
-The mock branch of `currentUnifiedStateView` builds the view the broadcast,
-`/api/state`, `GetUnifiedReadStateOrSnapshot` and `UnifiedResourceSnapshot`
-serve in mock mode from the fixture graph, which knows no link store. It now
-builds the graph with the links the monitor's resource store applied at its
-current generation (`resourceStoreManualLinks`,
-`mock.UnifiedResourceSnapshotWithLinks`; unified-resources contract
-"Mock-mode unified view applies operator links"), so a link reaches the mock
-broadcast when the resource store's next rebuild loads it, as in live mode; in
-mock mode that is normally the broadcast's own read-path refresh once the
-generation is older than `readPathRegistryFreshness`. The cached view is keyed
-on the fixture data version and the link list, each link by its resource pair,
-its primary and its creation time (`sameManualLinks`, which the structure view
-reuses), so a link change rebuilds it without a fixture tick; an unchanged
-list keeps the shared build. The creation time is in the key because, among
-otherwise equal candidates, a chain of links folds into the primary of its
-earliest-created link (unified-resources contract, "Operator links reach
-record-ingested resources", "Links apply as chains"): lists that differ only
-in a time can leave a different row standing, and a key that ignored it kept
-serving the row the old times chose while the live rebuild, which reloads the
-links from the store, served the new one. Freshness,
-which the resources API keys its registry cache on, is assigned in
-publication order under `mockUnifiedViewMu`: a view built from the same
-fixture freshness and links as the one it replaces keeps its freshness, and
-any other view gets a later one than every view before it, so a slow build
-that publishes late cannot reuse a value. With no links the view still comes
-from the shared memoized fixture snapshot, so the demo's allocation profile is
-unchanged; with links each monitor builds its own linked snapshot whenever
-the fixture data or links change (concurrent misses can each build one). The fence view behind `currentModeReadState` still omits links (see
-the mock-mode fence above): it stays a plain projection of current state for
-the window before a rebuild in the new epoch, after which the registry applies
-the links again. `TestMockUnifiedViewAppliesOperatorManualLinks` in
-`internal/monitoring/monitor_host_agents_test.go` pins the broadcast, the
-freshness advance and the cache,
-`TestMockUnifiedViewFollowsALinkCreationTimeChange` in the same file pins the
-creation time in that key (a Proxmox storage, a TrueNAS VM and a vSphere VM
-linked in a cycle swap the surviving VM when only one link's time moves, with
-the fixture data version held, through the structure view and the
-data-version view alike, and match what a linked mock build keeps),
-`TestFixtureGraphAppliesManualLinksAtTheRebuildsBoundary`
-and `TestUnifiedResourceSnapshotWithLinksLeavesTheSharedSnapshotUnlinked` in
-`internal/mock/platform_fixtures_test.go` pin the linked fixture build, and
-`TestMockUnifiedStateViewUsesCanonicalMockFixtureGraph` in
-`internal/monitoring/canonical_guardrails_test.go` pins the call.
+The mock branch of currentUnifiedStateView serves the fixture graph to the
+broadcast, /api/state, GetUnifiedReadStateOrSnapshot and UnifiedResourceSnapshot.
+The graph delegates resource assembly to the live
+MonitorAdapter.PopulateSnapshotAndSupplemental generation boundary. Snapshot
+and supplemental records share source ordering, operator-link application,
+availability projection and final freshness policy. Fixtures still generate
+synthetic provider inputs rather than exercising provider collection.
+
+The storeless graph receives the links loaded by the monitor's current resource
+store generation through resourceStoreManualLinks and
+mock.UnifiedResourceSnapshotWithLinks. Its next rebuild loads new links. Mock
+broadcast reads normally trigger that refresh after readPathRegistryFreshness.
+Storeless generations retain explicit links without writing fixture identity
+pins, successions or change history.
+
+The cached data view compares fixture freshness and each link's pair, primary
+and creation time through sameManualLinks. The structure view compares the
+fixture structure revision and the same link fields. Changing a link or the
+oldest link in a chain rebuilds the view without a fixture tick. No-link readers
+use the shared memoized view. Linked readers build their monitor's own view when
+fixture data or links change. Concurrent cache misses can each build a view.
+
+Publication under mockUnifiedViewMu preserves freshness only for identical
+fixture freshness and links. Every different view receives a later value than
+all previous publications, so a slow build cannot reuse a newer view's value.
+The resources API keys its registry cache on that published freshness. Metrics
+targets are captured with resources through the adapter's indexed view lookup.
+The fence behind currentModeReadState remains a plain, unlinked projection
+until the new epoch's rebuild applies the links.
+
+See unified-resources, "Mock-mode unified view applies operator links", for
+chain, availability and fixture-exclusion behavior. Proof remains
+TestMockUnifiedViewAppliesOperatorManualLinks and
+TestMockUnifiedViewFollowsALinkCreationTimeChange in
+internal/monitoring/monitor_host_agents_test.go, the fixture boundary and
+freshness tests in internal/mock/platform_fixtures_test.go, and
+TestMockUnifiedStateViewUsesCanonicalMockFixtureGraph in
+internal/monitoring/canonical_guardrails_test.go.
### Mock-mode metrics-target lookups ride the fixture structure revision
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
index ac8edfe4b4..5926197054 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -3748,21 +3748,36 @@ nonempty machine and agent IDs and canonical identity across fixture rebuilds.
This changes fixture generation only, without relaxing production identity
resolution or adding work to the recurring update path.
-### Mock linked fixture builds use the rebuild's link boundary
-
-The mock fixture build holds the operator-link pass back until the snapshot and
-every supplemental source but availability are ingested, then runs one deferred
-pass before availability (`DeferManualLinks`, `ApplyDeferredManualLinks`), as
-the monitor's rebuild does; the availability ingest runs its own pass after it,
-as in the rebuild. The shared memoized snapshot has no links, so it defers
-nothing and builds as before (about 52 ms and 65 MB on the default fixture
-estate, with or without the change). A linked build, which runs only when the
-fixture data version or the link list changes, pays one extra refresh round
-after the deferred pass: about 3 ms and 5 MB more on that estate, the same
-round the rebuild runs.
-`TestFixtureGraphAppliesManualLinksAtTheRebuildsBoundary` in
-`internal/mock/platform_fixtures_test.go` pins the result a pass per source
-does not reach.
+### Mock linked fixture builds use the live resource generation
+
+The fixture graph delegates snapshot and supplemental resource assembly to
+MonitorAdapter.PopulateSnapshotAndSupplemental. It shares the live monitor's
+source ordering, deferred operator-link boundary, availability projection and
+final freshness verdict. Storeless generations retain explicit links without
+adding persistence. The fixture data and link cache boundaries remain unchanged.
+
+The graph obtains resources and metrics targets together through
+GetAllWithMetricsTargets, which indexes source mappings once. It does not
+materialize an unrelated VM view to warm a cache or scan all mappings for each
+resource. Generation cost is paid when a fixture view rebuilds, not on every
+alert target lookup. No performance measurement is claimed for this change.
+TestFixtureGraphAppliesManualLinksAtTheRebuildsBoundary and
+TestFixtureGraphMatchesMonitorSupplementalFreshness in
+internal/mock/platform_fixtures_test.go pin the generation behavior.
+
+### vSphere workload groups follow canonical parent identity
+
+The workload adapter copies resource.parentId into parentResourceId. vSphere
+workload groups use that server parent identity while cluster, connection and
+host display labels are enriched. A metadata update therefore keeps the row
+and its drawer mounted, including its selected History tab. The workload
+instance fallback uses an explicit cluster and never the workload's own name.
+Legacy rows without a canonical parent retain the existing scoped fallback.
+
+The snapshot-enrichment case in hooks/__tests__/useWorkloads.test.ts and the
+parent-identity cases in Workloads/__tests__/workloadSelectors.test.ts preserve
+group stability, updated display labels and separation of equal host labels
+belonging to different canonical parents.
### Alert passes resolve metrics targets without materializing the estate
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 5cf8b2b85c..905360e196 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -7180,11 +7180,10 @@ links" below).
folded ID as they were. The resources API's snapshot-seeded fallback,
used only while the monitor has published no unified listing, still
ingests the snapshot and each supplemental source with a pass per call.
- The mock-mode fixture build (`internal/mock`) draws the rebuild's boundary
- (`DeferManualLinks`, `ApplyDeferredManualLinks`; see "Mock-mode unified
- view applies operator links"), so a chain whose answer depends on the
- order its members' sources arrive in settles there as it does in the
- monitor's rebuild.
+ The mock-mode fixture build (`internal/mock`) delegates to
+ `MonitorAdapter.PopulateSnapshotAndSupplemental` (see "Mock-mode unified
+ view applies operator links"), so it shares the monitor's rebuild boundary
+ rather than reproducing source-order and link policy.
- Rows fold along the chain's links, deepest first, so each fold record
names a stored link's pair. The links form a spanning tree from the root
that follows the fold records the rows already carry before any other
@@ -7401,102 +7400,64 @@ resources API's write and Patrol's read on the same store.
### Mock-mode unified view applies operator links
-In mock mode the websocket broadcast, `/api/state`, and the monitor's
-`GetUnifiedReadStateOrSnapshot` and `UnifiedResourceSnapshot` readers serve a
-view of the fixture graph, not the monitor's resource store, and the fixture
-graph was built without the link store. The resources API seeds its registry
-from that same list through a registry backed by the link store, so a manual
-link showed merged there while the broadcast kept both rows. The fixture graph
-is now built with the links the monitor adapter's current registry generation
-loaded from its store (`MonitorAdapter.ManualLinks`), in a registry that has
-no store at all (`NewRegistryWithManualLinks`,
-`mock.UnifiedResourceSnapshotWithLinks`). Nothing that build ingests can write
-identity pins, canonical-ID successions or change records, and the view's read
-state forwards no history to the operator's store, so fixture data stays out
-of durable state through it.
-
-- The links apply at the live rebuild's boundary (the monitor's rebuild
- holds the link pass back, above): the build holds the pass back
- (`DeferManualLinks`), ingests the snapshot and the TrueNAS and vSphere
- records, runs it once over that estate (`ApplyDeferredManualLinks`, which
- takes the stale thresholds the ingests were given, nil for the registry's
- own), and only then ingests availability. A chain of links is judged over
- every member's source at once, as the rebuild judges it, so the row that
- survives does not depend on which source arrives first: a Proxmox storage,
- a TrueNAS VM and a vSphere VM linked in a cycle keep the TrueNAS VM whose
- link is the oldest, where a pass after the TrueNAS records had already
- folded it into the storage and kept the vSphere VM. A registry with no
- links defers nothing, so the shared memoized snapshot is built exactly as
- before. An availability check that names the folded resource by source
- reference resolves through the fold and projects onto the primary, and so
- does one that names it by canonical ID, which the registry resolves through
- the fold history (`TestAvailabilityLinkToALinkFoldedResourceFollowsItsPrimary`
- in `internal/unifiedresources/availability_link_test.go`). Folding the
- finished list instead dropped the check with the folded row.
-- A link reaches the view when the adapter's next rebuild loads it, the same
- point at which the live broadcast picks it up. The view's cache is keyed on
- the fixture data version and on each link's resource pair, primary and
- creation time, so a link change rebuilds it without waiting for a fixture
- tick. The creation time is part of the key because, among otherwise equal
- candidates, a chain folds into the primary of its earliest-created link
- (the "Links apply as chains" bullet of "Operator links reach
- record-ingested resources"): link lists that differ only in a creation
- time can leave a different row standing. In the storage, TrueNAS VM and
- vSphere VM cycle above both VMs outrank the storage, so the TrueNAS VM
- keeps its row while its link is older than the vSphere VM's and the
- vSphere VM keeps it once the TrueNAS VM's link is newer. A key that
- compared pairs and primaries alone kept serving the row the old times
- chose with the fixture data version unchanged, while the live rebuild,
- which reloads the links from the store, served the new one. The structure
- view that serves
- callers reading identity and topology only keys on the fixture structure
- revision and the same link comparison, so a creation time change rebuilds
- it too. Freshness is
- assigned in publication order: a view built from the same fixture
- freshness and links as the one it replaces keeps its freshness, and any
- other view gets a later one than every view published before it, even when
- a slower build publishes after a newer one. The resources API reuses its
- registry while that freshness is unchanged, so it follows the published
- view and does not keep a list other links folded, for example after a
- link's primary is reversed. Fixture freshness stands in for the fixture
- data, as it already did for that cache.
-- Without links the view is built from the shared memoized fixture snapshot,
- as before. With links each monitor builds its own linked snapshot whenever
- the fixture data or links change (concurrent cache misses can each build
- one).
-- Exclusions are not carried by the fixture registry, as before. The
- broadcast's presentation coalescing consults the monitor adapter's
- exclusions, while the resources API's `ListForPresentation` consults its
- own store-backed registry's exclusions. Neither can undo an automatic
- identity merge already made inside the store-free fixture graph.
-- An agent linked into a guest leaves the agent listings (`Hosts()` lists
- agent-type rows only) and the guest carries its facet, as in live mode.
-
-`TestMockUnifiedViewAppliesOperatorManualLinks` in
-`internal/monitoring/monitor_host_agents_test.go` pins the broadcast payload,
-the rebuild and freshness advance on a link change with the fixture data
-version held, the cached build afterwards, the same rows as a store-backed
-registry seeded through resource ingest the way the resources API seeds, and
-no change rows reaching the store through the view.
-`TestMockUnifiedViewFollowsALinkCreationTimeChange` in the same file pins the
-creation time in the cache key: the cycle above, with only the TrueNAS VM's
-link time moved and the fixture data version held, swaps the surviving VM in
-the structure view and in the data-version view, each matching the row a
-linked mock build keeps.
-`TestFixtureGraphAppliesManualLinksAtTheRebuildsBoundary` and
-`TestUnifiedResourceSnapshotWithLinksLeavesTheSharedSnapshotUnlinked` in
-`internal/mock/platform_fixtures_test.go` pin the rebuild's boundary (the
-cycle above settling on the row the monitor's rebuild keeps, which a pass per
-source does not, and the availability projection after the pass) and the
-untouched shared snapshot,
-`TestRegistryHoldsManualLinksBackUntilTheDeferredPass` and
-`TestRegistryDeferredLinkPassJudgesFreshnessByTheCallersThresholds` in
-`internal/unifiedresources/registry_merge_policy_test.go` pin the exported
-pair (the snapshot and record ingests wait, the pass runs once, and it judges
-freshness by the thresholds it is given), and
-`TestRegistryWithManualLinksFoldsLikeTheStoreBackedRegistry` in
-`internal/unifiedresources/registry_test.go` pins the store-less registry
-against the store-backed one and the per-generation `ManualLinks` snapshot.
+The mock fixture graph uses MonitorAdapter.PopulateSnapshotAndSupplemental for
+the same resource generation boundary as the live monitor. It ingests snapshot
+and supplemental records, applies operator links over the assembled estate,
+ingests availability last, and makes the final freshness verdict. Supplemental
+sightings age under the monitor's source thresholds, including TrueNAS-only VMs.
+Fixtures still synthesize provider data. This shared generation does not exercise
+provider collection or every poller merge/rebase.
+
+The fixture registry has no store. NewRegistryWithManualLinks supplies the links
+from the monitor adapter's current generation. Rebuilding a storeless registry
+carries explicit links and exclusions from its previous generation. It carries
+no previous resource data and cannot persist identity pins, canonical-ID
+successions or change records. A store-backed rebuild uses freshly loaded
+decisions when its store is readable and retains previous decisions when
+loading fails.
+
+Links are judged across all non-availability sources, so a chain sees every
+member before choosing its primary. Availability references to folded resources
+project onto that primary, whether expressed through source references or
+canonical IDs. An agent linked into a guest leaves the agent listing and the
+guest carries its facet. GetAllWithMetricsTargets captures metrics targets with
+the resources and indexes source mappings once for the view.
+
+The broadcast, /api/state, GetUnifiedReadStateOrSnapshot and
+UnifiedResourceSnapshot read this fixture view. Links reach it when the
+monitor's next rebuild loads them, as in live mode. The data view cache compares
+fixture freshness and each link's pair, primary and creation time. The structure
+view compares the fixture structure revision and the same link fields. Creation
+time matters because changing the oldest link in a chain can change its primary.
+Link changes rebuild both views without a fixture tick. No-link readers use the
+shared memoized snapshot. Linked readers build their monitor's own view when
+fixture data or links change. Concurrent cache misses can each build a view.
+
+Freshness is assigned in publication order. A view with identical fixture
+freshness and links retains its predecessor's value. Every different view gets
+a later value than all previous publications, including a slow build that
+finishes after a newer one. The resources API reuses its registry only while
+that published freshness is unchanged.
+
+The fixture factory supplies links but no exclusions. Presentation readers
+consult their monitor or store-backed registry exclusions, but cannot undo an
+automatic merge already made within the fixture graph. This existing limitation
+remains at the fixture input boundary.
+
+Proof in internal/mock/platform_fixtures_test.go:
+TestFixtureGraphMatchesMonitorSupplementalFreshness compares fresh and aged
+TrueNAS sightings with the live generation. TestFixtureGraphAppliesManualLinksAtTheRebuildsBoundary
+checks cross-source chains and availability projection.
+TestUnifiedResourceSnapshotWithLinksLeavesTheSharedSnapshotUnlinked checks
+memo isolation. TestMonitorAdapterKeepsInMemoryManualLinksAcrossGenerations in
+internal/unifiedresources/monitor_adapter_generation_test.go checks storeless
+rebuilds. TestMonitorGenerationAppliesManualLinksAcrossSources and
+TestMonitorGenerationJudgesLinkedReadingsWithConfiguredThresholds in
+internal/unifiedresources/registry_merge_policy_test.go exercise the canonical
+boundary. TestMockUnifiedViewAppliesOperatorManualLinks and
+TestMockUnifiedViewFollowsALinkCreationTimeChange in
+internal/monitoring/monitor_host_agents_test.go preserve broadcast, API, cache,
+creation-time and no-durable-history behavior.
### Provider link network corroboration
diff --git a/frontend-modern/browser-verification/9512e55df90febce.json b/frontend-modern/browser-verification/9512e55df90febce.json
new file mode 100644
index 0000000000..ac29843b7c
--- /dev/null
+++ b/frontend-modern/browser-verification/9512e55df90febce.json
@@ -0,0 +1,63 @@
+{
+ "version": 1,
+ "base_sha": "16072f4a869a8eb3f3c50ab366aa23acdd8bcfc5",
+ "verified_at": "2026-10-12T10:26:17Z",
+ "result": "passed",
+ "changed_paths": [
+ "frontend-modern/src/components/Workloads/workloadSelectors.ts",
+ "frontend-modern/src/hooks/useWorkloads.ts",
+ "frontend-modern/src/types/workloads.ts"
+ ],
+ "content_sha256": {
+ "frontend-modern/src/components/Workloads/workloadSelectors.ts": "4a3a704cdccff0afb43feaf0f0701d237a5124b17d5a49083301477254afe99d",
+ "frontend-modern/src/hooks/useWorkloads.ts": "5c51dd331558621ee0e43bd61912e3b2dabbf9c1015abba36d940be4a2898faf",
+ "frontend-modern/src/types/workloads.ts": "4ab896c526f1b270d04258288c4b6734e16269237599d279324f56c941d0e8ed"
+ },
+ "routes": [
+ "/proxmox/overview",
+ "/vmware/overview",
+ "/truenas/overview",
+ "/truenas/vms",
+ "/standalone/machines",
+ "/standalone/availability",
+ "/alerts/thresholds/proxmox"
+ ],
+ "viewports": [
+ {
+ "width": 1280,
+ "height": 800
+ },
+ {
+ "width": 390,
+ "height": 844
+ },
+ {
+ "width": 900,
+ "height": 800
+ }
+ ],
+ "states": [
+ "Loaded platform tables and initial loading states",
+ "vSphere drawer Overview and cold first History selection across fixture updates",
+ "TrueNAS VM and availability check expanded details",
+ "Empty TrueNAS search and cleared filter",
+ "Linked agent and VM across three fixture refreshes and reload",
+ "Unlinked agent restored under its original ID with a separate VM",
+ "History 12-hour range and pointer/keyboard chart inspection after page scrolling",
+ "Drawer reopened with default Overview and 24-hour range",
+ "Different canonical guest opens its own Overview",
+ "Desktop and narrow alert thresholds with inherited policy controls",
+ "Actual pixels, focus rings, table/toolbar wrapping and no page overflow"
+ ],
+ "interactions": [
+ "Log in with synthetic demo credentials",
+ "Expand drawers with Enter and pointer",
+ "Press Escape on inline details, then close with header control",
+ "Select History and retain selection through refreshes",
+ "Change History range from 24h to 12h",
+ "Scroll deep charts, click the inspection slider and press ArrowLeft",
+ "Close and reopen warehouse-api-01, then open warehouse-db-01",
+ "Type an empty search and clear it",
+ "Link and unlink through authenticated resource APIs, observe publication and reload linked view"
+ ]
+}
diff --git a/frontend-modern/src/components/Workloads/__tests__/workloadSelectors.test.ts b/frontend-modern/src/components/Workloads/__tests__/workloadSelectors.test.ts
index 04fe52228a..cf1c97a4b4 100644
--- a/frontend-modern/src/components/Workloads/__tests__/workloadSelectors.test.ts
+++ b/frontend-modern/src/components/Workloads/__tests__/workloadSelectors.test.ts
@@ -898,6 +898,41 @@ describe('workloadSelectors', () => {
});
describe('getWorkloadGroupKey', () => {
+ it('keeps vSphere parent groups stable while display metadata changes', () => {
+ const guest = makeGuest(1, {
+ workloadType: 'vm',
+ platformScopes: ['vmware-vsphere'],
+ parentResourceId: 'host-vcenter-a:esxi-01',
+ node: 'esxi-01',
+ instance: '',
+ });
+ const key = getWorkloadGroupKey(guest);
+ const enriched = {
+ ...guest,
+ node: 'esxi-01.lab',
+ instance: 'Production Cluster',
+ clusterName: 'Production Cluster',
+ };
+ expect(getWorkloadGroupKey(enriched)).toBe(key);
+ expect(getWorkloadGroupLabel(key, [enriched])).toEqual({
+ name: 'esxi-01.lab',
+ type: 'Production Cluster',
+ });
+ });
+
+ it('keeps equal vSphere labels on different canonical parents separate', () => {
+ const guest = makeGuest(1, {
+ workloadType: 'vm',
+ platformScopes: ['vmware-vsphere'],
+ parentResourceId: 'host-vcenter-a:esxi-01',
+ node: 'esxi-01',
+ instance: 'Production Cluster',
+ });
+ expect(
+ getWorkloadGroupKey({ ...guest, parentResourceId: 'host-vcenter-b:esxi-01' }),
+ ).not.toBe(getWorkloadGroupKey(guest));
+ });
+
it('uses instance-node for vm/lxc, and type:context for app-container/pod', () => {
const vm = makeGuest(1, {
type: 'vm',
diff --git a/frontend-modern/src/components/Workloads/workloadSelectors.ts b/frontend-modern/src/components/Workloads/workloadSelectors.ts
index ec5fa3fc21..ba3dc7a497 100644
--- a/frontend-modern/src/components/Workloads/workloadSelectors.ts
+++ b/frontend-modern/src/components/Workloads/workloadSelectors.ts
@@ -402,10 +402,16 @@ export const getWorkloadGroupKey = (guest: WorkloadGuest): string => {
const type = resolveWorkloadType(guest);
if (type === 'vm' || type === 'system-container') {
const scope = workloadNodeScopeId(guest);
- return guest.platformScopes?.includes('vmware-vsphere') &&
+ if (
+ guest.platformScopes?.includes('vmware-vsphere') &&
!guest.platformScopes.includes('proxmox-pve')
- ? `vsphere|${scope}`
- : scope;
+ ) {
+ // Cluster, connection and host labels can arrive after the first snapshot.
+ // Group ownership follows the server parent so enrichment keeps rows mounted.
+ const parentId = guest.parentResourceId?.trim();
+ return parentId ? `vsphere|parent|${encodeURIComponent(parentId)}` : `vsphere|${scope}`;
+ }
+ return scope;
}
const context = guest.contextLabel || guest.node || guest.instance || guest.namespace || guest.id;
return `${type}:${context}`;
diff --git a/frontend-modern/src/hooks/__tests__/useWorkloads.test.ts b/frontend-modern/src/hooks/__tests__/useWorkloads.test.ts
index 0a9d0c9f43..8f31eabe06 100644
--- a/frontend-modern/src/hooks/__tests__/useWorkloads.test.ts
+++ b/frontend-modern/src/hooks/__tests__/useWorkloads.test.ts
@@ -4,7 +4,7 @@ import useWorkloadsSource from '../useWorkloads.ts?raw';
import { guestDiskDeferrals } from '@/components/Workloads/__fixtures__/guestDiskDeferrals';
import type { VM } from '@/types/api';
import { getWorkloadGuestDiskRead } from '@/utils/workloadGuestPresentation';
-import { getDiskUsagePercent } from '@/components/Workloads/workloadSelectors';
+import { getDiskUsagePercent, getWorkloadGroupKey } from '@/components/Workloads/workloadSelectors';
type UseWorkloadsModule = typeof import('@/hooks/useWorkloads');
@@ -1480,6 +1480,52 @@ describe('useWorkloads', () => {
dispose();
});
+ it('retains canonical vSphere parent grouping through snapshot enrichment', async () => {
+ const resource = {
+ ...sampleResource,
+ id: 'vm-warehouse-api',
+ name: 'warehouse-api',
+ sources: ['vmware'],
+ parentId: 'host-vcenter-a:esxi-01',
+ parentName: 'esxi-01',
+ vmid: 0,
+ node: undefined,
+ instance: undefined,
+ proxmox: undefined,
+ };
+ const [snapshot, setSnapshot] = createSignal([resource] as any);
+ let dispose = () => {};
+ let result: ReturnType<UseWorkloadsModule['useWorkloads']> | undefined;
+ createRoot((d) => {
+ dispose = d;
+ result = useWorkloads(() => true, { resourceSnapshot: snapshot });
+ });
+ try {
+ await flushAsync();
+ const first = result!.workloads()[0]!;
+ expect(first.parentResourceId).toBe(resource.parentId);
+ expect(first.instance).toBe('');
+ const group = getWorkloadGroupKey(first);
+ setSnapshot([
+ {
+ ...resource,
+ vmware: {
+ runtimeHostName: 'esxi-01',
+ clusterName: 'Production Cluster',
+ connectionName: 'Lab vCenter',
+ },
+ },
+ ]);
+ await flushAsync();
+ const enriched = result!.workloads()[0]!;
+ expect(enriched.id).toBe(first.id);
+ expect(enriched.instance).toBe('Production Cluster');
+ expect(getWorkloadGroupKey(enriched)).toBe(group);
+ } finally {
+ dispose();
+ }
+ });
+
it('never labels a vSphere or standalone Proxmox workload as its own cluster', async () => {
apiFetchJSONMock.mockResolvedValueOnce({
data: [
diff --git a/frontend-modern/src/hooks/useWorkloads.ts b/frontend-modern/src/hooks/useWorkloads.ts
index f7574567af..13ab9ed8d4 100644
--- a/frontend-modern/src/hooks/useWorkloads.ts
+++ b/frontend-modern/src/hooks/useWorkloads.ts
@@ -16,10 +16,7 @@ import {
isDockerManagedAppContainer,
resolveWorkloadTypeFromString,
} from '@/utils/workloads';
-import {
- getPreferredResourceClusterName,
- getPreferredResourceKubernetesContext,
-} from '@/utils/resourceIdentity';
+import { getPreferredResourceKubernetesContext } from '@/utils/resourceIdentity';
import { getExplicitResourceClusterName } from '@/utils/agentResources';
import type { WorkloadGuest } from '@/types/workloads';
import type { HostRAIDArray } from '@/types/api';
@@ -449,7 +446,6 @@ const mapResourceToWorkload = (resource: APIResource): WorkloadGuest | null => {
resource.parentName ??
'';
const kubernetesContext = getPreferredResourceKubernetesContext(resource);
- const preferredClusterName = getPreferredResourceClusterName(resource);
// The preferred helper falls back to the resource's own name, which is the
// right label for a cluster resource but not for a workload: a vSphere VM
// or a standalone Proxmox guest would otherwise be labelled as its own
@@ -463,7 +459,7 @@ const mapResourceToWorkload = (resource: APIResource): WorkloadGuest | null => {
resource.instance ??
resource.proxmox?.instance ??
kubernetesContext ??
- preferredClusterName ??
+ workloadClusterName ??
'';
const vmid =
typeof resource.vmid === 'number'
@@ -546,6 +542,7 @@ const mapResourceToWorkload = (resource: APIResource): WorkloadGuest | null => {
return {
id: guestId,
canonicalResourceId: resource.id,
+ parentResourceId: resource.parentId?.trim() || undefined,
alertResourceIds: buildAlertResourceIds(resource),
metricsTarget: resource.metricsTarget,
vmid: Number.isFinite(vmid) ? vmid : 0,
diff --git a/frontend-modern/src/types/workloads.ts b/frontend-modern/src/types/workloads.ts
index a5bd6c893c..adc5fcc45d 100644
--- a/frontend-modern/src/types/workloads.ts
+++ b/frontend-modern/src/types/workloads.ts
@@ -25,6 +25,8 @@ export type WorkloadGuest = (VM | Container) & {
alertResourceIds?: string[];
/** Exact unified-resource ID; a Proxmox row ID can be a different VMID-based display key. */
canonicalResourceId?: string;
+ /** Exact unified parent identity, independent of provider display labels. */
+ parentResourceId?: string;
/** Backend-owned coordinates for metrics history; distinct from the stable workload row id. */
metricsTarget?: ResourceMetricsTarget;
/** Canonical unified-resource health, kept separate from runtime power state in `status`. */
diff --git a/internal/mock/platform_fixtures.go b/internal/mock/platform_fixtures.go
index 240222852c..b24e3b8f63 100644
--- a/internal/mock/platform_fixtures.go
+++ b/internal/mock/platform_fixtures.go
@@ -215,26 +215,15 @@ func (g FixtureGraph) UnifiedResourceSnapshot() ([]unifiedresources.Resource, ti
}
func (g FixtureGraph) unifiedResourceSnapshot(registry *unifiedresources.ResourceRegistry) ([]unifiedresources.Resource, time.Time) {
- // The links apply at the monitor rebuild's boundary
- // (MonitorAdapter.replaceRegistryLocked): after the snapshot and every
- // source but availability, so a chain is judged over the assembled estate
- // instead of folded as its members' sources arrive, and before
- // availability, so a check linked to a folded resource projects onto its
- // primary.
- registry.DeferManualLinks()
- registry.IngestSnapshot(unifiedresources.SnapshotWithoutSources(g.State, SupplementalOwnedSources()))
-
- for _, source := range SupplementalOwnedSources() {
- if source == unifiedresources.SourceAvailability {
- registry.ApplyDeferredManualLinks(nil)
- }
- records := g.SupplementalRecords(source)
- if len(records) == 0 {
- continue
- }
- registry.IngestRecords(source, records)
+ // The demo uses the live generation builder for source ordering, operator
+ // links, availability projection and the final freshness verdict.
+ owned := SupplementalOwnedSources()
+ records := make(map[unifiedresources.DataSource][]unifiedresources.IngestRecord, len(owned))
+ for _, source := range owned {
+ records[source] = g.SupplementalRecords(source)
}
- registry.ApplyDeferredManualLinks(nil)
+ adapter := unifiedresources.NewMonitorAdapter(registry)
+ adapter.PopulateSnapshotAndSupplemental(unifiedresources.SnapshotWithoutSources(g.State, owned), records)
freshness := g.State.LastUpdate
for _, candidate := range []time.Time{
@@ -250,15 +239,10 @@ func (g FixtureGraph) unifiedResourceSnapshot(registry *unifiedresources.Resourc
}
}
- resources := registry.List()
- // Force one view-cache build before resolving targets: on a freshly
- // ingested registry the caches are dirty and every MetricsTarget call
- // would fall back to a scan over all source mappings, which at demo
- // scale turns this loop quadratic.
- registry.VMs()
+ resources, targets := adapter.GetAllWithMetricsTargets()
for i := range resources {
- if target := registry.MetricsTarget(resources[i].ID); target != nil {
- resources[i].MetricsTarget = target
+ if target, ok := targets[resources[i].ID]; ok {
+ resources[i].MetricsTarget = &target
}
}
diff --git a/internal/mock/platform_fixtures_test.go b/internal/mock/platform_fixtures_test.go
index 5c49e4f015..33bb5e9067 100644
--- a/internal/mock/platform_fixtures_test.go
+++ b/internal/mock/platform_fixtures_test.go
@@ -1399,3 +1399,45 @@ func countCalls(fn *ast.FuncDecl, receiver, method string) int {
})
return count
}
+
+func TestFixtureGraphMatchesMonitorSupplementalFreshness(t *testing.T) {
+ now := time.Now().UTC()
+ for _, age := range []time.Duration{0, 2 * time.Hour} {
+ t.Run(age.String(), func(t *testing.T) {
+ graph := buildFixtureGraph(DefaultConfig, now.Add(-age))
+ owned := SupplementalOwnedSources()
+ records := make(map[unifiedresources.DataSource][]unifiedresources.IngestRecord, len(owned))
+ for _, source := range owned {
+ records[source] = graph.SupplementalRecords(source)
+ }
+ adapter := unifiedresources.NewMonitorAdapter(unifiedresources.NewRegistry(nil))
+ adapter.PopulateSnapshotAndSupplemental(unifiedresources.SnapshotWithoutSources(graph.State, owned), records)
+ demo, _ := graph.UnifiedResourceSnapshot()
+ byID := make(map[string]unifiedresources.Resource, len(demo))
+ for _, resource := range demo {
+ byID[resource.ID] = resource
+ }
+ checked := 0
+ for _, live := range adapter.GetAll() {
+ if live.Type != unifiedresources.ResourceTypeVM || len(live.Sources) != 1 || live.Sources[0] != unifiedresources.SourceTrueNAS {
+ continue
+ }
+ checked++
+ wantStatus := "online"
+ if age > 0 {
+ wantStatus = "stale"
+ }
+ if live.SourceStatus[unifiedresources.SourceTrueNAS].Status != wantStatus {
+ t.Fatalf("live reference has no %s TrueNAS sighting: %+v", wantStatus, live)
+ }
+ got, ok := byID[live.ID]
+ if !ok || got.Status != live.Status || got.SourceStatus[unifiedresources.SourceTrueNAS].Status != wantStatus {
+ t.Fatalf("demo freshness differs from live for %s: demo=%+v live=%+v", live.ID, got, live)
+ }
+ }
+ if checked == 0 {
+ t.Fatal("fixture has no TrueNAS-only VM to compare")
+ }
+ })
+ }
+}
diff --git a/internal/unifiedresources/manual_links.go b/internal/unifiedresources/manual_links.go
index 00a06e678c..71432824d4 100644
--- a/internal/unifiedresources/manual_links.go
+++ b/internal/unifiedresources/manual_links.go
@@ -1,55 +1,17 @@
package unifiedresources
-import (
- "slices"
- "time"
-)
+import "slices"
-// NewRegistryWithManualLinks creates a registry that applies the given
-// operator links on every ingest but has no store behind it. Read views built
-// from data that never passed through the durable registry, such as the mock
-// fixture graph, use it to show the operator's links the way the store-backed
-// registry does, while nothing they ingest can persist identity pins,
-// canonical-ID successions or change records. It carries no exclusions, so
-// its identity matching and ListForPresentation see none. A builder that
-// ingests the snapshot and several record sources in turn calls
-// DeferManualLinks first, so the links are judged once over the whole estate
-// as the monitor's rebuild does.
+// NewRegistryWithManualLinks creates a storeless registry with explicit
+// operator links. MonitorAdapter builds each generation using the same link,
+// source-order and freshness boundary as the live monitor. No identity pins,
+// canonical-ID successions or change records are persisted.
func NewRegistryWithManualLinks(links []ResourceLink) *ResourceRegistry {
rr := NewRegistry(nil)
rr.links = slices.Clone(links)
return rr
}
-// DeferManualLinks holds the link pass back from this registry's snapshot and
-// record ingests until ApplyDeferredManualLinks, the boundary the monitor's
-// rebuild draws (MonitorAdapter.replaceRegistryLocked): a chain of links is
-// judged over every member's source at once, because a fold cannot be undone
-// when a later source brings a member that outranks the earlier choice. The
-// caller ingests availability checks after ApplyDeferredManualLinks, so a
-// check linked to a folded resource projects onto its primary. A registry with
-// no links has no pass to hold back and ingests as it always did.
-func (rr *ResourceRegistry) DeferManualLinks() {
- rr.mu.Lock()
- defer rr.mu.Unlock()
- if len(rr.links) == 0 {
- return
- }
- rr.deferManualLinks = true
-}
-
-// ApplyDeferredManualLinks runs the link pass DeferManualLinks held back, then
-// refreshes what folding changes. Freshness is judged by thresholds, which the
-// caller passes as it passed them to the ingests (nil takes the registry's own,
-// as IngestSnapshot and IngestRecords do): a source whose reading is stale
-// under one set can be current under the other, and the merge keeps the
-// current one. It does nothing once the pass has run, or on a registry that
-// was not deferring, so a builder may call it at every boundary without
-// tracking whether the pass already ran.
-func (rr *ResourceRegistry) ApplyDeferredManualLinks(thresholds map[DataSource]time.Duration) {
- rr.applyDeferredManualLinks(rr.thresholdsOrOwn(thresholds))
-}
-
// ManualLinks returns the operator's manual links that the adapter's current
// registry generation applied, as loaded from its store when that generation
// was built. A link added to the store since then appears after the next
diff --git a/internal/unifiedresources/monitor_adapter_generation_test.go b/internal/unifiedresources/monitor_adapter_generation_test.go
index 06eeca18d4..14a00dda1b 100644
--- a/internal/unifiedresources/monitor_adapter_generation_test.go
+++ b/internal/unifiedresources/monitor_adapter_generation_test.go
@@ -113,3 +113,35 @@ func TestMonitorAdapterSerializesSupplementalMutationAfterSnapshotPublication(t
t.Fatalf("final generation lost a writer: %+v", resources)
}
}
+
+func TestMonitorAdapterKeepsInMemoryManualLinksAcrossGenerations(t *testing.T) {
+ now := time.Now().UTC()
+ snapshot := models.StateSnapshot{
+ Hosts: []models.Host{
+ {ID: "host-app", Hostname: "app-guest", MachineID: "machine-app", Status: "online", LastSeen: now},
+ {ID: "host-nas", Hostname: "nas-a-mgmt", MachineID: "machine-nas", Status: "online", LastSeen: now},
+ },
+ LastUpdate: now,
+ }
+ baseline := NewRegistry(nil)
+ baseline.IngestSnapshot(snapshot)
+ listed := baseline.List()
+ if len(listed) != 2 {
+ t.Fatalf("fixture hosts did not stay separate: %+v", listed)
+ }
+ link := ResourceLink{ResourceA: listed[0].ID, ResourceB: listed[1].ID, PrimaryID: listed[0].ID}
+ adapter := NewMonitorAdapter(NewRegistryWithManualLinks([]ResourceLink{link}))
+ for generation := 0; generation < 3; generation++ {
+ adapter.PopulateFromSnapshot(snapshot)
+ got := adapter.GetAll()
+ if len(got) != 1 || got[0].ID != link.PrimaryID {
+ t.Fatalf("generation %d lost the in-memory operator link: %+v", generation, got)
+ }
+ if links := adapter.ManualLinks(); len(links) != 1 || links[0] != link {
+ t.Fatalf("generation %d changed the operator's link: %+v", generation, links)
+ }
+ if adapter.currentRegistry().store != nil {
+ t.Fatal("a storeless generation acquired persistence")
+ }
+ }
+}
diff --git a/internal/unifiedresources/registry.go b/internal/unifiedresources/registry.go
index 85d8bd85f1..c9f6b6b59c 100644
--- a/internal/unifiedresources/registry.go
+++ b/internal/unifiedresources/registry.go
@@ -307,8 +307,10 @@ func (rr *ResourceRegistry) loadOverrides() {
}
}
-// carryOverridesFrom keeps the operator's decisions across a rebuild that
-// could not read them. A registry whose store read for links or exclusions
+// carryOverridesFrom keeps in-memory operator decisions across a rebuild,
+// or stored decisions when the store could not be read. A registry without
+// a store carries the previous generation's explicit links and exclusions.
+// A registry whose store read for links or exclusions
// failed lacks what that read held; with both lost it lists every pair the
// operator split as one machine again, drops every manual link and answers
// the monitor's node<->agent split decider (ProxmoxNodeAgentSplit)
@@ -320,7 +322,7 @@ func (rr *ResourceRegistry) loadOverrides() {
// stale resource data is worse than stale decisions. A registry whose reads
// succeeded keeps what it read.
func (rr *ResourceRegistry) carryOverridesFrom(previous *ResourceRegistry) {
- if previous == nil || previous == rr || !rr.overridesUnreadable {
+ if previous == nil || previous == rr || (rr.store != nil && !rr.overridesUnreadable) {
return
}
previous.mu.RLock()
diff --git a/internal/unifiedresources/registry_merge_policy_test.go b/internal/unifiedresources/registry_merge_policy_test.go
index 7eae5da870..99630832b4 100644
--- a/internal/unifiedresources/registry_merge_policy_test.go
+++ b/internal/unifiedresources/registry_merge_policy_test.go
@@ -4580,13 +4580,9 @@ func linkedDiskRowsOn(t *testing.T, resources []Resource) linkedDiskRows {
return rows
}
-// TestRegistryHoldsManualLinksBackUntilTheDeferredPass pins the exported
-// boundary a builder outside the monitor draws (the mock fixture build): once
-// DeferManualLinks is called the snapshot and record ingests leave every
-// member standing, ApplyDeferredManualLinks folds them in one pass, and a
-// second call changes nothing. A registry with no links has no pass to hold
-// back, so the call leaves it ingesting as before.
-func TestRegistryHoldsManualLinksBackUntilTheDeferredPass(t *testing.T) {
+// TestMonitorGenerationAppliesManualLinksAcrossSources exercises the single
+// generation boundary with links spanning snapshot and supplemental sources.
+func TestMonitorGenerationAppliesManualLinksAcrossSources(t *testing.T) {
now := time.Now().UTC()
nas := IngestRecord{
SourceID: "system:tn-1:vm:nas-vm",
@@ -4602,91 +4598,51 @@ func TestRegistryHoldsManualLinksBackUntilTheDeferredPass(t *testing.T) {
}
snapshot := models.StateSnapshot{
LastUpdate: now,
- VMs: []models.VM{
- {ID: "lab:pve1:101", VMID: 101, Name: "web", Node: "pve1", Instance: "lab", Status: "running", Type: "qemu", LastSeen: now},
- },
- Hosts: []models.Host{
- {ID: "host-app", Hostname: "app-agent", MachineID: "0123456789abcdef", Status: "online", LastSeen: now},
- },
- }
- // The snapshot brings a Proxmox VM and an agent, the records bring a
- // TrueNAS VM and a vSphere VM; one link joins each pair.
- ingest := func(rr *ResourceRegistry, afterSnapshot func()) {
- rr.IngestSnapshot(snapshot)
- if afterSnapshot != nil {
- afterSnapshot()
- }
- rr.IngestRecords(SourceTrueNAS, []IngestRecord{nas})
- rr.IngestRecords(SourceVMware, []IngestRecord{guest})
+ VMs: []models.VM{{ID: "lab:pve1:101", VMID: 101, Name: "web", Node: "pve1", Instance: "lab", Status: "running", Type: "qemu", LastSeen: now}},
+ Hosts: []models.Host{{ID: "host-app", Hostname: "app-agent", MachineID: "0123456789abcdef", Status: "online", LastSeen: now}},
}
-
- unlinked := NewRegistry(nil)
- ingest(unlinked, nil)
+ records := map[DataSource][]IngestRecord{SourceTrueNAS: {nas}, SourceVMware: {guest}}
+ unlinked := NewMonitorAdapter(NewRegistry(nil))
+ unlinked.PopulateSnapshotAndSupplemental(snapshot, records)
ids := map[string]string{}
- for _, resource := range unlinked.List() {
+ for _, resource := range unlinked.GetAll() {
ids[resource.Name] = resource.ID
}
if len(ids) != 4 || ids["web"] == "" || ids["app-agent"] == "" || ids["nas-vm"] == "" || ids["app-guest"] == "" {
- t.Fatalf("unlinked estate = %v, want the VM, the agent, the TrueNAS VM and the vSphere VM", ids)
+ t.Fatalf("unlinked estate = %v, want four distinct fixture resources", ids)
}
links := []ResourceLink{
{ResourceA: ids["app-agent"], ResourceB: ids["web"], PrimaryID: ids["web"]},
{ResourceA: ids["nas-vm"], ResourceB: ids["app-guest"], PrimaryID: ids["app-guest"]},
}
- wantAfter := []string{ids["app-guest"], ids["web"]}
- slices.Sort(wantAfter)
- listed := func(rr *ResourceRegistry) []string {
- got := resourceIDs(rr.List())
+ want := []string{ids["app-guest"], ids["web"]}
+ slices.Sort(want)
+ adapter := NewMonitorAdapter(NewRegistryWithManualLinks(links))
+ for generation := 0; generation < 2; generation++ {
+ adapter.PopulateSnapshotAndSupplemental(snapshot, records)
+ resources := adapter.GetAll()
+ got := resourceIDs(resources)
slices.Sort(got)
- return got
- }
-
- eager := NewRegistryWithManualLinks(links)
- ingest(eager, nil)
- if got := listed(eager); !slices.Equal(got, wantAfter) {
- t.Fatalf("a registry that was not deferred listed %v, want %v", got, wantAfter)
- }
-
- deferred := NewRegistryWithManualLinks(links)
- deferred.DeferManualLinks()
- ingest(deferred, func() {
- // The link between the snapshot's own members waits too.
- if got := listed(deferred); len(got) != 2 {
- t.Fatalf("a deferred registry listed %v after the snapshot, want both snapshot members standing", got)
+ if !slices.Equal(got, want) {
+ t.Fatalf("generation %d lists %v, want the linked survivors %v", generation, got, want)
}
- })
- if got := listed(deferred); len(got) != 4 {
- t.Fatalf("a deferred registry listed %v before the pass, want every member standing", got)
- }
- deferred.ApplyDeferredManualLinks(nil)
- if got := listed(deferred); !slices.Equal(got, wantAfter) {
- t.Fatalf("a deferred registry listed %v after the pass, want %v", got, wantAfter)
- }
- folded, _ := deferred.Get(ids["app-guest"])
- for _, source := range []DataSource{SourceTrueNAS, SourceVMware} {
- if !slices.Contains(folded.Sources, source) {
- t.Fatalf("folded row sources = %v, want %s among them", folded.Sources, source)
+ for _, resource := range resources {
+ if resource.ID != ids["app-guest"] {
+ continue
+ }
+ for _, source := range []DataSource{SourceTrueNAS, SourceVMware} {
+ if !slices.Contains(resource.Sources, source) {
+ t.Fatalf("folded row sources = %v, want %s among them", resource.Sources, source)
+ }
+ }
}
}
- deferred.ApplyDeferredManualLinks(nil)
- if got := listed(deferred); !slices.Equal(got, wantAfter) {
- t.Fatalf("a second deferred pass listed %v, want the same rows %v", got, wantAfter)
- }
-
- plain := NewRegistry(nil)
- plain.DeferManualLinks()
- if plain.deferManualLinks {
- t.Fatal("a registry with no links holds a pass back that has nothing to fold")
- }
- plain.ApplyDeferredManualLinks(nil)
}
-// TestRegistryDeferredLinkPassJudgesFreshnessByTheCallersThresholds pins the
-// thresholds ApplyDeferredManualLinks takes: a vSphere disk reading three
-// minutes old is current under the five minutes the ingests were given, so the
-// guest keeps it over the agent's, and stale under the two-minute default,
-// where the fresh agent's reading replaces it.
-func TestRegistryDeferredLinkPassJudgesFreshnessByTheCallersThresholds(t *testing.T) {
+// TestMonitorGenerationJudgesLinkedReadingsWithConfiguredThresholds checks
+// the caller's freshness policy at the generation boundary: the three-minute
+// vSphere reading is current with five-minute thresholds and stale by default.
+func TestMonitorGenerationJudgesLinkedReadingsWithConfiguredThresholds(t *testing.T) {
now := time.Now().UTC()
total, used := int64(8<<30), int64(3<<30)
guest := IngestRecord{
@@ -4725,21 +4681,19 @@ func TestRegistryDeferredLinkPassJudgesFreshnessByTheCallersThresholds(t *testin
}
links := []ResourceLink{{ResourceA: ids["app-agent"], ResourceB: ids["app-guest"], PrimaryID: ids["app-guest"]}}
- diskSource := func(applyWith map[DataSource]time.Duration) DataSource {
- rr := NewRegistryWithManualLinks(links)
- rr.DeferManualLinks()
- ingest(rr)
- rr.ApplyDeferredManualLinks(applyWith)
- row, ok := rr.Get(ids["app-guest"])
+ diskSource := func(configured map[DataSource]time.Duration) DataSource {
+ adapter := NewMonitorAdapterWithStaleThresholds(NewRegistryWithManualLinks(links), configured)
+ adapter.PopulateSnapshotAndSupplemental(snapshot, map[DataSource][]IngestRecord{SourceVMware: {guest}})
+ row, ok := adapter.currentRegistry().Get(ids["app-guest"])
if !ok || row.Metrics == nil || row.Metrics.Disk == nil {
t.Fatalf("merged guest = %+v, want it listed with a disk reading", row)
}
return row.Metrics.Disk.Source
}
if got := diskSource(thresholds); got != SourceVMware {
- t.Fatalf("deferred pass with the ingests' thresholds took the disk reading from %q, want the current vSphere one", got)
+ t.Fatalf("generation with configured thresholds took the disk reading from %q, want the current vSphere one", got)
}
if got := diskSource(nil); got != SourceAgent {
- t.Fatalf("deferred pass with default thresholds took the disk reading from %q, want the fresh agent's (this scenario no longer separates the thresholds)", got)
+ t.Fatalf("generation with default thresholds took the disk reading from %q, want the fresh agent's (this scenario no longer separates the thresholds)", got)
}
}