Skip to content

[fix] Support IPv6 address#42

Merged
0oshowero0 merged 5 commits into
Ascend:mainfrom
0oshowero0:ipv6
Mar 5, 2026
Merged

[fix] Support IPv6 address#42
0oshowero0 merged 5 commits into
Ascend:mainfrom
0oshowero0:ipv6

Conversation

@0oshowero0

@0oshowero0 0oshowero0 commented Mar 4, 2026

Copy link
Copy Markdown
Collaborator

Support IPv6 environment.

Signed-off-by: 0oshowero0 <o0shower0o@outlook.com>
Copilot AI review requested due to automatic review settings March 4, 2026 13:05
@ascend-robot

Copy link
Copy Markdown

CLA Signature Pass

0oshowero0, thanks for your pull request. All authors of the commits have signed the CLA. 👍

Signed-off-by: 0oshowero0 <o0shower0o@outlook.com>
@ascend-robot

Copy link
Copy Markdown

CLA Signature Pass

0oshowero0, thanks for your pull request. All authors of the commits have signed the CLA. 👍

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to add IPv6 support for TransferQueue’s ZMQ communication by adjusting endpoint formatting and enabling the ZMQ IPv6 socket option where appropriate.

Changes:

  • Added is_ipv6_address() / format_zmq_address() utilities and updated ZMQServerInfo.to_addr() to use them.
  • Extended create_zmq_socket() with an optional ip parameter to enable zmq.IPV6 when needed.
  • Updated several bind/connect endpoints to use bracketed IP formatting.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
transfer_queue/utils/zmq_utils.py Adds IPv6 detection/address formatting helpers and optional IPv6 socket option enabling.
transfer_queue/storage/simple_backend.py Passes node IP into socket creation and updates bind endpoint formatting.
transfer_queue/storage/managers/simple_backend_manager.py Updates storage-unit connect endpoint formatting and passes IP for IPv6 option.
transfer_queue/controller.py Passes node IP into socket creation and updates controller bind endpoints.
transfer_queue/client.py Updates controller connect endpoint formatting and passes IP for IPv6 option.
tests/test_async_simple_storage_manager.py Adds mypy suppression comments on request type usage in tests.
Comments suppressed due to low confidence (2)

transfer_queue/utils/zmq_utils.py:265

  • create_zmq_socket() only enables zmq.IPV6 when callers pass the ip parameter. There are existing call sites that create sockets without ip and then connect via ZMQServerInfo.to_addr(...) (e.g., storage manager handshake), so IPv6 endpoints would still fail. Consider enabling zmq.IPV6 by default (or adding an address/endpoint_ip parameter and using that) so IPv6 support doesn’t depend on every caller being updated.
    if ip is not None and is_ipv6_address(ip):
        socket.setsockopt(zmq.IPV6, 1)

    # Calculate buffer size based on system memory
    total_mem = mem.total / 1024**3
    available_mem = mem.available / 1024**3
    # For systems with substantial memory (>32GB total, >16GB available):
    # - Set a large 0.5GB buffer to improve throughput
    # For systems with less memory:
    # - Use system default (-1) to avoid excessive memory consumption
    if total_mem > 32 and available_mem > 16:
        buf_size = int(0.5 * 1024**3)  # 0.5GB in bytes
    else:
        buf_size = -1  # Use system default buffer size

    if socket_type in (zmq.PULL, zmq.DEALER, zmq.ROUTER):
        socket.setsockopt(zmq.RCVHWM, 0)
        socket.setsockopt(zmq.RCVBUF, buf_size)

    if socket_type in (zmq.PUSH, zmq.DEALER, zmq.ROUTER):

transfer_queue/utils/zmq_utils.py:236

  • New IPv6 formatting logic in is_ipv6_address()/format_zmq_address() isn’t covered by tests. Adding unit tests for both IPv4 (e.g., 127.0.0.1) and IPv6 (e.g., ::1) would prevent regressions and catch invalid endpoint formats early.
def is_ipv6_address(ip: str) -> bool:
    """Check if the given IP address is an IPv6 address."""
    try:
        socket.inet_pton(socket.AF_INET6, ip)
        return True
    except OSError:
        return False


def get_free_port() -> str:
    """Get free port of the host."""
    with socket.socket() as sock:
        sock.bind(("", 0))
        return sock.getsockname()[1]


def create_zmq_socket(
    ctx: zmq.Context,
    socket_type: Any,
    identity: Optional[bytestr] = None,
    ip: Optional[str] = None,
) -> zmq.Socket:
    """Create ZMQ socket.

    Args:

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread transfer_queue/controller.py Outdated
Comment on lines +1585 to +1597
self.handshake_socket = create_zmq_socket(
ctx=self.zmq_context,
socket_type=zmq.ROUTER,
ip=self._node_ip,
)
self.handshake_socket.bind(f"tcp://{self._node_ip}:{self._handshake_socket_port}")
self.handshake_socket.bind(f"tcp://[{self._node_ip}]:{self._handshake_socket_port}")

self.request_handle_socket = create_zmq_socket(
ctx=self.zmq_context,
socket_type=zmq.ROUTER,
ip=self._node_ip,
)
self.request_handle_socket.bind(f"tcp://{self._node_ip}:{self._request_handle_socket_port}")
self.request_handle_socket.bind(f"tcp://[{self._node_ip}]:{self._request_handle_socket_port}")

Copilot AI Mar 4, 2026

Copy link

Choose a reason for hiding this comment

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

The bind endpoint uses tcp://[{self._node_ip}]:..., which will also bracket IPv4 literals. This risks breaking controller startup on typical IPv4-only setups. Use the common address formatter (with IPv6-only bracketing) for these bind endpoints so IPv4 remains tcp://ip:port while IPv6 becomes tcp://[ip]:port.

Copilot uses AI. Check for mistakes.
Comment thread transfer_queue/client.py Outdated
Comment on lines 127 to 130
address = f"tcp://[{server_info.ip}]:{server_info.ports.get(socket_name)}"
identity = f"{self.client_id}_to_{server_info.id}_{uuid4().hex[:8]}".encode()
sock = create_zmq_socket(context, zmq.DEALER, identity=identity)
sock = create_zmq_socket(context, zmq.DEALER, identity=identity, ip=server_info.ip)

Copilot AI Mar 4, 2026

Copy link

Choose a reason for hiding this comment

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

The connect address is built as tcp://[{server_info.ip}]:... unconditionally. If server_info.ip is an IPv4 literal, the brackets can make the endpoint invalid. Use a shared formatter that only adds brackets for IPv6 (or call format_zmq_address(server_info.ip, port)) so IPv4 connections keep working.

Copilot uses AI. Check for mistakes.
Comment on lines 153 to 156
address = f"tcp://[{server_info.ip}]:{server_info.ports.get(socket_name)}"
identity = f"{self.storage_manager_id}_to_{server_info.id}_{uuid4().hex[:8]}".encode()
sock = create_zmq_socket(context, zmq.DEALER, identity=identity)
sock = create_zmq_socket(context, zmq.DEALER, identity=identity, ip=server_info.ip)

Copilot AI Mar 4, 2026

Copy link

Choose a reason for hiding this comment

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

The storage unit connect address is built as tcp://[{server_info.ip}]:... for all IPs. This will likely break IPv4 endpoints (e.g., 127.0.0.1). Prefer using the shared address formatting helper that brackets only IPv6 literals.

Copilot uses AI. Check for mistakes.
Comment thread transfer_queue/utils/zmq_utils.py Outdated
Comment on lines +221 to +236
@@ -220,11 +229,23 @@ def create_zmq_socket(
ctx: zmq.Context,
socket_type: Any,
identity: Optional[bytestr] = None,
ip: Optional[str] = None,
) -> zmq.Socket:
"""Create ZMQ socket."""
"""Create ZMQ socket.

Args:

Copilot AI Mar 4, 2026

Copy link

Choose a reason for hiding this comment

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

format_zmq_address() currently wraps all IPs in brackets (tcp://[{ip}]:{port}). Brackets are required for IPv6 literals but can break IPv4 endpoints (e.g., tcp://[127.0.0.1]:5555). Use is_ipv6_address(ip) (or ipaddress.ip_address) to conditionally format as tcp://{ip}:{port} for IPv4 and tcp://[{ip}]:{port} for IPv6, and update the docstring accordingly.

Copilot uses AI. Check for mistakes.
Comment on lines 214 to 220
self.put_get_socket = create_zmq_socket(self.zmq_context, zmq.ROUTER, ip=self._node_ip)

while True:
try:
self._put_get_socket_port = get_free_port()
self.put_get_socket.bind(f"tcp://{self._node_ip}:{self._put_get_socket_port}")
self.put_get_socket.bind(f"tcp://[{self._node_ip}]:{self._put_get_socket_port}")
break

Copilot AI Mar 4, 2026

Copy link

Choose a reason for hiding this comment

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

Binding with tcp://[{self._node_ip}]:... wraps IPv4 addresses in brackets as well. If _node_ip is an IPv4 literal (common for ray.util.get_node_ip_address()), this can produce an invalid ZMQ endpoint. Prefer using the shared format_zmq_address(self._node_ip, self._put_get_socket_port) (with conditional IPv6 bracketing) for the bind address.

Copilot uses AI. Check for mistakes.
@0oshowero0 0oshowero0 changed the title [fix] Support IPV6 [fix] Support IPv6 address Mar 4, 2026
Signed-off-by: 0oshowero0 <o0shower0o@outlook.com>
@ascend-robot

Copy link
Copy Markdown

CLA Signature Pass

0oshowero0, thanks for your pull request. All authors of the commits have signed the CLA. 👍

Signed-off-by: 0oshowero0 <o0shower0o@outlook.com>
@ascend-robot

Copy link
Copy Markdown

CLA Signature Pass

0oshowero0, thanks for your pull request. All authors of the commits have signed the CLA. 👍

1 similar comment
@ascend-robot

Copy link
Copy Markdown

CLA Signature Pass

0oshowero0, thanks for your pull request. All authors of the commits have signed the CLA. 👍

Signed-off-by: 0oshowero0 <o0shower0o@outlook.com>
@ascend-robot

Copy link
Copy Markdown

CLA Signature Pass

0oshowero0, thanks for your pull request. All authors of the commits have signed the CLA. 👍

@0oshowero0 0oshowero0 merged commit 87d7e13 into Ascend:main Mar 5, 2026
5 checks passed
@0oshowero0 0oshowero0 deleted the ipv6 branch March 20, 2026 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants