smengcl opened a new pull request, #10686:
URL: https://github.com/apache/ozone/pull/10686
Generated-by: Claude Code (Opus 4.8)
## What changes were proposed in this pull request?
Ozone builds Ratis peer address strings by plainly concatenating a host and
port (`host + ":" + port`). When the host is an IPv6 literal (for example
`2001:db8::1`), the result `2001:db8::1:9858` is ambiguous: it cannot be
distinguished from a hostname, and neither Ratis nor gRPC can parse it. IPv6
literals must be wrapped in square brackets when combined with a port, e.g.
`[2001:db8::1]:9858`.
This affects every Ratis transport in Ozone:
- **Datanode pipelines** via `RatisHelper.toRaftPeerAddress` (used for the
`RATIS_SERVER`, `RATIS_ADMIN`, `RATIS`, and `RATIS_DATASTREAM` peer
addresses).
- **OM HA** and **SCM HA** via `NodeDetails.getRatisHostPortStr`
(consumed by `OzoneManagerRatisServer`, `SCMRatisServerImpl`, and
`SCMHAManagerImpl` when calling `RaftPeer.setAddress(...)`).
Ratis itself needs no change: `ratis-grpc` passes the peer address string
verbatim to `NettyChannelBuilder.forTarget(...)`, which accepts the bracketed
`[::1]:port` form, and Ratis's own
`NetUtils.createSocketAddr`/`address2String`
are already IPv6-aware. The defect is purely that Ozone hands Ratis
unbracketed IPv6 strings.
This PR adds a small bracket-aware formatter and routes the two Ratis
peer-address producers through it:
- New `HddsUtils.getHostPortString(String host, int port)`, which delegates
to
Guava's `HostAndPort.fromParts(host, port).toString()`. It brackets bare
and
already-bracketed IPv6 literals, and leaves hostnames and IPv4 literals
untouched. `HddsUtils` already depends on Guava `HostAndPort` (used by the
sibling `getHostPort`), so no new dependency is introduced.
- `RatisHelper.toRaftPeerAddress` and `NodeDetails.getRatisHostPortStr` now
use
the helper instead of raw string concatenation.
Scope note: this PR fixes the Ratis peer-address path only. Other IPv6-unsafe
address handling in Ozone (the `0.0.0.0` bind defaults, the S3G/OFS URI and
admin-CLI colon splitting, and other `host + ":" + port` sites such as
`GrpcOMFailoverProxyProvider`) is tracked separately and is out of scope
here.
## What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-15768
## How was this patch tested?
- Added unit tests
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]