Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-3040

Reverse order of Utils.findLocalIpAddress on UNIX

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Trivial
    • Resolution: Fixed
    • 1.0.2
    • 1.2.0
    • Spark Core
    • None
    • Mac os x, a bunch of network interfaces: eth0, wlan0, vnic0, vnic1, tun0, lo

    Description

      I noticed this inconvenience when I ran spark-shell with my virtual machines on and VPN service running.

      There are a lot of network interfaces on my laptop(inactive devices omitted):

      lo0: inet 127.0.0.1
      en1: inet 192.168.0.102
      vnic0: inet 10.211.55.2 (virtual if for vm1)
      vnic1: inet 10.37.129.3 (virtual if for vm2)
      tun0: inet 172.16.100.191 --> 172.16.100.191 (tun device for VPN)

      In spark core, Utils.findLocalIpAddress() uses NetworkInterface.getNetworkInterfaces to get all active network interfaces, but unfortunately, this method returns network interfaces in reverse order compared to the ifconfig output (both use ioctl sys call). I dug into the openJDK 6 and 7 source code and confirms this behavior(It just happens on unix-like system, windows deals with it and returns in index order). So, the findLocalIpAddress method will pick the ip address associated with tun0 rather than en1

      Attachments

        Activity

          People

            advancedxy YE
            advancedxy YE
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

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