Support dynamic NodeServer port allocation#335
Merged
slawlor merged 4 commits intoslawlor:mainfrom Feb 27, 2025
Merged
Conversation
- 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.
cerceris
reviewed
Feb 25, 2025
| ) -> Result<(), ActorProcessingErr> { | ||
|
|
||
| // If the used port differs from the user-specified port, inform the supervisor. | ||
| if let Some(listener) = &state.listener { |
slawlor
requested changes
Feb 25, 2025
Codecov ReportAttention: Patch coverage is
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. |
slawlor
approved these changes
Feb 27, 2025
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.
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:
NodeServerMessage::PortChangedthat tells the NodeServer to update its connection_string.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) aPortChangedMessage.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.