Skip to content

Support IPv6 endpoint URLs#18162

Open
HTHou wants to merge 1 commit into
masterfrom
codex/ipv6-endpoint-support
Open

Support IPv6 endpoint URLs#18162
HTHou wants to merge 1 commit into
masterfrom
codex/ipv6-endpoint-support

Conversation

@HTHou

@HTHou HTHou commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Description

This PR improves IPv6 endpoint handling across IoTDB by centralizing endpoint formatting/parsing and using bracketed IPv6 URLs where a port is appended.

  • Add [ipv6]:port formatting/parsing in shared UrlUtils, while keeping legacy naked IPv6 endpoint strings such as ::1:10710 readable.
  • Reuse the shared endpoint formatter in Ratis peer addresses, node URL utilities, Session/JDBC clients, pipe sink displays, metrics URLs, and integration-test environment helpers.
  • Add Python Session and AINode parsing/formatting support for bracketed IPv6 endpoints.
  • Treat IPv4 and IPv6 wildcard addresses as non-connectable remote endpoints in Java, Python, and C++ client-side refresh/redirection paths.
  • Add real IPv6 loopback ITs for Java JDBC/Session/TableSession clients and a 1C3D cluster using SchemaRegion Ratis plus DataRegion IoTConsensus.
  • Add regression tests for bracketed IPv6 URLs and malformed inputs like [::1]6667, [::1]:, [::1:6667, []:123, and stray brackets in non-bracketed endpoints.

Coverage

Area Previous gap Added in this PR
Shared endpoint utilities Endpoint parsing used the last colon for some IPv6 cases, but there was no canonical formatter for appending ports to IPv6 literals. Add shared [ipv6]:port formatting and parsing in UrlUtils, while preserving legacy naked IPv6 parsing such as ::1:10710.
Wildcard/bind-all addresses Java, Python, and C++ client-side node refresh/redirection paths only skipped 0.0.0.0; IPv6 wildcard addresses such as :: or [::] could still be treated as connectable remote endpoints. Add wildcard-address detection for 0.0.0.0, ::, bracketed ::, and expanded IPv6 zero forms, then reuse it in Java NodesSupplier, Java Session redirection, Python Session redirection, C++ NodesSupplier, and C++ Session redirection.
Ratis peer addresses Ratis addresses were built with host:port and parsed with split(":"), which breaks IPv6 peer addresses. Use shared endpoint utilities for Ratis peer address generation/parsing and add IPv4, hostname, IPv6, legacy IPv6, and malformed-input tests.
Java clients and node URLs Session/JDBC/node URL paths had inconsistent IPv6 handling and could accept malformed bracketed IPv6 forms. Support bracketed IPv6 in JDBC and Session-facing endpoint strings, centralize NodeUrlUtils formatting, and reject malformed bracketed URLs.
Python Session and AINode Python Session node_urls used simple colon splitting; AINode config/client paths did not consistently handle bracketed IPv6. Add Python parsers for [ipv6]:port and legacy IPv6 endpoint strings, plus AINode endpoint formatting for downstream Session/TableSession usage.
Integration-test runtime helpers Cluster node wrappers always advertised 127.0.0.1, so ITs could not start real ConfigNode/DataNode endpoints on IPv6 loopback. Add IoTDBTestNodeAddress for tests to override node bind/advertise addresses, plus an IPv6 loopback availability helper that skips cleanly when ::1 is unavailable.
Runtime IPv6 client IT Existing tests covered parser utilities but did not prove JDBC, Session, or TableSession could connect to an actual IoTDB node through [::1]:port. Add IoTDBIPv6ClientIT, which starts 1C1D on ::1 and verifies JDBC, direct Session node URLs, default env Session, and TableSession write/query paths.
Runtime IPv6 cluster IT Existing tests did not prove internal cluster endpoints, ConfigNode showCluster, schema consensus endpoints, data consensus endpoints, and query traffic all work with IPv6. Add IoTDBIPv6ClusterIT, which starts 1C3D on ::1, verifies every advertised ConfigNode/DataNode endpoint uses IPv6, and writes/queries data with SchemaRegion Ratis and DataRegion IoTConsensus.
Configuration docs Endpoint examples did not clearly document bracketed IPv6 notation where ports are appended. Update ConfigNode/DataNode and AINode config comments with IPv4, hostname, and [ipv6]:port examples.
Regression coverage There were no tests for malformed bracketed IPv6 endpoint strings, empty bracketed hosts, IPv6 wildcard filtering, or real IPv6 loopback runtime behavior. Add regression tests for [::1]6667, [::1]:, [::1:6667, []:123, stray brackets, wildcard address detection in Java/Python parsing paths, and real Java client/cluster IPv6 ITs.

Tests

  • mvn test -pl iotdb-client/service-rpc,iotdb-client/jdbc,iotdb-client/session -am -Dtest=UrlUtilsTest,UtilsTest,SessionUtilsTest -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false
  • mvn test -pl iotdb-client/service-rpc -am -Dtest=UrlUtilsTest -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false
  • mvn test -pl iotdb-core/node-commons -am -Dtest=NodeUrlUtilsTest -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false
  • mvn test -pl iotdb-core/consensus -am -Dtest=UtilsTest -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false
  • mvn spotless:apply -pl iotdb-client/service-rpc -am -DskipTests
  • mvn spotless:apply -pl integration-test -am -P with-integration-tests -DskipTests
  • mvn test-compile -pl integration-test -am -P with-integration-tests -DskipTests
  • mvn verify -DskipUTs -Dit.test=IoTDBIPv6ClientIT -DfailIfNoTests=false -Dfailsafe.failIfNoSpecifiedTests=false -pl integration-test -am -P with-integration-tests
  • mvn verify -DskipUTs -Dit.test=IoTDBIPv6ClusterIT -DfailIfNoTests=false -Dfailsafe.failIfNoSpecifiedTests=false -pl integration-test -am -PClusterIT -P with-integration-tests
  • mvn spotless:apply -pl iotdb-client/client-cpp -am -P with-cpp,spotless-cpp -DskipTests
  • mvn compile -pl iotdb-client/client-cpp -am -P with-cpp -DskipTests
  • cd iotdb-client/client-py && python3 -m pytest tests/unit/test_session_node_url.py
  • cd iotdb-core/ainode && python3 -m unittest discover -s tests
  • python3 -m black iotdb-core/ainode/iotdb/ainode/core/config.py iotdb-core/ainode/tests/test_config.py
  • PYTHONPATH=/tmp/codex-isort-6.0.1 python3 -m isort --profile black iotdb-core/ainode/iotdb/ainode/core/config.py iotdb-core/ainode/tests/test_config.py
  • python3 -m black --check iotdb-client/client-py/iotdb/Session.py iotdb-client/client-py/tests/unit/test_session_node_url.py iotdb-core/ainode/iotdb/ainode/core/config.py iotdb-core/ainode/iotdb/ainode/core/ingress/iotdb.py
  • PYTHONPATH=/tmp/codex-isort-6.0.1 python3 -m isort --profile black --check-only iotdb-client/client-py/iotdb/Session.py iotdb-client/client-py/tests/unit/test_session_node_url.py iotdb-core/ainode/iotdb/ainode/core/config.py iotdb-core/ainode/iotdb/ainode/core/ingress/iotdb.py
  • python3 -m py_compile iotdb-core/ainode/iotdb/ainode/core/config.py iotdb-core/ainode/iotdb/ainode/core/ingress/iotdb.py
  • python3 -m py_compile iotdb-core/ainode/iotdb/ainode/core/config.py iotdb-core/ainode/tests/test_config.py
  • rg -n --fixed-strings "0.0.0.0" --glob '!**/target/**' --glob '!**/.git/**'
  • git diff --check

@HTHou HTHou force-pushed the codex/ipv6-endpoint-support branch 2 times, most recently from 21dc1a9 to 4f65a99 Compare July 9, 2026 04:06
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.41975% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 41.92%. Comparing base (f3e1612) to head (e8bdb6c).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
...dbc/src/main/java/org/apache/iotdb/jdbc/Utils.java 91.42% 3 Missing ⚠️
...c/src/main/java/org/apache/iotdb/rpc/UrlUtils.java 90.00% 3 Missing ⚠️
...ava/org/apache/iotdb/session/pool/SessionPool.java 33.33% 2 Missing ⚠️
...n/java/org/apache/iotdb/session/NodesSupplier.java 0.00% 1 Missing ⚠️
...rotocol/thrift/async/IoTDBDataRegionAsyncSink.java 0.00% 1 Missing ⚠️
.../plan/execution/config/sys/TestConnectionTask.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #18162      +/-   ##
============================================
+ Coverage     41.77%   41.92%   +0.15%     
  Complexity      318      318              
============================================
  Files          5297     5298       +1     
  Lines        374235   374564     +329     
  Branches      48313    48386      +73     
============================================
+ Hits         156326   157040     +714     
+ Misses       217909   217524     -385     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@HTHou HTHou force-pushed the codex/ipv6-endpoint-support branch from 4f65a99 to e8bdb6c Compare July 9, 2026 05:34
@HTHou HTHou requested a review from Copilot July 9, 2026 07:08

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 strengthens IPv6 endpoint support across Apache IoTDB by centralizing canonical endpoint formatting/parsing (notably [ipv6]:port) and reusing it consistently throughout server, clients, and tests, including handling wildcard/bind-all addresses correctly.

Changes:

  • Centralize endpoint URL formatting/parsing via shared UrlUtils and reuse it across node URL utilities, Ratis peer addressing, client redirection/refresh paths, pipe sink displays, and metrics URLs.
  • Extend Java/JDBC, Python, and C++ clients to support bracketed IPv6 endpoint URLs and to treat IPv4/IPv6 wildcard addresses as non-connectable remote endpoints.
  • Add integration and unit tests validating IPv6 loopback connectivity, malformed bracketed forms, and IPv6 cluster behavior.

Reviewed changes

Copilot reviewed 35 out of 35 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/utils/NodeUrlUtilsTest.java Adds assertions validating canonical bracketed IPv6 formatting in node URL conversions.
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/NodeUrlUtils.java Switches endpoint URL conversion/parsing to shared UrlUtils for IPv6-safe formatting.
iotdb-core/node-commons/src/assembly/resources/conf/iotdb-system.properties.template Updates config comments to document [ipv6]:port examples and hostname support.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java Uses shared endpoint formatter for displaying endpoints in test-connection output.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/thrift/async/IoTDBDataRegionAsyncSink.java Uses shared endpoint formatter to render endpoints (incl. IPv6) safely.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/client/IoTDBDataNodeAsyncClientManager.java Uses shared endpoint formatter to generate stable resource keys for endpoints.
iotdb-core/consensus/src/test/java/org/apache/iotdb/consensus/ratis/utils/UtilsTest.java Adds round-trip and malformed-input tests for Ratis peer address parsing/formatting with IPv6.
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/utils/Utils.java Replaces split(":") parsing/formatting with shared IPv6-safe endpoint utilities.
iotdb-core/ainode/resources/conf/iotdb-ainode.properties Documents bracketed IPv6 endpoint configuration and hostname support.
iotdb-core/ainode/iotdb/ainode/core/ingress/iotdb.py Adds endpoint formatting helper to produce bracketed IPv6 node URLs for downstream clients.
iotdb-core/ainode/iotdb/ainode/core/config.py Adds bracketed IPv6 parsing support for endpoint URLs in AINode config loading.
iotdb-client/session/src/main/java/org/apache/iotdb/session/SessionConnection.java Uses shared endpoint formatter when building reconnection failure messages.
iotdb-client/session/src/main/java/org/apache/iotdb/session/Session.java Treats wildcard IPv4/IPv6 addresses as non-connectable during redirection handling.
iotdb-client/session/src/main/java/org/apache/iotdb/session/pool/SessionPool.java Formats initial node URLs using IPv6-safe shared formatter.
iotdb-client/session/src/main/java/org/apache/iotdb/session/NodesSupplier.java Skips wildcard IPv4/IPv6 addresses when refreshing available nodes.
iotdb-client/service-rpc/src/test/java/org/apache/iotdb/rpc/UrlUtilsTest.java Adds tests for bracketed IPv6 conversion/parsing and wildcard detection.
iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/UrlUtils.java Introduces canonical [ipv6]:port formatting/parsing and wildcard-address detection.
iotdb-client/jdbc/src/test/java/org/apache/iotdb/jdbc/UtilsTest.java Adds JDBC URL parsing tests for bracketed IPv6 (including SSL query params) and malformed inputs.
iotdb-client/jdbc/src/main/java/org/apache/iotdb/jdbc/Utils.java Updates JDBC URL parsing to correctly handle bracketed IPv6 host/port.
iotdb-client/client-py/tests/unit/test_session_node_url.py Adds Python unit tests for bracketed/legacy IPv6 parsing and wildcard detection.
iotdb-client/client-py/iotdb/Session.py Adds IPv6-aware endpoint parsing and wildcard-address filtering for redirection.
iotdb-client/client-cpp/src/session/Session.cpp Treats wildcard IPv4/IPv6 addresses as non-connectable during redirection handling.
iotdb-client/client-cpp/src/rpc/RpcCommon.h Declares wildcard-address detection utility for C++ client.
iotdb-client/client-cpp/src/rpc/RpcCommon.cpp Implements wildcard-address detection for IPv4/IPv6 (including bracketed form).
iotdb-client/client-cpp/src/rpc/NodesSupplier.cpp Skips wildcard IPv4/IPv6 addresses when refreshing available nodes.
integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBIPv6ClientIT.java Adds runtime IT proving JDBC/Session/TableSession connectivity via [::1]:port.
integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/treemodel/auto/enhanced/IoTDBPipeClusterIT.java Uses IPv6-safe getIpAndPortString() when building endpoint lists in tests.
integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/tablemodel/manual/enhanced/IoTDBPipeClusterIT.java Uses IPv6-safe getIpAndPortString() when building endpoint lists in tests.
integration-test/src/test/java/org/apache/iotdb/it/utils/IPv6TestUtils.java Adds helper to detect IPv6 loopback availability and configure tests to bind to ::1.
integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBIPv6ClusterIT.java Adds runtime IT proving 1C3D cluster internal/external endpoints work over IPv6 loopback.
integration-test/src/test/java/org/apache/iotdb/db/it/iotconsensusv2/IoTDBIoTConsensusV23C3DBasicITBase.java Updates logs/metrics URLs to use IPv6-safe host formatting.
integration-test/src/main/java/org/apache/iotdb/it/env/remote/env/RemoteServerEnv.java Uses shared endpoint formatter for remote env metrics/JDBC/session URLs.
integration-test/src/main/java/org/apache/iotdb/it/env/cluster/node/AbstractNodeWrapper.java Allows overriding node bind/advertise address via system property and returns IPv6-safe ip:port.
integration-test/src/main/java/org/apache/iotdb/it/env/cluster/env/AbstractEnv.java Uses shared endpoint formatter for metrics URLs and avoids split(":") on IPv6 endpoints.
integration-test/src/main/java/org/apache/iotdb/it/env/cluster/ClusterConstant.java Adds constant for integration-test node-address override property.

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

Comment thread iotdb-core/ainode/iotdb/ainode/core/config.py
@HTHou HTHou force-pushed the codex/ipv6-endpoint-support branch from e8bdb6c to 6d78598 Compare July 9, 2026 07:35
@HTHou HTHou requested a review from Copilot July 9, 2026 07:40

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

Copilot reviewed 35 out of 35 changed files in this pull request and generated 3 comments.

Comment thread iotdb-core/ainode/iotdb/ainode/core/config.py
Comment thread iotdb-core/ainode/iotdb/ainode/core/config.py
@HTHou HTHou force-pushed the codex/ipv6-endpoint-support branch from 6d78598 to 8f84bea Compare July 9, 2026 08:08
@sonarqubecloud

sonarqubecloud Bot commented Jul 9, 2026

Copy link
Copy Markdown

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

Copilot reviewed 36 out of 36 changed files in this pull request and generated no new comments.

@HTHou HTHou marked this pull request as ready for review July 10, 2026 02:14
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.

2 participants