[
https://issues.apache.org/jira/browse/HADOOP-20072?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18139824#comment-18139824
]
ASF GitHub Bot commented on HADOOP-20072:
-----------------------------------------
smengcl opened a new pull request, #8957:
URL: https://github.com/apache/hadoop/pull/8957
Generated-by: Claude Code (Opus 5.5)
JIRA: https://issues.apache.org/jira/browse/HADOOP-20072
### Description of PR
`CachedDNSToSwitchMapping` normalizes every name with
`NetUtils.normalizeHostName`, which gives the full IPv6 form without zero
compression (`2001:db8:0:0:0:0:0:10`). `TableMapping` then does an exact string
lookup against the keys as written in the table file, so an entry in the usual
compressed form (`2001:db8::10`) or with uppercase hex never matched, and the
node fell back to `/default-rack`.
`RawTableMapping#load` now rewrites keys that are IP literals to that same
form with Guava `InetAddresses` (no DNS lookup). Host name keys are kept as
written. IPv4 literals and lowercase full form IPv6 keys map to themselves, so
tables that work today behave the same.
### How was this patch tested?
- `TestTableMapping#testResolveIPv6` (new): compressed and uppercase IPv6
entries resolve for both compressed and full form names, an IPv6 address not in
the table gets `/default-rack`, and an IPv4 entry still resolves. Fails on
trunk, passes with the fix.
- `TestTableMapping`, `TestStaticMapping`, `TestScriptBasedMapping` and
`TestScriptBasedMappingWithDependency` pass.
### For code changes:
- [x] Does the title or this PR starts with the corresponding JIRA issue id
(e.g. 'HADOOP-17799. Your PR title ...')?
- [ ] Object storage: have the integration tests been executed and the
endpoint declared according to the connector-specific documentation?
- [ ] If adding new dependencies to the code, are these dependencies
licensed in a way that is compatible for inclusion under [ASF
2.0](http://www.apache.org/legal/resolved.html#category-a)?
- [ ] If applicable, have you updated the `LICENSE`, `LICENSE-binary`,
`NOTICE-binary` files?
🤖 Generated with [Claude Code](https://claude.com/claude-code)
> TableMapping never matches IPv6 entries written in compressed form
> ------------------------------------------------------------------
>
> Key: HADOOP-20072
> URL: https://issues.apache.org/jira/browse/HADOOP-20072
> Project: Hadoop Common
> Issue Type: Sub-task
> Components: net
> Reporter: Siyao Meng
> Priority: Major
>
> {{CachedDNSToSwitchMapping#resolve}} normalizes every name with
> {{NetUtils.normalizeHostName}}, which returns {{InetAddress#getHostAddress}}.
> For IPv6 that is the full form without zero compression, for example
> {{2001:db8:0:0:0:0:0:10}}. {{TableMapping}} then looks the name up with an
> exact string match ({{RawTableMapping#resolve}}), and its keys are kept
> exactly as written in the table file.
> So an entry in the usual compressed form ([RFC
> 5952|https://datatracker.ietf.org/doc/html/rfc5952]), such as
> {{2001:db8::10}}, never matches, whichever form the caller passes. The node
> quietly falls back to {{/default-rack}}. Only the full form works.
> h3. Reproduction (3.4.3)
> Table file:
> {noformat}
> 2001:db8::10 /rack1
> 10.0.0.5 /rack2
> {noformat}
> {code:java}
> tableMapping.resolve(Arrays.asList("2001:db8::10", "2001:db8:0:0:0:0:0:10",
> "10.0.0.5"));
> // [/default-rack, /default-rack, /rack2]
> {code}
> With {{2001:db8:0:0:0:0:0:10 /rack1}} in the file instead, the first two
> resolve to {{/rack1}}.
> h3. Impact
> Rack awareness for nodes registered by IPv6 address: HDFS datanodes, and
> Ozone datanodes and clients (SCM and OM resolve through the same mapping).
> {{ScriptBasedMapping}} passes the same full form to the topology script, so
> scripts have to expect it too.
> h3. Proposal
> When loading the table in {{RawTableMapping#load}}, normalize keys that are
> IP literals to the same form the lookup uses (for example
> {{InetAddresses.forString(key).getHostAddress()}}), without DNS lookups.
> Leave other keys as they are. Add a test with compressed and full-form IPv6
> entries.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]