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

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

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


##########
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:
   Could we handle normalization failures per entry ? 
   
   For `fe80::1%hadoop-no-such-interface`, `isInetAddress()` returns `true`, 
but `forString()` throws `IllegalArgumentException` because the interface does 
not exist on the local host. 
   
   That exception reaches the outer `catch` in `load()` and discards the entire 
table, so even valid entries fall back to `/default-rack`.
   
   Could we keep the original key when normalization fails and add a regression 
test verifying that the other entries still resolve?
   



##########
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:
   Could we handle normalization failures per entry? 
   
   For `fe80::1%hadoop-no-such-interface`, `isInetAddress()` returns `true`, 
but `forString()` throws `IllegalArgumentException` because the interface does 
not exist on the local host. 
   
   That exception reaches the outer `catch` in `load()` and discards the entire 
table, so even valid entries fall back to `/default-rack`.
   
   Could we keep the original key when normalization fails and add a regression 
test verifying that the other entries still resolve?
   





> 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