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.

Centralize Kubernetes discovery mapping

rcourtman9888b1271def
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 4593493efb..429c29035b 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -145,6 +145,9 @@ separate from the backend cluster lookup contract.
The workloads projection in `useWorkloads` also uses that same helper for pod
context labels, keeping the dashboard's Kubernetes grouping aligned with the
same canonical cluster-name boundary.
+The drawer's discovery mapper also reuses that helper for pod fallback agent
+IDs, so the resource-detail hot path and the dashboard selector path stay
+aligned on the same cluster-name source of truth.
The aggregate `/api/charts/workloads-summary` endpoint now also has its own
explicit API p95 budget constant, aligned with the per-workload charts budget,
and `internal/api/slo_bench_test.go` must fail if that aggregate budget or its
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 1485dc4f52..3fdc736869 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -293,6 +293,9 @@ separate from the governed display-label contract.
The shared workloads projection in `useWorkloads` also uses that helper for
pod context labels, so dashboard Kubernetes grouping follows the same
canonical cluster-name contract instead of re-encoding the fallback locally.
+The drawer's discovery mapper also reuses that helper for pod fallback agent
+IDs, so the resource-detail path and the dashboard path stay aligned on the
+same cluster-name source of truth.
That same contract also owns the canonical resource display-name fallback, so
name-or-ID presentation stays consistent between the unified AI adapter, the
AI resource context, and the shared resource selectors instead of being
diff --git a/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx b/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx
index df378ce189..0712ef138b 100644
--- a/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx
+++ b/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx
@@ -9,6 +9,7 @@ import {
createWorkloadSortComparator,
groupWorkloads,
computeWorkloadStats,
+ getKubernetesContextKey,
} from '../workloadSelectors';
import { filterResources } from '@/components/Infrastructure/infrastructureSelectors';
import { getCanonicalWorkloadId, normalizeWorkloadViewModeParam } from '@/utils/workloads';
@@ -455,6 +456,41 @@ describe('Dashboard performance contract', () => {
expect(result).toHaveLength(PROFILES.S);
});
+ it('keeps pod context selection aligned with the projected canonical cluster label', () => {
+ const guests = [
+ makeGuest(1, {
+ id: 'pod-a',
+ type: 'pod',
+ workloadType: 'pod',
+ contextLabel: 'cluster-a',
+ instance: 'cluster-b',
+ node: 'worker-a',
+ }),
+ makeGuest(2, {
+ id: 'pod-b',
+ type: 'pod',
+ workloadType: 'pod',
+ contextLabel: 'cluster-b',
+ instance: 'cluster-a',
+ node: 'worker-b',
+ }),
+ ];
+
+ expect(getKubernetesContextKey(guests[0] as any)).toBe('cluster-a');
+
+ const result = filterWorkloads({
+ guests: guests as any,
+ viewMode: 'pod',
+ statusMode: 'all',
+ searchTerm: '',
+ selectedNode: null,
+ selectedHostHint: null,
+ selectedKubernetesContext: 'cluster-a',
+ });
+
+ expect(result.map((guest) => guest.id)).toEqual(['pod-a']);
+ });
+
it('filterWorkloads correctly filters by viewMode', () => {
const guests = makeGuests(PROFILES.S);
const vmCount = guests.filter((g) => g.type === 'vm').length;
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/resourceDetailMappers.test.ts b/frontend-modern/src/components/Infrastructure/__tests__/resourceDetailMappers.test.ts
index 0d49eff452..8499d9b816 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/resourceDetailMappers.test.ts
+++ b/frontend-modern/src/components/Infrastructure/__tests__/resourceDetailMappers.test.ts
@@ -132,5 +132,28 @@ describe('resourceDetailMappers', () => {
expect(config?.hostname).toBe('tower.canonical');
});
+
+ it('uses the shared Kubernetes cluster helper for pod fallback agent ids', () => {
+ const config = toDiscoveryConfig({
+ ...createHybridHostResource(),
+ id: 'resource:pod:hash-2',
+ type: 'pod',
+ platformType: 'kubernetes',
+ kubernetes: {
+ context: 'cluster-context',
+ podUid: 'pod-uid-2',
+ namespace: 'default',
+ },
+ platformData: {
+ kubernetes: {
+ context: 'cluster-context',
+ namespace: 'default',
+ },
+ },
+ } as unknown as Resource);
+
+ expect(config?.agentId).toBe('cluster-context');
+ expect(config?.resourceId).toBe('pod-uid-2');
+ });
});
});
diff --git a/frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts b/frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts
index ff68a8543a..3f6eb61fd4 100644
--- a/frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts
+++ b/frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts
@@ -21,6 +21,7 @@ import {
} from '@/utils/agentResources';
import {
getPreferredResourceDisplayName,
+ getPreferredResourceClusterName,
getPreferredResourceHostname,
} from '@/utils/resourceIdentity';
import { titleCaseDelimitedLabel } from '@/utils/textPresentation';
@@ -265,13 +266,7 @@ export const toDiscoveryConfig = (resource: Resource): DiscoveryConfig | null =>
asString(resource.kubernetes?.agentId) ||
asString(kubernetesPlatformData?.agentId) ||
actionableKubernetesId ||
- asString(resource.kubernetes?.clusterId) ||
- asString(kubernetesPlatformData?.clusterId) ||
- asString(resource.clusterId) ||
- asString(resource.kubernetes?.context) ||
- asString(kubernetesPlatformData?.context) ||
- asString(resource.kubernetes?.clusterName) ||
- asString(kubernetesPlatformData?.clusterName);
+ getPreferredResourceClusterName(resource);
const kubernetesResourceId =
asString(resource.kubernetes?.podUid) ||
asString(kubernetesPlatformData?.podUid) ||