Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-15380

RBF: Could not fetch real remote IP in RouterWebHdfsMethods

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.1.0
    • 3.3.1, 3.4.0
    • webhdfs
    • Reviewed
    • Patch, Important

    Description

      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:

      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
      

      Attachments

        1. HDFS-15380.001.patch
          2 kB
          Tao Li

        Issue Links

          Activity

            People

              tomscut Tao Li
              tomscut Tao Li
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 2h
                  2h
                  Remaining:
                  Remaining Estimate - 2h
                  2h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified