Centralize state adapter cluster labels

This commit is contained in:
rcourtman
2026-03-19 20:17:19 +00:00
parent 6ad3f70b3a
commit 393726eea6
4 changed files with 24 additions and 1 deletions
@@ -144,6 +144,10 @@ share the canonical cluster-name helpers in the shared agent-resource layer,
so route labels, pod grouping, and cluster-name fetch keys keep using the
same source of truth instead of rebuilding the `clusterName`/`context`/
`clusterId` prefix locally.
The shared node adapter also uses that same cluster-name helper for the
infrastructure summary surface, so Proxmox node projections stay aligned with
the same canonical cluster label instead of carrying a raw adapter-local
cluster string.
The drawer's Kubernetes namespace/deployment tabs use the canonical
cluster-name helper for fetch keys, so the visible navigation label stays
separate from the backend cluster lookup contract.
@@ -176,6 +176,10 @@ The same shared agent-resource module now also owns the canonical cluster-name
helpers, so Kubernetes context prefixes, Proxmox cluster labels, and
cluster-name fetch keys stay aligned instead of each surface rebuilding its
own pod, namespace, and VM routing fallbacks.
The shared node-state adapter also routes Proxmox cluster labels through that
same helper, so infrastructure summary projections keep the same canonical
cluster name as the rest of the unified resource model instead of rewriting
the label locally.
The canonical unified-resource change and relationship presenters now also
share the same elapsed-time and "ago" wording utilities, so `observed`,
`last seen`, and `ago` fragments stay consistent without each formatter
@@ -88,6 +88,20 @@ describe('resourceStateAdapters nodeFromResource', () => {
expect(node?.displayName).toBe('Tower');
expect(node?.host).toBe('tower.local');
expect(node?.instance).toBe('pve-canonical');
expect(node?.clusterName).toBeUndefined();
});
it('projects the canonical cluster name through the shared helper', () => {
const node = nodeFromResource(
createNodeResource({
proxmox: {
nodeName: 'pve-node-1',
clusterName: 'cluster-a',
},
}),
);
expect(node?.clusterName).toBe('cluster-a');
});
it('maps PBS display and host identity through shared resource helpers', () => {
@@ -23,6 +23,7 @@ import type {
import type { Resource } from '@/types/resource';
import { getActionableAgentIdFromResource } from '@/utils/agentResources';
import {
getPreferredResourceClusterName,
getPreferredResourceDisplayName,
getPreferredResourceHostname,
} from '@/utils/resourceIdentity';
@@ -232,7 +233,7 @@ export const nodeFromResource = (resource: Resource): Node | null => {
lastSeen: toISOTime(undefined, resource.lastSeen),
connectionHealth: asString(proxmox?.connectionHealth) || resource.status || 'unknown',
isClusterMember: asBoolean(proxmox?.isClusterMember),
clusterName: asString(proxmox?.clusterName),
clusterName: getPreferredResourceClusterName(resource),
linkedAgentId,
};
};