Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sometimes dubbo can choose wrong IP which hangs brave's integration test. #1557

Open
beiwei30 opened this issue Apr 6, 2018 · 3 comments
Open
Labels
type/proposal Everything you want Dubbo have

Comments

@beiwei30
Copy link
Member

beiwei30 commented Apr 6, 2018

Adrian Cole @adriancole mentions on gitter.im:

fyi I noticed sometimes dubbo can choose wrong IP. for example hangs our integration tests openzipkin/brave#680
we use this approach when guessing

       Enumeration<NetworkInterface> nics = NetworkInterface.getNetworkInterfaces();
      if (nics == null) return builder.build();
      while (nics.hasMoreElements()) {
        NetworkInterface nic = nics.nextElement();
        Enumeration<InetAddress> addresses = nic.getInetAddresses();
        while (addresses.hasMoreElements()) {
          InetAddress address = addresses.nextElement();
          if (address.isSiteLocalAddress()) {
            builder.ip(address);
            break;
          }
        }
      }

https://github.com/openzipkin/brave/blob/master/brave/src/main/java/brave/internal/Platform.java#L63
anyway not sure it breaks other people as unit tests are one thing.. production use another

If I debugged right, we were getting this one which accidentally chose docker IP so hung trying to connect https://github.com/apache/incubator-dubbo/blob/master/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/NetUtils.java#L193
but also depends a lot on my network. ex only happens sometimes (I change network a lot)

@chickenlj
Copy link
Contributor

chickenlj commented Apr 12, 2018

Dubbo will try to retrieve ip in the following orders:

  1. outer configurations(e.g., system environment variables)
  2. hosts mapping
  3. guess by traversing the network` interface.
    • the interface that can connect to remote registry.
    • first interface has valid ip address.

As for guessing approach, Dubbo almost uses the same approach as zipkin/brave does: https://github.com/openzipkin/brave/blob/master/brave/src/main/java/brave/internal/Platform.java#L63, except for it does not check if (address.isSiteLocalAddress()) {. I am not sure if site-local addresses: 10/8, 172.16/12 and 192.168/16 the best choice for dubbo.

The deploy environment for dubbo varies, we highly recommend rely on the first two approaches, specifying the ip you want explicitly can be the best way, avoid guessing as it's unpredictable. In a docker environment, bind the docker ip or host ip can depends, leave the choice to users.

@codefromthecrypt
Copy link

codefromthecrypt commented Apr 12, 2018 via email

@chickenlj
Copy link
Contributor

We want people to test dubbo, like do good testing in junit etc. Making a
special flag to allow loopback for test only would be a very nice feature
and avoid all of this. Right now, it is impossible to use loopback in tests
due to production concerns that don't have anything to do with tests.

Good advice, we will take look at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/proposal Everything you want Dubbo have
Projects
None yet
Development

No branches or pull requests

4 participants