HDDS-15773. Make HddsUtils host:port helpers IPv6-safe#10804
Open
chihsuan wants to merge 4 commits into
Open
Conversation
chihsuan
marked this pull request as draft
July 18, 2026 06:53
chihsuan
marked this pull request as ready for review
July 18, 2026 06:55
adoroszlai
reviewed
Jul 18, 2026
adoroszlai
left a comment
Contributor
There was a problem hiding this comment.
Thanks @chihsuan for the patch. Functionality LGTM. Please reduce duplication in test.
Comment on lines
+182
to
+187
| final OzoneConfiguration conf = new OzoneConfiguration(); | ||
| conf.set(OZONE_SCM_CLIENT_ADDRESS_KEY, "2001:db8::1"); | ||
| InetSocketAddress addr = | ||
| HddsUtils.getScmAddressForClients(conf).iterator().next(); | ||
| assertEquals("2001:db8:0:0:0:0:0:1", addr.getHostString()); | ||
| assertEquals(OZONE_SCM_CLIENT_PORT_DEFAULT, addr.getPort()); |
Contributor
There was a problem hiding this comment.
Please extract a helper method for single test case:
testClientAddress(String clientAddressConfig, String expectedHost, int expectedPort)to avoid duplicated boilerplate.
Contributor
Author
There was a problem hiding this comment.
Thanks for the review! Addressed in 1fc02f7.
adoroszlai
approved these changes
Jul 18, 2026
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.
What changes were proposed in this pull request?
This change makes
HddsUtilshost:port handling IPv6-safe.getHostName()previously removed a trailing:portwith a regex. This left brackets in[::1]:9862and corrupted bare IPv6 literals such as::1or2001:db8::1.getScmAddressForClients()then rebuilt addresses usinghost + ":" + port, which creates an ambiguous address for IPv6 hosts.This patch:
HostAndPortingetHostName(), matching the adjacentgetHostPort()helper and returning unbracketed IPv6 hosts.getHostPortString()to rebuild SCM client addresses, producing valid bracketed IPv6 addresses such as[2001:db8::1]:9860.HddsUtils.format(List<String>)method. It has no repository callers and parses role strings with IPv6-unsafe fixed-colon splitting.Malformed host:port inputs, including
a:b,host:99999, and unbracketed IPv6-with-port values, now throwIllegalArgumentException. This matchesgetHostPort()and the documented contract ofgetHostNameFromConfigKeys().The fixed-index role parsing in
StorageContainerManager#getScmRatisRoles()(HDDS-15774) and theServerNotLeaderExceptionsuggested-leader flow (HDDS-15895) remain out of scope and require separate follow-up changes.What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-15773
How was this patch tested?
TestHddsUtils#testGetHostNamecoverage for bracketed and bare IPv6 literals, IPv6 without a port, and malformed input.TestHddsClientUtilscoverage for IPv6 SCM client addresses and theozone.scm.namesfallback path.TestHddsUtilsand TestHddsClientUtilsruns pass; hdds-common module unit tests pass (404 tests, 0 failures).checkstyle.sh, rat.sh, and author.shpass locally; fullmvn clean install -DskipTestssucceeds.Generated-by: Claude Code (Opus 4.8)