Repository navigation
[1/n] IPv6 support: address <-> host:port conversion - #55129
Yicheng-Lu-llll wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Summary of Changes
Hello @Yicheng-Lu-llll, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
I am introducing the foundational changes for IPv6 support in Ray. This pull request focuses on establishing a consistent and correct way to handle the conversion between IP addresses (including IPv6) and host:port string representations across both Python and C++ components. By centralizing this logic, I am preparing the codebase for broader IPv6 compatibility in subsequent changes.
Highlights
- New Network Utilities: I've added "parse_address" and "build_address" functions in "python/ray/_private/network_utils.py" and their C++ counterparts in "src/ray/common/network_util.cc" and ".h". These utilities correctly handle IPv6 addresses by enclosing them in square brackets "[]" when forming host:port strings.
- Runtime Environment Agent IP Binding: I've updated the runtime environment agent to bind directly to "args.node_ip_address" instead of a hardcoded "127.0.0.1" or "0.0.0.0". This change allows the agent to correctly bind to IPv6 addresses if "node_ip_address" is an IPv6 address.
- Refactored Address Parsing/Building: I've integrated the new "ParseAddress" and "BuildAddress" utilities into key Ray components, including the GCS client, Redis context, and gRPC client. This ensures that all address parsing and building operations are IPv6-aware and consistent.
- Removed Redundant Function: The simple "address" helper function in "python/ray/_private/services.py" has been removed, as its functionality is now superseded by the more robust "build_address" utility.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request introduces utility functions for handling IPv6 addresses in both Python and C++, which is a good step towards full IPv6 support. The core logic for parsing and building addresses with host and port components has been added. My review focuses on the correctness and robustness of these new utility functions. I've identified some critical issues where the parsing logic for IPv6 addresses is incorrect, especially for addresses without ports. I've also pointed out that the logic for building addresses is not fully robust and can be improved by using standard library features for IP address validation in both Python and C++. The suggested changes aim to make these utilities more reliable and prevent potential bugs.
387946e to
4dbb21c
Compare
There was a problem hiding this comment.
Here, we are not aiming to provide strict address validation, but rather to mimic the behavior of absl::StrSplit(ipv4_address, ':').
For example, in absl::StrSplit(ipv4_address, ':'):
If the ipv4_address contains a colon (:), it is assumed to be in the ip:port format and is split accordingly.
If the ipv4_address does not contain a colon, it returns [ipv4_address], treating it as an address without a specified port.
Similarly, ParseAddress provides the same behavior for IPv6:
If [2001:db8::1]:8000 is provided, it returns ["2001:db8::1", "8000"].
If 2001:db8::1 or even ::1 is provided, it simply returns ["2001:db8::1"] or ["::1"]
e7fff3f to
74198aa
Compare
0b70d7d to
ffbf2ae
Compare
aslonnie
left a comment
There was a problem hiding this comment.
this is changing a lot of files.. can we split this into smaller PRs and roll out this more incrementally?
The only changes here are:
These changes are intended to be fully backward compatible. |
f00fe94 to
9c73a2c
Compare
jjyao
left a comment
There was a problem hiding this comment.
Thanks for working on this!!
There was a problem hiding this comment.
Can we have a network_util.h|cc file for these?
There was a problem hiding this comment.
Also add docstring for these methods.
There was a problem hiding this comment.
When will we call this function without port?
There was a problem hiding this comment.
This is aim to mimic the behavior of split. For example, we currently have code where the input can be either a plain IP address or an IP address with a port (ip:port).
ray/python/ray/_private/services.py
Lines 592 to 612 in bb50864
There was a problem hiding this comment.
Currently there are two callers of resolve_ip_for_localhost. One pass in ip only and the other pass in ip:port. I'd actually make the function only accepts IP and do the split on the caller side. This makes the code cleaner.
There was a problem hiding this comment.
To make the review easier, could you create a separate PR for this kind of pure format changes?
Could you create a PR with only c++ changes and we can have another one with only python changes, this will make the PR smaller to review. |
Sure! |
9c73a2c to
b37a4a4
Compare
|
I have:
will soon separate the PR into C++ and Python changes and recheck every changes. |
Signed-off-by: Yicheng-Lu-llll <[email protected]>
b37a4a4 to
0c2b34a
Compare
Why are these changes needed?
This is a continuation of the work in #54662 (comment).
Please refer to that discussion for more context
Related issue number
Checks
git commit -s) in this PR.scripts/format.shto lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/under thecorresponding
.rstfile.