Repository navigation
fix(data-plane): move mooncake's ports out of the ephemeral range - #4103
Conversation
saumishr
left a comment
There was a problem hiding this comment.
Reviewed with the repo's review-pr skill. The band choice and the reservation mechanics check out (no other file hardcodes 50050/50051, TQ honors both addresses via urlparse, and the extra config key cannot raise because TQ reads that section with .get()), but one substantive gap: the metrics port is still on mooncake's default inside the ephemeral range, because TQ never forwards --metrics_port to mooncake_master -- so the crash described in the commit message is not actually fixed. Details inline, plus one maintainability point (this duplicates ManagedDynamoRuntime's port allocator), one test point, and one doc point.
|
Thank you @saumishr Can we also cover metrics port as well? This PR moves the two ports that worked and leaves the one that failed.
Merge as-is and job 3678431 reproduces identically. Why 9003 doesn't actually moveThe PR reserves a port and writes
"Inert" is the operative word: the value is written into a dict nothing consumes. The log the PR cites shows the same split: Fix — no TransferQueue change needed
If you'd rather scope this PR to metadata/rpc, fine — but please file the Premise confirmed (measured)Four GB200 nodes in the fleet where 3678431 failed: Identical on all four — fleet default, not node variance. 9003 is 3 ports inside Minor: none of the four new tests would fail today, since they pass while Approving the direction — happy to re-review once |
be76e8e to
3dacb03
Compare
|
/ok to test 3dacb03 |
3dacb03 to
c99f473
Compare
|
Two corrections to my own review, both now folded into The caveat I attached to the metrics-port comment was wrong, and the finding is firmer than I said. I claimed the TransferQueue pin was "Mooncake's defaults -- 50050, 50051 and 9003" misattributes the first number, and I repeated it in the code rather than catching it. 50050 is TransferQueue's While confirming that, I also found a stronger reason for the pre-flight check than "the master happens to die": the metrics socket is bound unconditionally. CI: |
c99f473 to
afe042f
Compare
|
Revised in
/ok to test afe042f |
saumishr
left a comment
There was a problem hiding this comment.
Re-review at afe042f after the metrics-port rework. Five findings, one of which breaks CI.
The headline is the inline comment on test_mooncake_metrics_port.py: two of its tests fail as soon as any earlier test calls _init_tq, which alphabetical collection guarantees. I reproduced both failures locally, so this is not a theoretical ordering concern — it was missed because the file was validated in isolation.
One finding has no line to attach to, since the file is not in the diff:
[DOC] tests/unit/data_plane/README.md — it describes itself as a "Generated audit of every test function under tests/unit/data_plane/" and carries a section per test file with a test count and one-line summaries (## test_mooncake_gdr.py (4 tests) and so on). The new test_mooncake_metrics_port.py (9 tests) needs a section, or the README stops being the inventory it claims to be.
Checked and deliberately not raised, so the next reader does not redo the work:
pyreflyis unchanged at one pre-existing error with none in the new code. Both changed source files are inpyrefly.tomlproject-includes, and CI runs the check, so this was worth confirming rather than assuming.- The proxy's
__getattr__delegation covers every attribute TQ's bootstrap actually touches (Popen,run,PIPE,STDOUT), andsubprocess.run(["pgrep", ...])cannot setmaster_launchedspuriously. - Re-registering through
StorageBootstrapProvider.register_providerdoes replace the entryget_providerreturns at the pinned TQ SHA, cannot stack wrappers, and cannot lose the original. tq.close()followed by a re-init repoints the proxy correctly rather than leaving a stale port.- Both port maps (
ray.subandvirtual_cluster.py) agree with the half-open constants and clear the Ray GCS ports at 1200-1201 and the router band at 1202. - Hardening the drift guard against a gflags
--terminator or space-separated flag was considered and dropped as speculative: the pinned argv is entirely-flag=valuewith no positionals and no terminator, and gflags permutes non-option arguments rather than terminating parsing.
afe042f to
715d097
Compare
|
Every finding from my re-review is fixed in
The one that mattered was the test-order failure: two tests in the new file asserted on installation state while any earlier Also re-checked after the fixes: /ok to test 715d097 |
|
/ok to test 715d097 |
|
@ZhiyuLi-Nvidia Please take a look. Included the metrics port as well. |
|
Thank you @saumishr, LGTM. |
The ports this stack lands on for the mooncake data plane -- 50050 for the metadata server and 50051 for the master RPC from TransferQueue's config.yaml, 9003 for the master's metrics server from mooncake_master's own gflag -- all sit inside the 9000-65000 ephemeral range these nodes use. The kernel can hand any of them to an outgoing connection during the minutes between job start and the master's bind, after which the master exits with EADDRINUSE and takes the run down with every node already up. Job 3678431 lost 10 nodes for 22 minutes this way: the master bound 50051 and 50050, then died on 9003 a second later. ray.sub's port map already documents this hazard and pins every other service below 9000. Allocate all three from one data-plane band in the gap that map leaves free, and record the band in both copies of the map, instead of hardcoding ports inside the range the kernel draws from. Every one of them reaches clients through the TQ controller actor rather than being assumed, so relocating them costs nothing. The reservation lives next to the other port helpers in virtual_cluster.py and allocates through _get_free_port_local with excluded_ports, the way ManagedDynamoRuntime already allocates its etcd/NATS/frontend ports: distinct by construction, and bound without SO_REUSEADDR, matching mooncake_master -- a port obtainable only by reusing a lingering slot is not one the master could bind either. That placement also keeps the band's tests off TransferQueue, so they run wherever the rest of the virtual_cluster port tests do. The metrics port takes a different route to the master. TransferQueue passes mooncake_master neither --metrics_port nor a --config_path file that could carry one, and mooncake_master reads a config file only when --config_path is given, so a config key for it would be inert -- and its bind is not optional either: MasterAdminServer::Start binds the socket before it consults enable_metric_reporting, and the master exits non-zero when that bind fails. TQ does build the master's argv in this process, though (tq.init -> _maybe_create_tq_storage -> initialize_mooncake_storage all run on the driver), so the bootstrap's subprocess.Popen is wrapped to append the flag, alongside the three TQ patches this adapter already installs. gflags takes the last occurrence of a repeated flag, so this stays correct if upstream starts passing its own. The provider registry holds a functools.wraps wrapper closed over the original bootstrap function, so the registry entry is re-registered too -- the same trap extract_field_schema has. That wrapper is also where the drift check lives: if a future TQ revision launches the master by some other route, the flag would stop landing silently and the metrics server would be back on 9003, so the bootstrap is required to have gone through the wrapped Popen. Signed-off-by: Saurabh Mishra <[email protected]>
715d097 to
92459f6
Compare
|
Lint is fixed in
registered_bootstrap: Callable[..., Any] = bootstrap
# pyrefly: ignore[bad-assignment] the proxy stands in for the module on purposeAfter the fix, with the pinned version and TransferQueue resolving for real: /ok to test 92459f6 |
|
/ok to test 92459f6 |
Eleven commits, two conflicts. nemo_rl/algorithms/single_controller.py -- NOT a keep-both. #3925 (telemetry for rollout checkpointing) replaced the retry-count approach with a reason-typed result: it deletes _MAX_CONSECUTIVE_ROLLOUT_CHECKPOINT_FAILURES and adds the _RolloutCheckpointSaveResult dataclass in the same place this branch's _SUPERVISOR_DRAIN_TIMEOUT_S sits. Resolved as ours + main's dataclass, with the constant dropped: it has no remaining users anywhere in the merged tree, this branch never referenced it, and RolloutCheckpointAttemptReason is imported and used by the replacement. Keeping it would have resurrected a name main removed on purpose. tests/unit/environments/test_nemo_gym_utils.py -- adjacency, as before. #3368 (actor failure and teardown ownership) appends module-level tests to the same end-of-file this branch appended TestUnresolvedAgentRefsAreDiagnosable to. main's functions first, this branch's class after. The other nine merged clean, including #3739 (nccl_reshard M-to-N refit for Megatron generation) and #4063 (refit_with_reload_api in the v2 entrypoint), both of which touch refit paths this PR hardens. Verified after the merge: every artefact this PR adds is still present (_refit_participants, _SUPERVISOR_DRAIN_TIMEOUT_S, the aggregated router drain, shard_liveness_ref, record_weight_version, should_rebuild, restart_backoff_s, the router's transport-cause log), submodule pins match main on all three, and 1398 tests pass across single_controller, fleet_health, the generation router, the gym utils and weight_sync. pyrefly reports two new import errors beyond the known one, all three in data_plane/adapters/transfer_queue.py from #4103, inside a try/except ImportError that exists to report exactly that drift. Optional TQ submodules absent from this container, not a regression. Signed-off-by: asolergibert <[email protected]> Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…IDIA-NeMo#4103) Signed-off-by: Saurabh Mishra <[email protected]>
Overview
The ports this stack lands on for the mooncake data plane -- 50050 for the metadata server and 50051 for the master RPC, both from TransferQueue's
config.yamlrather than from mooncake, which defaults its HTTP metadata server to 8080 and off, plus 9003 for the master's metrics server frommooncake_master's own gflag -- all sit inside the 9000-65000 ephemeral range these nodes use. The kernel can hand any of them to an outgoing connection during the minutes between job start and the master's bind, after which the master exits withEADDRINUSEand takes the run down with every node already up. Job 3678431 lost 10 nodes for 22 minutes this way: the master bound 50051 and 50050, then died on 9003 a second later.ray.sub's port map already documents this hazard and pins every other service below 9000. This allocates all three ports from one data-plane band in the gap that map leaves free (1150-1199) and records the band in both copies of the map, instead of hardcoding ports inside the range the kernel draws from. Every one of them reaches clients through the TQ controller actor rather than being assumed, so relocating them costs nothing.The reservation (
_reserve_data_plane_ports) lives next to the other port helpers invirtual_cluster.pyand allocates through_get_free_port_localwithexcluded_ports, the wayManagedDynamoRuntimealready allocates its etcd/NATS/frontend ports: distinct by construction, and bound withoutSO_REUSEADDR, matchingmooncake_master-- a port obtainable only by reusing a lingering slot is not one the master could bind either.The metrics port needs a different route to the master
TransferQueue passes
mooncake_masterneither--metrics_portnor a--config_pathfile that could carry one (mooncake_bootstrap.py#L110-L128), andmooncake_masterreads a config file only when--config_pathis given, so a config key for it is inert. Its bind is not optional either:MasterAdminServer::Startbinds the socket before it consultsenable_metric_reporting, and the master returns 1 when that bind fails. 9003 is the port that actually killed job 3678431.TQ does build the master's argv in this process, though --
tq.init->_maybe_create_tq_storage->initialize_mooncake_storageall run on the driver -- so_patch_mooncake_master_metrics_portwraps thesubprocess.Popenthat bootstrap calls and appends--metrics_port=<reserved>, alongside the three TQ patches this adapter already installs. gflags takes the last occurrence of a repeated flag, so this stays correct if upstream starts passing its own.The provider registry holds a
functools.wrapswrapper closed over the original bootstrap function, so the registry entry is re-registered too -- the same trapextract_field_schemahas, where rebinding only the defining module leaves the called function unpatched. That wrapper is also where the drift check lives: if a future TQ revision launches the master by some other route, the flag would stop landing silently and the metrics server would be back on 9003, so the bootstrap is required to have gone through the wrappedPopen. The patch can be deleted outright once TQ forwards ametrics_portfromconf.backend.MooncakeStore.What does this PR do ?
Moves every port mooncake's master listens on -- metadata server, master RPC and master metrics -- into the 1150-1199 band that
ray.sub's port map leaves free, so none of them is drawn from the kernel's ephemeral range any more.Issues
Job 3678431 (10 nodes lost for 22 minutes to
mooncake_masterexiting withEADDRINUSE).Usage
No user-facing configuration change: the ports are allocated on the driver and reach clients through the TQ controller actor.
Before your PR is "Ready for review"
Pre checks:
Additional Information
Band and allocator tests sit with the other port helpers in
tests/unit/distributed/test_virtual_cluster.pyand import no TransferQueue, so they run in the base unit-test environment:TestReserveDataPlanePorts(distinctness, band, ephemeral floor, occupied-port avoidance, exhaustion),test_data_plane_band_does_not_collide_with_ray_sub_ports, and data-plane assertions intest_default_port_ranges_ordered_and_below_ephemeral_floor(including that the band is wide enough for all three ports).The argv patch is covered in
tests/unit/data_plane/test_mooncake_metrics_port.py: the flag is appended formooncake_master(bare or absolute path) and never for the offload client, unknown attributes delegate to the realsubprocess, the registry entry that is actually called gets patched, re-init repoints the port instead of stacking wrappers, a bootstrap that skips the wrappedPopenraises, and_init_tqend-to-end hands out three distinct in-band ports with nometrics_portkey in the config TQ reads.