[ 
https://issues.apache.org/jira/browse/HADOOP-18087?focusedWorklogId=712559&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-712559
 ]

ASF GitHub Bot logged work on HADOOP-18087:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 21/Jan/22 01:36
            Start Date: 21/Jan/22 01:36
    Worklog Time Spent: 10m 
      Work Description: eubnara opened a new pull request #3911:
URL: https://github.com/apache/hadoop/pull/3911


   
   
   <!--
     Thanks for sending a pull request!
       1. If this is your first time, please read our contributor guidelines: 
https://cwiki.apache.org/confluence/display/HADOOP/How+To+Contribute
       2. Make sure your PR title starts with JIRA issue id, e.g., 
'HADOOP-17799. Your PR title ...'.
   -->
   
   ### Description of PR
   
   When query A record which is chained by CNAME, YARN Registry DNS Server does 
not properly respond. Some CNAME records are missing.
   
   For example, "repo.maven.apache.org" is chaned as follows:
   
   repo.maven.apache.org.       21317   IN      CNAME   repo.apache.maven.org.
   repo.apache.maven.org.       20114   IN      CNAME   maven.map.fastly.net.
   maven.map.fastly.net.        7       IN      A       199.232.192.215
   maven.map.fastly.net.        7       IN      A       199.232.196.215
   
   If ask A record for "repo.maven.apache.org" using "dig" or "nslookup", YARN 
Registry DNS Server will give answers similar to this:
   (10.1.2.3, 10.8.8.8 IP is virtual)
   
   
   ```
   $ nslookup repo.maven.apache.org 10.1.2.3
   Server:              10.1.2.3
   Address:     10.1.2.3#53
   
   Non-authoritative answer:
   repo.maven.apache.org        canonical name = repo.apache.maven.org.
   Name:        maven.map.fastly.net
   Address: 151.101.196.215
   ** server can't find repo.apache.maven.org: NXDOMAIN
   ```
   
   The reason why you can see "NXDOMAIN", "nslookup" will query "A" & "AAAA" 
records.
   If there is no answer from other dns server, "answers == null" but YARN 
Registry DNS Server has a bug. There is no null handling.
   
   
   ```java
       // Forward lookup to primary DNS servers
       Record[] answers = getRecords(name, type);
       try {
         for (Record r : answers) {
           if (!response.findRecord(r)) {
             if (r.getType() == Type.SOA) {
               response.addRecord(r, Section.AUTHORITY);
             } else {
               response.addRecord(r, Section.ANSWER);
             }
           }
           if (r.getType() == Type.CNAME) {
             Name cname = r.getName();
             if (iterations < 6) {
               remoteLookup(response, cname, type, iterations + 1);
             }
           }
         }
       } catch (NullPointerException e) {
         return Rcode.NXDOMAIN;
       } catch (Throwable e) {
         return Rcode.SERVFAIL;
       }
       return Rcode.NOERROR;
   ```
   
   
   
   
   
   It should be like this:
   
   ```
   nslookup repo.maven.apache.org 10.8.8.8
   Server:              10.8.8.8
   Address:     10.8.8.8#53
   
   Non-authoritative answer:
   repo.maven.apache.org        canonical name = repo.apache.maven.org.
   repo.apache.maven.org        canonical name = maven.map.fastly.net.
   Name:        maven.map.fastly.net
   Address: 151.101.196.215
   ```
   
   
   
   ### How was this patch tested?
   
   - apply this patch to YARN Registry DNS Server in our cluster & test with 
`dig` and `nslookup`
   
   ### 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?
   
   


-- 
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: common-issues-unsubscr...@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

            Worklog Id:     (was: 712559)
    Remaining Estimate: 0h
            Time Spent: 10m

> fix bug when getting CNAME chain records and no record from remote dns server
> -----------------------------------------------------------------------------
>
>                 Key: HADOOP-18087
>                 URL: https://issues.apache.org/jira/browse/HADOOP-18087
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: registry
>    Affects Versions: 3.1.2
>            Reporter: YUBI LEE
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> When query A record which is chained by CNAME, YARN Registry DNS Server does 
> not properly respond. Some CNAME records are missing.
> For example, "repo.maven.apache.org" is chaned as follows:
> repo.maven.apache.org.        21317   IN      CNAME   repo.apache.maven.org.
> repo.apache.maven.org.        20114   IN      CNAME   maven.map.fastly.net.
> maven.map.fastly.net. 7       IN      A       199.232.192.215
> maven.map.fastly.net. 7       IN      A       199.232.196.215
> If ask A record for "repo.maven.apache.org" using "dig" or "nslookup", YARN 
> Registry DNS Server will give answers similar to this:
> (10.1.2.3, 10.8.8.8 IP is virtual)
> {code}
> $ nslookup repo.maven.apache.org 10.1.2.3
> Server:               10.1.2.3
> Address:      10.1.2.3#53
> Non-authoritative answer:
> repo.maven.apache.org canonical name = repo.apache.maven.org.
> Name: maven.map.fastly.net
> Address: 151.101.196.215
> ** server can't find repo.apache.maven.org: NXDOMAIN
> {code}
> The reason why you can see "NXDOMAIN", "nslookup" will query "A" & "AAAA" 
> records.
> If there is no answer from other dns server, "answers == null" but YARN 
> Registry DNS Server has a bug. There is no null handling.
> {code:java}
>     // Forward lookup to primary DNS servers
>     Record[] answers = getRecords(name, type);
>     try {
>       for (Record r : answers) {
>         if (!response.findRecord(r)) {
>           if (r.getType() == Type.SOA) {
>             response.addRecord(r, Section.AUTHORITY);
>           } else {
>             response.addRecord(r, Section.ANSWER);
>           }
>         }
>         if (r.getType() == Type.CNAME) {
>           Name cname = r.getName();
>           if (iterations < 6) {
>             remoteLookup(response, cname, type, iterations + 1);
>           }
>         }
>       }
>     } catch (NullPointerException e) {
>       return Rcode.NXDOMAIN;
>     } catch (Throwable e) {
>       return Rcode.SERVFAIL;
>     }
>     return Rcode.NOERROR;
> {code}
> It should be like this:
> {code}
> nslookup repo.maven.apache.org 10.8.8.8
> Server:               10.8.8.8
> Address:      10.8.8.8#53
> Non-authoritative answer:
> repo.maven.apache.org canonical name = repo.apache.maven.org.
> repo.apache.maven.org canonical name = maven.map.fastly.net.
> Name: maven.map.fastly.net
> Address: 151.101.196.215
> {code}
> I will make a pull request at https://github.com/apache/hadoop soon.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org

Reply via email to