Skip to content

fix(mdns): stop advertising the computer's hostname over mDNS - #235

Open
stevbev wants to merge 2 commits into
NVIDIA:developfrom
stevbev:fix/mdns-hostname-claim
Open

stevbev wants to merge 2 commits into
NVIDIA:developfrom
stevbev:fix/mdns-hostname-claim

Conversation

@stevbev

@stevbev stevbev commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Description

Closes #229

On macOS, PAIR's discovery advertisement turned the computer's Local hostname into <name>-2.

PAIR's node scanner advertises the node as one _nvpair-node._tcp record. Its SRV target and A records named the machine's own hostname — so PAIR became a second mDNS responder asserting a name the operating system's own responder already owned. RFC 6762 treats two responders disagreeing over a unique record as a conflict, and macOS resolves it the way Bonjour does: it renames the computer's Local hostname, appending -2. Every PAIR start re-litigated the name; nothing the user configures prevents it.

The fix is one rule: PAIR now advertises a host record it owns and nobody else can claim.

  • The SRV target and A records carry a synthetic label derived from the node's stable UUID — nvpair-<first twelve hex digits> (example: nvpair-9d4e7c1a06b3). It is stable across restarts and link changes, and already tied to the node identity because the same UUID is in the record's TXT.
  • The service instance name is still the computer's hostname, unchanged: node names in the UI and in every consumer's directory entries behave exactly as before. Hostnames remain display-only.
  • On shutdown the scanner now retracts every record it ever claimed (PTR, SRV, TXT, A at TTL 0), so peers drop the node immediately instead of waiting out cached entries.
  • The record ID consumers use to track a discovery record no longer hashes that SRV target host label. The SRV target is not connection information and no consumer reads it, so dropping it means upgrading a node neither re-keys its discovery record nor disturbs pairing or cluster state.
  • If no usable node identity is available, the label falls back to a hash of the hostname (still never the hostname itself), with a warning that the name follows renames; with no entropy at all, the scanner advertises nothing rather than a placeholder everyone would collide on.

No macOS configuration is involved, required, or recommended anywhere in this change — the defect was PAIR claiming a name it did not own, and the fix is PAIR stopping.

Release intent

Changelog title

PAIR no longer claims the computer's hostname on the local network

Changelog body

  • The node scanner advertises a synthetic host record name derived from the node's identity instead of the computer's hostname, so running PAIR no longer makes macOS rename the computer's Local hostname (the <name>-2 suffix).
  • Node records are now fully retracted on shutdown, so peer lists update immediately instead of after cached entries expire.
  • Node names shown in the application are unchanged.

Bumps

  • services: minor
  • nvpair-cluster-manager: none
  • nvpair-engine-manager: none
  • nvpair-errors: none
  • nvpair-job-scheduler: none
  • nvpair-manual-nodes: none
  • nvpair-node-info: none
  • nvpair-node-scanner: minor
  • nvpair-node-settings: none
  • nvpair-proxy: none
  • nvpair-tui: none
  • nvpair-ui-broker: minor
  • nvpair-workload-manager: none

Scope

Included:

  • nvpair-shared/noderec: HostLabel(nodeUUID, hostname) — the one place the label rule lives (UUID → hostname-hash → refuse).
  • nvpair-node-scanner: responder advertises the synthetic label (A records + SRV target); full PTR+SRV+TXT+A TTL-0 goodbye on shutdown; discoveryRecordId no longer hashes the SRV host label; the cross-process test stubs advertise synthetic hosts too, so the test suite can no longer reproduce the collision in CI.
  • Docs: the scanner spec, cluster-manager spec, architecture.mdx, and the noderec comments describe the record as it is now advertised.

Excluded deliberately:

  • No RFC 6762 §8 name-probing. Probing would let PAIR keep claiming the machine's name "politely"; the correct fix is not claiming it. One synthetic name, one code path.
  • No compatibility branch for the old record shape. One canonical layout; mixed-version operation was verified, not bridged.
  • The TXT records of test stubs still carry routable addresses (pre-existing; tracked separately).
  • Scanner-side label refresh on hostname rename mid-run (the UUID-derived label does not move on renames; the fallback-hash label does, with a warning) — follow-up candidate.

Validation

All on macOS (Apple Silicon), live 5353 captures on one IPv4 interface; every count below re-derived independently from the raw capture files, not from grep summaries; example hostnames and addresses are pseudonymized:

  • make check + desktop dead-code:check/service-contracts:check/lint/typecheck/typecheck:web/test:unit: all exit 0 on the squashed tree. All Go modules go test ./... clean except two pre-existing engine-manager failures that reproduce identically at clean develop tip (6bfdcdb); zero skips. Known pre-existing, unrelated: TestUninstall_TerminatesRunningInstance fails at clean develop tip too.
  • Wire before (old binary, standalone scanner): 260 A + 260 SRV records at TTL 120 naming the machine hostname, teardown = PTR only at TTL 0, zero hostname records ever retracted — the defect, captured. Wire after (this build, two windows): zero PAIR-TTL records naming the hostname; 246 A + 246 SRV at TTL 120 for nvpair-9d4e7c1a06b3.local. (instance name still the hostname; +1 each at TTL 0 in the goodbye).
  • dns-sd -Q nvpair-9d4e7c1a06b3.local A → Addr IN 10.108.6.189. The dns-sd -B/-L browse pair is reported as inconclusive on the test host on purpose: a control (dns-sd -P native registration) proved same-host dns-sd enumeration blind there today even to the system's own stack, so the authoritative channel is raw 5353 capture plus -Q.
  • Goodbye: after SIGTERM, one packet with TTL-0 PTR+SRV+TXT+A sent 45 ms later, before process exit; independently reproduced in the mixed-version capture (second responder, ~0.9 s).
  • Mixed-version coexistence (old develop-tip scanner + this scanner running concurrently, same network): the wire carries 181 hostname-targeted SRV answers from the old binary and 0 from the new one in the same capture; TXT census attributes both identities cleanly; zero §9 conflict events logged by either responder across the window; both tears down with their own (PTR-only vs full) goodbyes.
  • cd services/tests && go test ./... -count=1: 99 PASS / 0 FAIL / 0 SKIP with installed PAIR off. With PAIR on it fails 15 default-port tests; representatives fail identically at develop tip with PAIR on, and the same binaries on the same tree pass all 15 off — pre-existing port contention with the installed app, no branch causation.
  • services/versions.json and CHANGELOG.md untouched — bumps declared here only.

Risk

  • A node's mDNS target name changes shape on upgrade. Consumers take ports from TXT and treat the instance name as display-only, and the record ID deliberately does not include the host label, so consumers key on unchanged information; mixed-version operation verified above.
  • The fallback label (hostname hash) moves if the hostname changes while no node identity is available. That rung exists only for configurations that cannot persist an identity; the warning is logged next to the advertised name.
  • Advertise-nothing with no entropy is a behavior change: such a configuration advertised a colliding placeholder before and advertises nothing now. That state means no usable node identity and no hostname; advertising anything would recreate this bug.
  • Peers running the old scanner keep advertising hostname-derived names until they upgrade. Coexistence was verified; the contention each old node causes on its own machine is that machine's upgrade to make.

Checklist

  • I have read the Contributing Guidelines.
  • Every commit is signed off (git commit -s), certifying the Developer Certificate of Origin.
  • New or existing tests cover the change.
  • Relevant documentation is updated.
  • I checked the diff, changed filenames, and commit messages for credentials, private data, internal URLs, internal issue identifiers, and generated artifacts.
  • I recorded the validation commands and results above.
  • I declared version bumps in the release-intent block above. services/versions.json is written by automation — do not edit it by hand.

@stevbev
stevbev force-pushed the fix/mdns-hostname-claim branch from b9c3e7b to b1ae820 Compare November 24, 2026 17:05

@Noah-Tervalon-Nvidia Noah-Tervalon-Nvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gonna go bug someone else for a review just to double check since this is large, but I only found the one issue.

PAIR published A records and an SRV target naming the machine's own hostname,
which made it a second responder asserting the operating system's host name.
macOS responds to that contention by renaming the computer's Local hostname
to <name>-2. PAIR now advertises a synthetic host label derived from the node
UUID, retracts every record it claimed on shutdown, and no longer hashes that
label into discovery record IDs, so existing nodes neither re-key nor re-pair.

Closes NVIDIA#229

Signed-off-by: Steven Beverly <thestevbev@gmail.com>
…e suite

grandcat v1.0.0 sets no write deadline anywhere, and Server.Shutdown holds
its shutdown lock while unregister sends the goodbye on every interface
listMulticastInterfaces reports — loopback, VPN tunnels and peer-to-peer
interfaces included — before it closes any socket. An interface that answers
"network is unreachable" is harmless, because grandcat discards write errors,
but one that accepts the packet into a queue that never drains leaves that
write waiting to become writable indefinitely. Reported on an M5 mac, whose
goroutine dump shows exactly that park.

Route all three grandcat teardowns in the package through one bounded wait:
the cleanup registerTestAdvertisement registers on behalf of every call site,
the control of the hostname-claim guard, and the multicast control of the
discovery diagnosis. The cleanup is the one that matters most — cleanups run
one test at a time, so a parked one stalls every later test until go test's
own timeout dumps the binary.

A teardown that outlives the deadline is reported rather than failed: one
interface that will not take a goodbye should not turn red every test that
advertised anything. That report goes to the test's own *testing.T, because
a throwaway one discards everything written to it.

The bound frees the test, not the write: grandcat's sockets are unexported
and closed only after the write returns, so a stalled advertisement is
retracted when its records reach their TTL. Those records are always a
synthetic label pointing at 127.0.0.1, so the residue is a dead entry a peer
drops by itself, not a live node's entry being replaced.

Test-only: no service binary's compiled output changes.
Signed-off-by: Steven Beverly <thestevbev@gmail.com>
@stevbev
stevbev force-pushed the fix/mdns-hostname-claim branch from b1ae820 to 723e5bb Compare November 25, 2026 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mDNS responder claims the machine's own hostname, so macOS renames its Local hostname to <name>-2

2 participants