Skip to content

Support dynamic NodeServer port allocation#335

Merged
slawlor merged 4 commits intoslawlor:mainfrom
NilsDeckert:main
Feb 27, 2025
Merged

Support dynamic NodeServer port allocation#335
slawlor merged 4 commits intoslawlor:mainfrom
NilsDeckert:main

Conversation

@NilsDeckert
Copy link
Copy Markdown
Contributor

Issue

See Issue #334.

TLDR:
Creating a NodeServer with port 0 lets the OS choose an available port. The port chosen by the OS is not reflected in the connection_string. Transitive connections to nodes that used port 0 will fail, since other nodes will try to connect to port 0.

Changes

I fixed the issue with the following changes:

  • Add a new NodeServerMessage::PortChanged that tells the NodeServer to update its connection_string.
  • In net::listener::Listener::post_start() query the port that the listener is bound to. If it differs from the user-specified port, send the supervisor (the NodeServer) a PortChanged Message.

I also changed the input for the dist_connect integration test slightly to use port 0 so that both the basic functionality and this 'edge case' are tested.


I'm not entirely sure this approach is the most idiomatic, so I am very open to feedback.

 - Add NodeServerMessage::PortChanged
 - Add post_start() for net::listener

After starting, the net::listener actor compares the user-specified port
with the actually used port. If they differ, a PortChanged message will
be sent to the supervisor, who then updates the connection string.
Comment thread ractor_cluster/src/net/listener.rs Outdated
) -> Result<(), ActorProcessingErr> {

// If the used port differs from the user-specified port, inform the supervisor.
if let Some(listener) = &state.listener {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Skipping all the errors? For what?

Comment thread ractor_cluster/src/net/listener.rs Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 25, 2025

Codecov Report

Attention: Patch coverage is 0% with 18 lines in your changes missing coverage. Please review.

Project coverage is 82.39%. Comparing base (77ec8d8) to head (64b8976).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
ractor_cluster/src/net/listener.rs 0.00% 9 Missing ⚠️
ractor_cluster/src/node/mod.rs 0.00% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #335      +/-   ##
==========================================
- Coverage   82.47%   82.39%   -0.09%     
==========================================
  Files          65       65              
  Lines       12904    12917      +13     
==========================================
  Hits        10643    10643              
- Misses       2261     2274      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@slawlor slawlor merged commit 9ebeece into slawlor:main Feb 27, 2025
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.

3 participants