[ 
https://issues.apache.org/jira/browse/HADOOP-20072?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18140124#comment-18140124
 ] 

ASF GitHub Bot commented on HADOOP-20072:
-----------------------------------------

smengcl commented on code in PR #8957:
URL: https://github.com/apache/hadoop/pull/8957#discussion_r4500042467


##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/TableMapping.java:
##########
@@ -124,6 +125,14 @@ private Map<String, String> load() {
       return loadMap;
     }
   
+    /**
+     * Rewrite an IP literal to the form {@link NetUtils#normalizeHostName} 
gives lookups,
+     * e.g. 2001:db8::10 to 2001:db8:0:0:0:0:0:10. Other keys are kept as 
written.
+     */
+    private static String normalizeIpLiteral(String key) {
+      return InetAddresses.isInetAddress(key) ? 
InetAddresses.forString(key).getHostAddress() : key;

Review Comment:
   Good catch, reproduced. `normalizeIpLiteral` now keeps the key as written 
when `forString` throws, so only that entry stays unnormalized, and 
`testResolveIPv6` adds `fe80::1%hadoop-no-such-interface` and checks the other 
entries still resolve.
   
   _🤖 Addressed by [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
>            Assignee: Siyao Meng
>            Priority: Major
>              Labels: pull-request-available
>
> {{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]

Reply via email to