[ https://issues.apache.org/jira/browse/HDFS-15380?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ayush Saxena updated HDFS-15380: -------------------------------- Fix Version/s: 3.4.0 Resolution: Fixed Status: Resolved (was: Patch Available) > RBF: Could not fetch real remote IP in RouterWebHdfsMethods > ----------------------------------------------------------- > > Key: HDFS-15380 > URL: https://issues.apache.org/jira/browse/HDFS-15380 > Project: Hadoop HDFS > Issue Type: Bug > Components: webhdfs > Affects Versions: 3.1.0 > Reporter: tomscut > Assignee: tomscut > Priority: Major > Labels: router, webhdfs > Fix For: 3.4.0 > > Attachments: HDFS-15380.001.patch > > Original Estimate: 2h > Remaining Estimate: 2h > > We plan to add audit log for hdfs router, then we fetch remote ip via > Server.getRemoteIp(), but the result is "localhost/127.0.0.1". > > "REMOTE_ADDRESS" in RouterWebHdfsMethods.java is a ThreadLocal field, > setting in construction method RouterWebHdfsMethods() and init(). When we > call method Server.getRemoteIp() to fetch remote ip, the thread would be > changed, so the ThreadLocal field "REMOTE_ADDRESS" is null, and would be > passed to "localhost/127.0.0.1" via InetAddress.getByName(). > > So we can change this field "REMOTE_ADDRESS" to a String value, just like > NamenodeWebHdfsMethods does. > > I printed thread name and the value of "REMOTE_ADDRESS" in log, the log is > shown below: > {code:java} > 2020-05-27 19:15:18,797 INFO router.RouterWebHdfsMethods > (RouterWebHdfsMethods.java:<init>(138)) - RouterWebHdfsMethods > REMOTE_ADDRESS: 14.39.39.28, current thread: qtp476579021-1090 > 2020-05-27 19:15:18,827 INFO router.RouterWebHdfsMethods > (RouterWebHdfsMethods.java:init(150)) - init REMOTE_ADDRESS: 14.39.39.28, > current thread: qtp476579021-1090 > 2020-05-27 19:15:18,836 INFO router.RouterWebHdfsMethods > (RouterWebHdfsMethods.java:getRemoteAddr(170)) - getRemoteAddr > REMOTE_ADDRESS: null, current thread: IPC Server handler 75 on 8888 > 2020-05-27 19:15:18,837 INFO router.RouterWebHdfsMethods > (RouterWebHdfsMethods.java:getRemoteAddr(170)) - getRemoteAddr > REMOTE_ADDRESS: null, current thread: IPC Server handler 75 on 8888 > 2020-05-27 19:15:18,883 INFO router.RouterWebHdfsMethods > (RouterWebHdfsMethods.java:reset(164)) - reset REMOTE_ADDRESS: null, current > thread: IPC Server handler 75 on 8888 > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org