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.

Surface host-agent identity collapse from cloned machine-ids

[email protected]13371a6b6c53
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md
index 4e92d10855..44d4685e54 100644
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@ -156,6 +156,22 @@ downstream surfaces can warn, and it must clear on its own once only one
machine keeps reporting for the window. Monitoring must not auto-split the
collapsed identity: the machine ID is the identity key, and the remedy
(regenerating the clone's machine-id) belongs to the operator.
+Host-agent identity collapse follows the same doctrine. Host report ingest
+keys agent identity on the machine-derived agent ID, so template deployments
+that still share `/etc/machine-id` fold two physical machines into one
+`models.Host` whose reports alternately overwrite each other (hostname, report
+IP, and interfaces flapping between sites), which also poisons node-agent
+linking. Ingest must watch each resolved host identity for identity-field
+revisits: a reported hostname or report IP that switches away and returns to a
+value already observed inside the monitoring-owned flap window proves two
+machines share the identity, while a one-time hostname rename never revisits
+and must not be flagged. The report IP is tracked alongside the hostname
+because template fleets often reuse hostnames across sites, leaving the
+address as the only field that betrays the clone. An active conflict is
+published as `models.Host.IdentityConflict` carrying the flapping values so
+downstream surfaces can warn, and it must clear on its own once only one
+machine keeps reporting for the window. Monitoring must not auto-split the
+collapsed identity here either; the remedy belongs to the operator.
Unified Agent module projection is report-authored and additive. When one
agent sends host and Docker reports for the same machine identity, monitoring
must refresh one canonical machine carrying both facets so the Hosts and
diff --git a/frontend-modern/src/features/standalone/HostIdentityConflictNotice.tsx b/frontend-modern/src/features/standalone/HostIdentityConflictNotice.tsx
new file mode 100644
index 0000000000..20da40c3ad
--- /dev/null
+++ b/frontend-modern/src/features/standalone/HostIdentityConflictNotice.tsx
@@ -0,0 +1,63 @@
+import { Show, createMemo } from 'solid-js';
+import { AlertTriangle } from 'lucide-solid';
+import { InlineNotice } from '@/components/shared/InlineNotice';
+import type { HostIdentityConflictHost } from './hostIdentityConflict';
+
+type HostIdentityConflictNoticeProps = {
+ hosts: HostIdentityConflictHost[];
+};
+
+// The flapping evidence: distinct hostnames when the clones are named apart,
+// otherwise the alternating report IPs (template deployments often reuse
+// hostnames too, e.g. pve01 at two different sites).
+const conflictDetail = (host: HostIdentityConflictHost): string => {
+ if (host.hostnames.length > 1) return host.hostnames.join(', ');
+ if (host.reportIps.length > 1) return host.reportIps.join(', ');
+ return '';
+};
+
+const hostLabel = (host: HostIdentityConflictHost): string => {
+ const detail = conflictDetail(host);
+ return detail ? `${host.name} (${detail})` : host.name;
+};
+
+// Warns when the server detects reports from two different machines being
+// folded into one host agent record, usually template-deployed machines that
+// still share the same /etc/machine-id. Unlike the outdated-agent notice this
+// is not gated on presentation policy, because it flags that the data on this
+// page is unreliable, which matters to read-only viewers too.
+export function HostIdentityConflictNotice(props: HostIdentityConflictNoticeProps) {
+ const count = createMemo(() => props.hosts.length);
+
+ const message = createMemo(() => {
+ if (count() === 1) {
+ const host = props.hosts[0];
+ const detail = conflictDetail(host);
+ const names = detail ? ` (${detail})` : '';
+ return (
+ `Two machines appear to share the identity of ${host.name}${names}. ` +
+ `They are likely cloned from the same template with the same /etc/machine-id, so Pulse sees them as one host and their reports overwrite each other. ` +
+ `Give one of them a fresh machine-id and restart its agent to monitor them separately.`
+ );
+ }
+ const labels = props.hosts.map(hostLabel).join('; ');
+ return (
+ `${count()} hosts are each receiving reports from more than one machine. ` +
+ `They are likely cloned from the same template with the same /etc/machine-id, so their reports overwrite each other. ` +
+ `Give the clones fresh machine-ids and restart their agents to monitor them separately. Affected hosts are ${labels}.`
+ );
+ });
+
+ return (
+ <Show when={count() > 0}>
+ <InlineNotice
+ role="status"
+ data-testid="host-identity-conflict-notice"
+ tone="warning"
+ icon={<AlertTriangle aria-hidden="true" />}
+ >
+ {message()}
+ </InlineNotice>
+ </Show>
+ );
+}
diff --git a/frontend-modern/src/features/standalone/StandalonePageSurface.tsx b/frontend-modern/src/features/standalone/StandalonePageSurface.tsx
index 124d8c28d8..d02e62ddc4 100644
--- a/frontend-modern/src/features/standalone/StandalonePageSurface.tsx
+++ b/frontend-modern/src/features/standalone/StandalonePageSurface.tsx
@@ -31,6 +31,8 @@ import { formatRelativeTime } from '@/utils/format';
import { buildProbeAgentOptions } from '@/utils/availabilityProbeAgents';
import { AvailabilityChecksTable } from './AvailabilityChecksTable';
import { AgentsMachinesTable } from './AgentsMachinesTable';
+import { collectHostIdentityConflictHosts } from './hostIdentityConflict';
+import { HostIdentityConflictNotice } from './HostIdentityConflictNotice';
import {
buildStandalonePageModel,
buildStandalonePostureSummary,
@@ -161,6 +163,9 @@ export function StandalonePageSurface() {
const outdatedAgentHosts = createMemo(() =>
collectOutdatedAgentHosts(model().machines, agentUpdateTargetVersion()),
);
+ const identityConflictHosts = createMemo(() =>
+ collectHostIdentityConflictHosts(model().machines),
+ );
const outdatedAgentUpdatePath = createMemo(() =>
buildInfrastructureAgentUpdatesPath(outdatedAgentHosts().map((host) => host.agentId)),
);
@@ -273,6 +278,7 @@ export function StandalonePageSurface() {
}
>
<div class="space-y-4">
+ <HostIdentityConflictNotice hosts={identityConflictHosts()} />
<PlatformOutdatedAgentNotice
hosts={outdatedAgentHosts()}
targetVersion={serverVersionDisplay()}
diff --git a/frontend-modern/src/features/standalone/__tests__/hostIdentityConflict.test.tsx b/frontend-modern/src/features/standalone/__tests__/hostIdentityConflict.test.tsx
new file mode 100644
index 0000000000..ff9d29a13e
--- /dev/null
+++ b/frontend-modern/src/features/standalone/__tests__/hostIdentityConflict.test.tsx
@@ -0,0 +1,105 @@
+import { cleanup, render, screen } from '@solidjs/testing-library';
+import { afterEach, describe, expect, it } from 'vitest';
+
+import type { Resource } from '@/types/resource';
+import { collectHostIdentityConflictHosts } from '../hostIdentityConflict';
+import { HostIdentityConflictNotice } from '../HostIdentityConflictNotice';
+
+const agentHost = (overrides: Partial<Resource> = {}): Resource =>
+ ({
+ id: 'agent-host-1',
+ type: 'agent',
+ name: 'agent-host-1',
+ ...overrides,
+ }) as Resource;
+
+describe('collectHostIdentityConflictHosts', () => {
+ it('returns an empty list when no host carries a conflict', () => {
+ expect(
+ collectHostIdentityConflictHosts([agentHost(), agentHost({ id: 'h2', name: 'h2' })]),
+ ).toEqual([]);
+ });
+
+ it('collects conflicting hosts with their hostnames and report IPs', () => {
+ const hosts = [
+ agentHost({
+ agent: {
+ identityConflict: {
+ hostnames: ['clone-a', ' clone-b '],
+ reportIps: ['192.168.1.10', ' 10.0.0.10 '],
+ firstSeen: '2026-07-27T12:00:00Z',
+ lastSeen: '2026-07-27T12:05:00Z',
+ },
+ },
+ }),
+ agentHost({ id: 'healthy', name: 'healthy' }),
+ ];
+ expect(collectHostIdentityConflictHosts(hosts)).toEqual([
+ {
+ name: 'agent-host-1',
+ hostnames: ['clone-a', 'clone-b'],
+ reportIps: ['192.168.1.10', '10.0.0.10'],
+ },
+ ]);
+ });
+
+ it('falls back to the resource id when the name is missing', () => {
+ const hosts = [agentHost({ name: '', agent: { identityConflict: { hostnames: ['a', 'b'] } } })];
+ expect(collectHostIdentityConflictHosts(hosts)[0].name).toBe('agent-host-1');
+ });
+});
+
+describe('HostIdentityConflictNotice', () => {
+ afterEach(() => cleanup());
+
+ it('renders nothing without conflicts', () => {
+ render(() => <HostIdentityConflictNotice hosts={[]} />);
+ expect(screen.queryByTestId('host-identity-conflict-notice')).toBeNull();
+ });
+
+ it('explains a single conflicted host with its flapping hostnames', () => {
+ render(() => (
+ <HostIdentityConflictNotice
+ hosts={[{ name: 'agent-host-1', hostnames: ['clone-a', 'clone-b'], reportIps: [] }]}
+ />
+ ));
+ const notice = screen.getByTestId('host-identity-conflict-notice');
+ expect(notice.textContent).toContain(
+ 'Two machines appear to share the identity of agent-host-1',
+ );
+ expect(notice.textContent).toContain('clone-a, clone-b');
+ expect(notice.textContent).toContain('/etc/machine-id');
+ });
+
+ it('falls back to report IPs when the clones reuse one hostname', () => {
+ render(() => (
+ <HostIdentityConflictNotice
+ hosts={[
+ {
+ name: 'pve01',
+ hostnames: ['pve01'],
+ reportIps: ['192.168.1.10', '10.0.0.10'],
+ },
+ ]}
+ />
+ ));
+ const notice = screen.getByTestId('host-identity-conflict-notice');
+ expect(notice.textContent).toContain('Two machines appear to share the identity of pve01');
+ expect(notice.textContent).toContain('192.168.1.10, 10.0.0.10');
+ });
+
+ it('lists every affected host when several conflict', () => {
+ render(() => (
+ <HostIdentityConflictNotice
+ hosts={[
+ { name: 'host-1', hostnames: ['a', 'b'], reportIps: [] },
+ { name: 'host-2', hostnames: ['host-2'], reportIps: ['1.1.1.1', '2.2.2.2'] },
+ ]}
+ />
+ ));
+ const notice = screen.getByTestId('host-identity-conflict-notice');
+ expect(notice.textContent).toContain('2 hosts');
+ expect(notice.textContent).toContain('host-1 (a, b)');
+ expect(notice.textContent).toContain('host-2 (1.1.1.1, 2.2.2.2)');
+ });
+});
diff --git a/frontend-modern/src/features/standalone/hostIdentityConflict.ts b/frontend-modern/src/features/standalone/hostIdentityConflict.ts
new file mode 100644
index 0000000000..b180537e5e
--- /dev/null
+++ b/frontend-modern/src/features/standalone/hostIdentityConflict.ts
@@ -0,0 +1,30 @@
+import type { Resource } from '@/types/resource';
+
+// Duplicate-identity detection for host agents (the host-agent shape of
+// #1584). The server flags a host when reports from more than one machine are
+// being folded into a single identity, which usually means template-deployed
+// machines still sharing /etc/machine-id. The hosts silently overwrite each
+// other in Pulse, so the page needs to say so.
+
+export type HostIdentityConflictHost = {
+ name: string;
+ hostnames: string[];
+ reportIps: string[];
+};
+
+const cleanList = (values: string[] | undefined): string[] =>
+ (values ?? []).map((value) => value.trim()).filter((value) => value.length > 0);
+
+export function collectHostIdentityConflictHosts(hosts: Resource[]): HostIdentityConflictHost[] {
+ const conflicts: HostIdentityConflictHost[] = [];
+ for (const host of hosts) {
+ const conflict = host.agent?.identityConflict;
+ if (!conflict) continue;
+ conflicts.push({
+ name: host.name?.trim() || host.id || 'host',
+ hostnames: cleanList(conflict.hostnames),
+ reportIps: cleanList(conflict.reportIps),
+ });
+ }
+ return conflicts;
+}
diff --git a/frontend-modern/src/types/resource.ts b/frontend-modern/src/types/resource.ts
index a90a2b514a..234dc2701f 100644
--- a/frontend-modern/src/types/resource.ts
+++ b/frontend-modern/src/types/resource.ts
@@ -673,6 +673,15 @@ export interface ResourceAgentMeta {
tokenName?: string;
tokenHint?: string;
tokenLastUsedAt?: number;
+ // Set while the server sees reports from more than one machine folded into
+ // this host identity (usually template-cloned machines sharing the same
+ // /etc/machine-id).
+ identityConflict?: {
+ hostnames?: string[];
+ reportIps?: string[];
+ firstSeen?: string;
+ lastSeen?: string;
+ };
}
export interface ResourceProxmoxMeta {
diff --git a/internal/models/deepcopy.go b/internal/models/deepcopy.go
index 88eab56a7f..3f99e0e446 100644
--- a/internal/models/deepcopy.go
+++ b/internal/models/deepcopy.go
@@ -388,9 +388,20 @@ func cloneHost(src Host) Host {
dest.TokenLastUsedAt = cloneTimePtr(src.TokenLastUsedAt)
dest.Tags = append([]string(nil), src.Tags...)
dest.DiskExclude = append([]string(nil), src.DiskExclude...)
+ dest.IdentityConflict = cloneHostIdentityConflict(src.IdentityConflict)
return dest.NormalizeCollections()
}
+func cloneHostIdentityConflict(src *HostIdentityConflict) *HostIdentityConflict {
+ if src == nil {
+ return nil
+ }
+ dest := *src
+ dest.Hostnames = append([]string(nil), src.Hostnames...)
+ dest.ReportIPs = append([]string(nil), src.ReportIPs...)
+ return &dest
+}
+
func cloneHosts(src []Host) []Host {
if len(src) == 0 {
return nil
diff --git a/internal/models/deepcopy_test.go b/internal/models/deepcopy_test.go
index 44b1b4f368..c15404edf4 100644
--- a/internal/models/deepcopy_test.go
+++ b/internal/models/deepcopy_test.go
@@ -65,6 +65,33 @@ func TestCloneDockerHost_PreservesIndependentIdentityConflict(t *testing.T) {
}
}
+func TestCloneHost_PreservesIndependentIdentityConflict(t *testing.T) {
+ src := Host{
+ ID: "host-1",
+ IdentityConflict: &HostIdentityConflict{
+ Hostnames: []string{"clone-a", "clone-b"},
+ ReportIPs: []string{"192.168.1.10", "10.0.0.10"},
+ },
+ }
+
+ got := cloneHost(src)
+ if got.IdentityConflict == nil {
+ t.Fatal("clone dropped identity conflict evidence")
+ }
+ if len(got.IdentityConflict.Hostnames) != 2 || got.IdentityConflict.Hostnames[0] != "clone-a" {
+ t.Fatalf("hostnames = %v, want [clone-a clone-b]", got.IdentityConflict.Hostnames)
+ }
+ src.IdentityConflict.Hostnames[0] = "mutated"
+ src.IdentityConflict.ReportIPs[0] = "mutated"
+ if got.IdentityConflict.Hostnames[0] != "clone-a" || got.IdentityConflict.ReportIPs[0] != "192.168.1.10" {
+ t.Fatal("cloned host must own its identity conflict slices")
+ }
+
+ if clean := cloneHost(Host{ID: "healthy"}); clean.IdentityConflict != nil {
+ t.Fatalf("healthy host should clone with nil conflict, got %+v", clean.IdentityConflict)
+ }
+}
+
func TestCloneFloat64Ptr_Nil(t *testing.T) {
if cloneFloat64Ptr(nil) != nil {
t.Error("nil should clone to nil")
diff --git a/internal/models/models.go b/internal/models/models.go
index db404ec233..5642a709eb 100644
--- a/internal/models/models.go
+++ b/internal/models/models.go
@@ -304,6 +304,10 @@ type Host struct {
PackageUpdates *HostPackageUpdateStatus `json:"packageUpdates,omitempty"`
StorageCleanup *HostStorageCleanupStatus `json:"storageCleanup,omitempty"`
IsLegacy bool `json:"isLegacy,omitempty"`
+ // IdentityConflict is set while multiple distinct machines appear to be
+ // reporting under this host's identity (e.g. template-cloned machines
+ // sharing the same /etc/machine-id). Nil when no conflict is active.
+ IdentityConflict *HostIdentityConflict `json:"identityConflict,omitempty"`
// Computed I/O rates (bytes/sec), populated from cumulative counters by rate tracker
NetInRate float64 `json:"netInRate,omitempty"`
@@ -408,9 +412,31 @@ func (h Host) NormalizeCollections() Host {
if h.DiskExclude == nil {
h.DiskExclude = []string{}
}
+ if h.IdentityConflict != nil {
+ conflict := h.IdentityConflict.NormalizeCollections()
+ h.IdentityConflict = &conflict
+ }
return h
}
+// HostIdentityConflict records evidence that reports from more than one
+// physical machine are being folded into a single host agent record. The
+// usual cause is template-deployed machines that still share the same
+// /etc/machine-id, which the agent uses as its identity.
+type HostIdentityConflict struct {
+ Hostnames []string `json:"hostnames"`
+ ReportIPs []string `json:"reportIps,omitempty"`
+ FirstSeen time.Time `json:"firstSeen"`
+ LastSeen time.Time `json:"lastSeen"`
+}
+
+func (c HostIdentityConflict) NormalizeCollections() HostIdentityConflict {
+ if c.Hostnames == nil {
+ c.Hostnames = []string{}
+ }
+ return c
+}
+
// HostNetworkInterface describes a host network adapter summary.
type HostNetworkInterface struct {
Name string `json:"name"`
diff --git a/internal/monitoring/host_identity_conflict.go b/internal/monitoring/host_identity_conflict.go
new file mode 100644
index 0000000000..4a48f3d565
--- /dev/null
+++ b/internal/monitoring/host_identity_conflict.go
@@ -0,0 +1,122 @@
+package monitoring
+
+import (
+ "strings"
+ "time"
+
+ "github.com/rcourtman/pulse-go-rewrite/internal/models"
+)
+
+// hostIdentityConflictWindow bounds how far apart two reports can be and
+// still count as evidence that distinct machines share one identity. It also
+// controls how long a detected conflict stays visible after the flapping
+// stops (e.g. one of the clones was fixed or shut down). Sized to cover a few
+// report cycles even for agents on multi-minute intervals.
+const hostIdentityConflictWindow = 15 * time.Minute
+
+// hostIdentityFlapTracker watches the stream of reports folded into a single
+// host agent identity and detects when two distinct machines are behind it.
+//
+// The signal is a *revisit*: the reported hostname (or report IP) switches
+// away from the previous value and back to one already seen inside the
+// window. A genuine hostname rename transitions exactly once and never
+// revisits the old value, so it does not trip the detector; template-cloned
+// machines that share /etc/machine-id alternate every report cycle and trip
+// it immediately. The report IP is tracked alongside the hostname because
+// MSP-style template deployments often reuse hostnames too (pve01 at two
+// sites), leaving the address as the only field that betrays the clone.
+type hostIdentityFlapTracker struct {
+ hostnames map[string]time.Time
+ reportIPs map[string]time.Time
+
+ lastHostname string
+ lastReportIP string
+
+ conflictSince time.Time
+ conflictLastSeen time.Time
+}
+
+func newHostIdentityFlapTracker() *hostIdentityFlapTracker {
+ return &hostIdentityFlapTracker{
+ hostnames: make(map[string]time.Time),
+ reportIPs: make(map[string]time.Time),
+ }
+}
+
+// observe records one report's identity fields and returns the active
+// conflict, or nil when the identity looks healthy.
+func (t *hostIdentityFlapTracker) observe(hostname, reportIP string, now time.Time) *models.HostIdentityConflict {
+ hostname = strings.TrimSpace(hostname)
+ reportIP = strings.TrimSpace(reportIP)
+
+ pruneOlderThan(t.hostnames, now.Add(-hostIdentityConflictWindow))
+ pruneOlderThan(t.reportIPs, now.Add(-hostIdentityConflictWindow))
+
+ revisit := false
+ if hostname != "" {
+ if _, seen := t.hostnames[hostname]; seen && t.lastHostname != "" && t.lastHostname != hostname {
+ revisit = true
+ }
+ t.hostnames[hostname] = now
+ t.lastHostname = hostname
+ }
+ if reportIP != "" {
+ if _, seen := t.reportIPs[reportIP]; seen && t.lastReportIP != "" && t.lastReportIP != reportIP {
+ revisit = true
+ }
+ t.reportIPs[reportIP] = now
+ t.lastReportIP = reportIP
+ }
+
+ if revisit {
+ if t.conflictSince.IsZero() || now.Sub(t.conflictLastSeen) > hostIdentityConflictWindow {
+ t.conflictSince = now
+ }
+ t.conflictLastSeen = now
+ }
+
+ if t.conflictLastSeen.IsZero() || now.Sub(t.conflictLastSeen) > hostIdentityConflictWindow {
+ t.conflictSince = time.Time{}
+ t.conflictLastSeen = time.Time{}
+ return nil
+ }
+
+ conflict := &models.HostIdentityConflict{
+ Hostnames: sortedKeys(t.hostnames),
+ FirstSeen: t.conflictSince,
+ LastSeen: t.conflictLastSeen,
+ }
+ // Report IPs are only interesting when they themselves diverge; when the
+ // clones alternate hostnames the hostname list already carries the story.
+ if len(t.reportIPs) > 1 {
+ conflict.ReportIPs = sortedKeys(t.reportIPs)
+ }
+ return conflict
+}
+
+// trackHostAgentIdentity feeds one report's identity fields into the flap
+// tracker for the resolved host identifier and returns the active conflict,
+// if any. Callers must not hold m.mu.
+func (m *Monitor) trackHostAgentIdentity(identifier, hostname, reportIP string, now time.Time) *models.HostIdentityConflict {
+ if strings.TrimSpace(identifier) == "" {
+ return nil
+ }
+
+ m.mu.Lock()
+ defer m.mu.Unlock()
+ if m.hostIdentityFlaps == nil {
+ m.hostIdentityFlaps = make(map[string]*hostIdentityFlapTracker)
+ }
+ tracker, ok := m.hostIdentityFlaps[identifier]
+ if !ok {
+ tracker = newHostIdentityFlapTracker()
+ m.hostIdentityFlaps[identifier] = tracker
+ }
+ return tracker.observe(hostname, reportIP, now)
+}
+
+// clearHostAgentIdentityTrackingLocked drops flap state for a host identity,
+// e.g. when the host is deliberately removed. Callers must hold m.mu.
+func (m *Monitor) clearHostAgentIdentityTrackingLocked(hostID string) {
+ delete(m.hostIdentityFlaps, hostID)
+}
diff --git a/internal/monitoring/host_identity_conflict_test.go b/internal/monitoring/host_identity_conflict_test.go
new file mode 100644
index 0000000000..31b3cafd0d
--- /dev/null
+++ b/internal/monitoring/host_identity_conflict_test.go
@@ -0,0 +1,249 @@
+package monitoring
+
+import (
+ "testing"
+ "time"
+
+ agentshost "github.com/rcourtman/pulse-go-rewrite/pkg/agents/host"
+)
+
+func TestHostIdentityFlapTrackerDetectsAlternatingHostnames(t *testing.T) {
+ tracker := newHostIdentityFlapTracker()
+ base := time.Date(2026, 7, 27, 12, 0, 0, 0, time.UTC)
+ interval := 30 * time.Second
+
+ if conflict := tracker.observe("clone-a", "", base); conflict != nil {
+ t.Fatalf("first report should not conflict, got %+v", conflict)
+ }
+ // First switch could be a legitimate rename, so it must not warn yet.
+ if conflict := tracker.observe("clone-b", "", base.Add(interval)); conflict != nil {
+ t.Fatalf("single hostname switch should not conflict, got %+v", conflict)
+ }
+ // The revisit of clone-a proves two machines are alternating.
+ conflict := tracker.observe("clone-a", "", base.Add(2*interval))
+ if conflict == nil {
+ t.Fatal("expected conflict after hostname revisit")
+ }
+ if len(conflict.Hostnames) != 2 || conflict.Hostnames[0] != "clone-a" || conflict.Hostnames[1] != "clone-b" {
+ t.Fatalf("expected sorted hostnames [clone-a clone-b], got %v", conflict.Hostnames)
+ }
+ if len(conflict.ReportIPs) != 0 {
+ t.Fatalf("absent report IPs should not be listed as conflicting, got %v", conflict.ReportIPs)
+ }
+ if conflict.FirstSeen.IsZero() || conflict.LastSeen.IsZero() {
+ t.Fatalf("expected conflict timestamps, got %+v", conflict)
+ }
+
+ // Continued flapping keeps the conflict alive and refreshes LastSeen.
+ later := tracker.observe("clone-b", "", base.Add(3*interval))
+ if later == nil {
+ t.Fatal("expected conflict to persist while flapping continues")
+ }
+ if !later.LastSeen.After(conflict.LastSeen) {
+ t.Fatalf("expected LastSeen to advance, got %v then %v", conflict.LastSeen, later.LastSeen)
+ }
+ if !later.FirstSeen.Equal(conflict.FirstSeen) {
+ t.Fatalf("expected FirstSeen to be stable, got %v then %v", conflict.FirstSeen, later.FirstSeen)
+ }
+}
+
+func TestHostIdentityFlapTrackerDetectsAlternatingReportIPsBehindOneHostname(t *testing.T) {
+ // MSP template deployments reuse hostnames across sites (pve01 at two
+ // customers), so the alternating report IP is the only field that betrays
+ // the clone.
+ tracker := newHostIdentityFlapTracker()
+ base := time.Date(2026, 7, 27, 12, 0, 0, 0, time.UTC)
+
+ tracker.observe("pve01", "192.168.1.10", base)
+ if conflict := tracker.observe("pve01", "10.0.0.10", base.Add(30*time.Second)); conflict != nil {
+ t.Fatalf("single report IP switch should not conflict, got %+v", conflict)
+ }
+ conflict := tracker.observe("pve01", "192.168.1.10", base.Add(60*time.Second))
+ if conflict == nil {
+ t.Fatal("expected conflict after report IP revisit")
+ }
+ if len(conflict.Hostnames) != 1 || conflict.Hostnames[0] != "pve01" {
+ t.Fatalf("expected shared hostname [pve01], got %v", conflict.Hostnames)
+ }
+ if len(conflict.ReportIPs) != 2 || conflict.ReportIPs[0] != "10.0.0.10" || conflict.ReportIPs[1] != "192.168.1.10" {
+ t.Fatalf("expected sorted report IPs [10.0.0.10 192.168.1.10], got %v", conflict.ReportIPs)
+ }
+}
+
+func TestHostIdentityFlapTrackerIgnoresSingleRename(t *testing.T) {
+ tracker := newHostIdentityFlapTracker()
+ base := time.Date(2026, 7, 27, 12, 0, 0, 0, time.UTC)
+
+ if conflict := tracker.observe("old-name", "", base); conflict != nil {
+ t.Fatalf("unexpected conflict: %+v", conflict)
+ }
+ for i := 1; i <= 5; i++ {
+ if conflict := tracker.observe("new-name", "", base.Add(time.Duration(i)*30*time.Second)); conflict != nil {
+ t.Fatalf("rename should never conflict, got %+v on report %d", conflict, i)
+ }
+ }
+}
+
+func TestHostIdentityFlapTrackerConflictExpiresAfterWindow(t *testing.T) {
+ tracker := newHostIdentityFlapTracker()
+ base := time.Date(2026, 7, 27, 12, 0, 0, 0, time.UTC)
+
+ tracker.observe("clone-a", "", base)
+ tracker.observe("clone-b", "", base.Add(30*time.Second))
+ if conflict := tracker.observe("clone-a", "", base.Add(60*time.Second)); conflict == nil {
+ t.Fatal("expected conflict after revisit")
+ }
+
+ // One clone goes away; steady reports from the survivor eventually clear it.
+ steady := base.Add(60 * time.Second).Add(hostIdentityConflictWindow + time.Minute)
+ if conflict := tracker.observe("clone-a", "", steady); conflict != nil {
+ t.Fatalf("expected conflict to expire after quiet window, got %+v", conflict)
+ }
+}
+
+func TestApplyHostReportFlagsClonedMachineIDIdentity(t *testing.T) {
+ monitor := newTestMonitor(t)
+
+ report := func(hostname, reportIP string, at time.Time) agentshost.Report {
+ return agentshost.Report{
+ Agent: agentshost.AgentInfo{
+ ID: "machine-duplicate",
+ Version: "6.0.0",
+ Type: "unified",
+ IntervalSeconds: 30,
+ },
+ Host: agentshost.HostInfo{
+ ID: "machine-duplicate",
+ Hostname: hostname,
+ Platform: "linux",
+ ReportIP: reportIP,
+ },
+ Timestamp: at,
+ }
+ }
+
+ base := time.Now().UTC()
+
+ // Two physical pve01 machines at different sites share a cloned
+ // /etc/machine-id, so their reports collapse into one host row whose
+ // report IP alternates every cycle.
+ first, err := monitor.ApplyHostReport(report("pve01", "192.168.1.10", base), nil)
+ if err != nil {
+ t.Fatalf("first report: %v", err)
+ }
+ if first.IdentityConflict != nil {
+ t.Fatalf("first report should not conflict, got %+v", first.IdentityConflict)
+ }
+
+ second, err := monitor.ApplyHostReport(report("pve01", "10.0.0.10", base.Add(30*time.Second)), nil)
+ if err != nil {
+ t.Fatalf("second report: %v", err)
+ }
+ if second.ID != first.ID {
+ t.Fatalf("expected clones to collapse into one identity, got %q vs %q", first.ID, second.ID)
+ }
+ if second.IdentityConflict != nil {
+ t.Fatalf("single report IP switch should not conflict yet, got %+v", second.IdentityConflict)
+ }
+
+ third, err := monitor.ApplyHostReport(report("pve01", "192.168.1.10", base.Add(60*time.Second)), nil)
+ if err != nil {
+ t.Fatalf("third report: %v", err)
+ }
+ if third.IdentityConflict == nil {
+ t.Fatal("expected identity conflict once the report IP flapped back")
+ }
+ if got := third.IdentityConflict.ReportIPs; len(got) != 2 || got[0] != "10.0.0.10" || got[1] != "192.168.1.10" {
+ t.Fatalf("expected conflict report IPs [10.0.0.10 192.168.1.10], got %v", got)
+ }
+
+ hosts := monitor.state.GetHosts()
+ if len(hosts) != 1 {
+ t.Fatalf("expected 1 collapsed host in state, got %d", len(hosts))
+ }
+ if hosts[0].IdentityConflict == nil {
+ t.Fatal("expected identity conflict to be stored on the state host")
+ }
+
+ // The conflict lingers while inside the detection window so the UI keeps
+ // warning even between flaps.
+ steady, err := monitor.ApplyHostReport(report("pve01", "192.168.1.10", base.Add(90*time.Second)), nil)
+ if err != nil {
+ t.Fatalf("steady report: %v", err)
+ }
+ if steady.IdentityConflict == nil {
+ t.Fatal("conflict should linger while inside the detection window")
+ }
+}
+
+func TestApplyHostReportOneTimeHostnameRenameDoesNotConflict(t *testing.T) {
+ monitor := newTestMonitor(t)
+
+ report := func(hostname string, at time.Time) agentshost.Report {
+ return agentshost.Report{
+ Agent: agentshost.AgentInfo{ID: "renamed-machine", Type: "unified", Version: "6.0.0", IntervalSeconds: 30},
+ Host: agentshost.HostInfo{
+ ID: "renamed-machine",
+ Hostname: hostname,
+ Platform: "linux",
+ },
+ Timestamp: at,
+ }
+ }
+
+ base := time.Now().UTC()
+ if _, err := monitor.ApplyHostReport(report("old-name", base), nil); err != nil {
+ t.Fatalf("first report: %v", err)
+ }
+ for i := 1; i <= 3; i++ {
+ host, err := monitor.ApplyHostReport(report("new-name", base.Add(time.Duration(i)*30*time.Second)), nil)
+ if err != nil {
+ t.Fatalf("report %d: %v", i, err)
+ }
+ if host.IdentityConflict != nil {
+ t.Fatalf("one-time rename should never conflict, got %+v on report %d", host.IdentityConflict, i)
+ }
+ }
+}
+
+func TestApplyHostReportIdentityConflictClearedOnHostRemoval(t *testing.T) {
+ monitor := newTestMonitor(t)
+
+ base := time.Now().UTC()
+ mkReport := func(hostname string, at time.Time) agentshost.Report {
+ return agentshost.Report{
+ Agent: agentshost.AgentInfo{ID: "machine-dup", Type: "unified", Version: "6.0.0"},
+ Host: agentshost.HostInfo{ID: "machine-dup", Hostname: hostname, Platform: "linux"},
+ Timestamp: at,
+ }
+ }
+
+ host, err := monitor.ApplyHostReport(mkReport("clone-a", base), nil)
+ if err != nil {
+ t.Fatalf("first report: %v", err)
+ }
+ if _, err = monitor.ApplyHostReport(mkReport("clone-b", base.Add(time.Second)), nil); err != nil {
+ t.Fatalf("second report: %v", err)
+ }
+ if _, err = monitor.ApplyHostReport(mkReport("clone-a", base.Add(2*time.Second)), nil); err != nil {
+ t.Fatalf("third report: %v", err)
+ }
+
+ monitor.mu.Lock()
+ if _, ok := monitor.hostIdentityFlaps[host.ID]; !ok {
+ monitor.mu.Unlock()
+ t.Fatal("expected flap tracker for host identity")
+ }
+ monitor.mu.Unlock()
+
+ if _, err := monitor.RemoveHostAgent(host.ID); err != nil {
+ t.Fatalf("RemoveHostAgent: %v", err)
+ }
+
+ monitor.mu.Lock()
+ if _, ok := monitor.hostIdentityFlaps[host.ID]; ok {
+ monitor.mu.Unlock()
+ t.Fatal("expected flap tracker to be cleared on host removal")
+ }
+ monitor.mu.Unlock()
+}
diff --git a/internal/monitoring/monitor.go b/internal/monitoring/monitor.go
index 2153dfae46..34d607a898 100644
--- a/internal/monitoring/monitor.go
+++ b/internal/monitoring/monitor.go
@@ -1126,6 +1126,7 @@ type Monitor struct {
kubernetesTokenBindings map[string]string // Track token ID -> agent ID bindings to enforce uniqueness
removedHostAgents map[string]time.Time // Track deliberately removed host agents (ID -> removal time)
hostTokenBindings map[string]string // Track tokenID:hostname -> host identity bindings
+ hostIdentityFlaps map[string]*hostIdentityFlapTracker // Track per-host-agent identity flapping (cloned machines sharing machine-id)
hostReportApplyLocksMu sync.Mutex
hostReportApplyLocks map[string]*hostReportApplyLock
hostReportOrderMu sync.Mutex
@@ -1767,6 +1768,7 @@ func New(cfg *config.Config) (*Monitor, error) {
kubernetesTokenBindings: make(map[string]string),
removedHostAgents: make(map[string]time.Time),
hostTokenBindings: make(map[string]string),
+ hostIdentityFlaps: make(map[string]*hostIdentityFlapTracker),
hostReportApplyLocks: make(map[string]*hostReportApplyLock),
hostReportOrders: make(map[string]hostReportOrder),
clusterSensorsCache: make(map[string]clusterSensorsCacheEntry),
diff --git a/internal/monitoring/monitor_agents.go b/internal/monitoring/monitor_agents.go
index 83e10f145a..594e0a9a20 100644
--- a/internal/monitoring/monitor_agents.go
+++ b/internal/monitoring/monitor_agents.go
@@ -367,6 +367,7 @@ func (m *Monitor) RemoveHostAgent(hostID string) (models.Host, error) {
m.removedHostAgents = make(map[string]time.Time)
}
m.removedHostAgents[hostID] = removedAt
+ m.clearHostAgentIdentityTrackingLocked(hostID)
m.mu.Unlock()
m.state.AddRemovedHostAgent(removedEntry)
@@ -1535,6 +1536,7 @@ func (m *Monitor) ClearUnauthenticatedAgents() (int, int) {
m.dockerTokenBindings = make(map[string]string)
m.hostTokenBindings = make(map[string]string)
m.dockerIdentityFlaps = make(map[string]*dockerIdentityFlapTracker)
+ m.hostIdentityFlaps = make(map[string]*hostIdentityFlapTracker)
m.mu.Unlock()
if hostCount > 0 || dockerCount > 0 {
@@ -2594,6 +2596,19 @@ func (m *Monitor) ApplyHostReport(report agentshost.Report, tokenRecord *config.
observedAt,
)
+ // Detect distinct machines flapping under one identity (e.g. template
+ // deployments still sharing /etc/machine-id, the host-agent shape of
+ // #1584) so the UI can warn instead of silently letting the reports
+ // overwrite each other.
+ identityConflict := m.trackHostAgentIdentity(identifier, hostname, strings.TrimSpace(report.Host.ReportIP), receivedAt)
+ if identityConflict != nil {
+ log.Warn().
+ Str("hostID", identifier).
+ Strs("hostnames", identityConflict.Hostnames).
+ Strs("reportIPs", identityConflict.ReportIPs).
+ Msg("Multiple machines appear to report under one host agent identity (cloned machines sharing /etc/machine-id?)")
+ }
+
host := models.Host{
ID: identifier,
Hostname: hostname,
@@ -2639,6 +2654,7 @@ func (m *Monitor) ApplyHostReport(report agentshost.Report, tokenRecord *config.
PackageUpdates: convertHostPackageUpdateStatus(report.Host.PackageUpdates, observedAt),
StorageCleanup: convertHostStorageCleanupStatus(report.Host.StorageCleanup, observedAt),
IsLegacy: isLegacyAgent(report.Agent.Type),
+ IdentityConflict: identityConflict,
}
// Normalize vendor-managed internal RAID arrays out of host state so they do
diff --git a/internal/unifiedresources/adapters.go b/internal/unifiedresources/adapters.go
index c535201fb2..20633a4d1a 100644
--- a/internal/unifiedresources/adapters.go
+++ b/internal/unifiedresources/adapters.go
@@ -190,6 +190,7 @@ func resourceFromHost(host models.Host) (Resource, ResourceIdentity) {
ReportIP: host.ReportIP,
DiskExclude: append([]string(nil), host.DiskExclude...),
IsLegacy: host.IsLegacy,
+ IdentityConflict: cloneHostIdentityConflict(host.IdentityConflict),
NetInRate: host.NetInRate,
NetOutRate: host.NetOutRate,
DiskReadRate: host.DiskReadRate,
diff --git a/internal/unifiedresources/clone.go b/internal/unifiedresources/clone.go
index c15b7aeba3..061649ac39 100644
--- a/internal/unifiedresources/clone.go
+++ b/internal/unifiedresources/clone.go
@@ -253,6 +253,17 @@ func cloneAgentData(in *AgentData) *AgentData {
out.PackageUpdates = cloneAgentPackageUpdateMeta(in.PackageUpdates)
out.StorageCleanup = cloneAgentStorageCleanupMeta(in.StorageCleanup)
out.DiskExclude = cloneStringSlice(in.DiskExclude)
+ out.IdentityConflict = cloneHostIdentityConflict(in.IdentityConflict)
+ return &out
+}
+
+func cloneHostIdentityConflict(in *models.HostIdentityConflict) *models.HostIdentityConflict {
+ if in == nil {
+ return nil
+ }
+ out := *in
+ out.Hostnames = append([]string(nil), in.Hostnames...)
+ out.ReportIPs = append([]string(nil), in.ReportIPs...)
return &out
}
diff --git a/internal/unifiedresources/code_standards_test.go b/internal/unifiedresources/code_standards_test.go
index ec8e73cb85..c6a577f89f 100644
--- a/internal/unifiedresources/code_standards_test.go
+++ b/internal/unifiedresources/code_standards_test.go
@@ -538,6 +538,34 @@ func TestCloneResourceClonesDockerIdentityConflict(t *testing.T) {
}
}
+func TestCloneResourceClonesHostAgentIdentityConflict(t *testing.T) {
+ original := Resource{
+ ID: "agent:host-1",
+ Type: ResourceTypeAgent,
+ Agent: &AgentData{
+ AgentID: "host-1",
+ IdentityConflict: &models.HostIdentityConflict{
+ Hostnames: []string{"pve01"},
+ ReportIPs: []string{"192.168.1.10", "10.0.0.10"},
+ },
+ },
+ }
+
+ cloned := cloneResource(&original)
+ if cloned.Agent == nil || cloned.Agent.IdentityConflict == nil {
+ t.Fatalf("clone lost host agent identity conflict evidence: %#v", cloned.Agent)
+ }
+ if !reflect.DeepEqual(cloned.Agent.IdentityConflict, original.Agent.IdentityConflict) {
+ t.Fatalf("identity conflict clone = %#v, want %#v",
+ cloned.Agent.IdentityConflict, original.Agent.IdentityConflict)
+ }
+
+ cloned.Agent.IdentityConflict.ReportIPs[0] = "changed"
+ if got := original.Agent.IdentityConflict.ReportIPs[0]; got != "192.168.1.10" {
+ t.Fatalf("identity conflict was aliased through clone, original report IP = %q", got)
+ }
+}
+
func TestCloneResourcePreservesDockerCPUCapacityMetadata(t *testing.T) {
original := Resource{
ID: "app-container:docker-host-1:web",
diff --git a/internal/unifiedresources/types.go b/internal/unifiedresources/types.go
index 1aaca576e6..7f64b1ca17 100644
--- a/internal/unifiedresources/types.go
+++ b/internal/unifiedresources/types.go
@@ -941,6 +941,10 @@ type AgentData struct {
ReportIP string `json:"reportIp,omitempty"`
DiskExclude []string `json:"diskExclude,omitempty"`
IsLegacy bool `json:"isLegacy,omitempty"`
+ // IdentityConflict is set while the server sees reports from more than one
+ // machine folded into this host identity (usually template-cloned machines
+ // sharing the same /etc/machine-id).
+ IdentityConflict *models.HostIdentityConflict `json:"identityConflict,omitempty"`
NetInRate float64 `json:"netInRate,omitempty"`
NetOutRate float64 `json:"netOutRate,omitempty"`
DiskReadRate float64 `json:"diskReadRate,omitempty"`
diff --git a/internal/unifiedresources/views.go b/internal/unifiedresources/views.go
index b760af91d3..33015a8008 100644
--- a/internal/unifiedresources/views.go
+++ b/internal/unifiedresources/views.go
@@ -1185,6 +1185,13 @@ func (v HostView) IsLegacy() bool {
return v.r.Agent.IsLegacy
}
+func (v HostView) IdentityConflict() *models.HostIdentityConflict {
+ if v.r == nil || v.r.Agent == nil {
+ return nil
+ }
+ return cloneHostIdentityConflict(v.r.Agent.IdentityConflict)
+}
+
func (v HostView) Status() ResourceStatus {
if v.r == nil {
return ""
diff --git a/internal/unifiedresources/views_test.go b/internal/unifiedresources/views_test.go
index 302f591ed6..53f5984e91 100644
--- a/internal/unifiedresources/views_test.go
+++ b/internal/unifiedresources/views_test.go
@@ -813,6 +813,38 @@ func TestView_HostViewAccessors(t *testing.T) {
}
}
+func TestView_HostViewIdentityConflictAccessor(t *testing.T) {
+ r := &Resource{
+ ID: "host-1",
+ Type: ResourceTypeAgent,
+ Agent: &AgentData{
+ AgentID: "host-1",
+ IdentityConflict: &models.HostIdentityConflict{
+ Hostnames: []string{"pve01"},
+ ReportIPs: []string{"10.0.0.10", "192.168.1.10"},
+ },
+ },
+ }
+
+ v := NewHostView(r)
+ conflict := v.IdentityConflict()
+ if conflict == nil || len(conflict.ReportIPs) != 2 || conflict.ReportIPs[0] != "10.0.0.10" {
+ t.Fatalf("expected identity conflict evidence, got %+v", conflict)
+ }
+ conflict.ReportIPs[0] = "mutated"
+ if r.Agent.IdentityConflict.ReportIPs[0] != "10.0.0.10" {
+ t.Fatal("IdentityConflict accessor must return an independent copy")
+ }
+
+ if healthy := NewHostView(&Resource{ID: "h2", Type: ResourceTypeAgent, Agent: &AgentData{}}); healthy.IdentityConflict() != nil {
+ t.Fatal("healthy host must report nil identity conflict")
+ }
+ var nilView HostView
+ if nilView.IdentityConflict() != nil {
+ t.Fatal("nil-backed view must report nil identity conflict")
+ }
+}
+
func TestView_HostViewIntegrationSource(t *testing.T) {
agentBacked := NewHostView(&Resource{
ID: "host-agent",