Repository navigation
Conversation
stevbev
force-pushed
the
fix/mdns-hostname-claim
branch
from
November 24, 2026 17:05
b9c3e7b to
b1ae820
Compare
Noah-Tervalon-Nvidia
requested changes
Nov 25, 2026
Noah-Tervalon-Nvidia
left a comment
Collaborator
There was a problem hiding this comment.
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
force-pushed
the
fix/mdns-hostname-claim
branch
from
November 25, 2026 21:26
b1ae820 to
723e5bb
Compare
nvrithik
reviewed
Nov 26, 2026
daemon.run kept the bounded wait for responder.Run inside its ctx.Done() branch, but cancelling the context makes that case and the browser's closed events channel ready at the same instant, and select takes either. When it took the closed channel, run returned with responder.Run still inside its shutdown, so Scanner.Run could reach process exit with the RFC 6762 §10.1 retraction unsent — the same early return reproduced on DGX Spark and macOS. Move the responder join, together with the idle peer clients that are closed alongside it, into one deferred cleanup registered before the loops start, so both exits wait. The responder is still the only component joined: the other background loops hold nothing the wire needs after cancellation. daemon now names its two mDNS collaborators as interfaces so a test can control when each finishes; production wiring is unchanged, since mdns.Responder and *discovery.Browser already satisfy them. Without that seam nothing could prove the wait: the real responder sends its goodbye in microseconds, so a timing assertion against it cannot tell a joined shutdown from a skipped one. Two daemon_test cases drive each branch with a responder whose shutdown the test releases — the closed-channel case failed before this change, the cancellation case passed because that branch already waited. Changes nvpair-node-scanner's compiled output: shutdown now waits for the responder even when the browse loop ends on the browser's closed channel. Signed-off-by: Steven Beverly <thestevbev@gmail.com>
nvrithik
approved these changes
Nov 27, 2026
nvrithik
left a comment
Collaborator
There was a problem hiding this comment.
+1. Thanks for addressing the shutdown-wait concern. The deferred cleanup now covers both context cancellation and browser-channel closure, with regression tests for each path.
Verified both new regression tests with 50 race-detector repetitions each, plus the full scanner race-detector suite; all passed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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._tcprecord. 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 retracts every record it claimed (PTR, SRV, TXT, A at TTL 0), so peers drop the node immediately instead of waiting out cached entries. The wait for that retraction now runs whichever way the browse loop ends:
daemon.runkept its bounded join inside thectx.Done()branch of its select, but cancellation makes that case and the browser's closedeventschannel ready at the same instant andselecttakes either, so about half of cancellations returned withresponder.Runstill inside its shutdown — see the follow-up below.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.
Follow-up on review: the shutdown join now runs on every way out of the browse loop
daemon.runstarted the mDNS responder, then waited for it only in thecase <-ctx.Done()branch of its select overctx.Done()and the browser'seventschannel.discovery.Browser.Runcloses that channel as it stops onctx.Done(), so on cancellation both cases are ready at once and Go picks one at random: when it picked the closed channel,runreturned without ever waiting, and the process could exit with the goodbye still in progress (reproduced on DGX Spark and macOS).The cleanup — the bounded
waitForShutdownon the responder, plus theCloseIdlecalls that belonged with it — now sits in a singledeferregistered before the loops start, so both exits wait.daemon's two mDNS collaborators are declared as small interfaces (mdnsResponder,discoveryBrowser) purely so a test can control when each finishes; production wiring is unchanged becausemdns.Responderand*discovery.Browseralready satisfy them. Twodaemon_test.gocases drive one branch each against a responder whose shutdown the test releases, which is the only way to observe the join: the real responder sends its goodbye in microseconds, so no timing assertion against it can distinguish a waited shutdown from a skipped one. The context-cancellation case passed before this change (that branch already waited); the closed-channel case failed with "daemon.run returned while the responder was still sending its goodbye" and passes now.User-visible behavior is unchanged from the description above; this commit makes the retraction guarantee hold every time instead of about half the time.
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>-2suffix).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
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;discoveryRecordIdno 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.nvpair-node-scanner(review follow-up):daemon.run's responder join and idle-peer-client cleanup moved into a single deferred cleanup, so it runs on both exits from the browse loop, plusdaemon_test.gocases proving each exit waits (TestDaemonRun_DoesNotReturnBeforeTheResponderHasShutDownWhenTheContextIsCancelledand…WhenTheBrowserClosesItsEvents).mdnsResponderanddiscoveryBrowserexist only as test seams.Docs: the scanner spec, cluster-manager spec,
architecture.mdx, and thenodereccomments describe the record as it is now advertised. No specification change was needed for the follow-up: the spec already required the retraction, and the follow-up is what makesdaemon.runhonor it in all cases.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.
No unbounded wait for the responder. The join is still capped at
shutdownJoinTimeout(2s) and logs a warning if it expires: a stalled interface should not hang the broker's wait forever, and the records expire at their TTL anyway.Validation
Recorded 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.
Wire evidence, recorded on the tree before the review follow-up (
de6ce32/723e5bb) and not re-derived since: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. Thedns-sd -B/-Lbrowse pair is reported as inconclusive on the test host on purpose: a control (dns-sd -Pnative registration) proved same-hostdns-sdenumeration blind there today even to the system's own stack, so the authoritative channel is raw 5353 capture plus-Q.selectchose thectx.Done()branch, so the "retraction before exit" outcome was not guaranteed by any capture on the old tree.Re-run on the current tree, including the review follow-up:
go test ./...fromservices/: everything passes exceptnvpair-engine-manager→TestUninstall_TerminatesRunningInstance(one failure, not two; it reproduces at clean develop tip, where the executor refuses to stop a process it treats as externally managed).services/nvpair-node-scanner: 152 tests pass, 0 fail, 1 skip —TestDispatchHardwarePreviews_LimitsConcurrentReadsAcrossNodesAndAddresses, which needs a second loopback alias (sudo ifconfig lo0 alias 127.0.0.2) that a default macOS host does not have. The two newdaemon_test.gocases are among the passes.cd services/tests && go test ./... -count=1: 94 pass, 0 fail, 6 skip, run beside the installed PAIR, which was live throughout; the six skips are the default-port tests that skip when the installation already holds the port. The earlier figure — 99 pass / 0 fail / 0 skip — was recorded with the installation off and predates the follow-up.services/nvpair-engine-manager: 16 skips besides the failing test, all environment-gated (no vLLM/venv install, no second loopback alias). The earlier "zero skips" claim did not hold on this host and has been replaced with the actual counts.make checkand the desktop gates (dead-code:check,service-contracts:check,lint,typecheck,test:unit) exit 0 on the squashed tree as previously recorded; the follow-up commit changes onlyservices/nvpair-node-scannersources, so no TypeScript, contract, or documentation input changed and those results carry over unchanged.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.
daemon's two mDNS collaborators are now interfaces.mdnsResponderanddiscoveryBrowserexist so a test can control when the responder and the browser finish their shutdown; they add no runtime branch and no second code path, andnewDaemonstill wires the concretemdns.Responderanddiscovery.Browser.Checklist
git commit -s), certifying the Developer Certificate of Origin.services/versions.jsonis written by automation — do not edit it by hand.