Skip to content

The sdk should auto-detect ipv4 loopback and ipv6 loopback for daprd communication. #218

Description

@LMWF

Expected Behavior

Today the sdk will choose the ipv4 loopback address to contact darpd: 127.0.0.1 (this was changed from "localhost" today). Some users may prefer ipv6 or may operate in an ipv6 only environment. The sdk should automatically detect which one to use: ipv6 or ipv4.

Actual Behavior

Today the sdk will always use the ipv4 loopback address: 127.0.0.1 to connect to daprd.

Activity

  1. yaron2 commented on Feb 6, 2020

    @yaron2
    Member

    Might be better to detect the environment automatically and set the address accordingly. This is a detail the user shouldn't be aware of.

  2. amanbha commented on Feb 6, 2020

    @amanbha
    Contributor

    While reducing the friction because of issues faced by localhost is good. Asking user to provide this ipv4(or ipv6)address is not good solution,
    I agree it should be auto discovered for user.

  3. artursouza commented on Feb 7, 2020

    @artursouza
    Contributor

    @amanbha @yaron2 I agree for auto-detection. It would be interesting to see how the auto-detection can be done without causing delay (waiting for IPV6 connection to fail, for example).

  4. yaron2 commented on Feb 7, 2020

    @yaron2
    Member

    A delay on startup is a non-issue.

  5. artursouza commented on Feb 7, 2020

    @artursouza
    Contributor

    @yaron2 If it is "small", I agree.

  6. yaron2 commented on Feb 7, 2020

    @yaron2
    Member
  7. LMWF commented on Feb 7, 2020

    @LMWF
    ContributorAuthor

    Doesn't it have to use the one daprd is using? Can't daprd be using the ipv6 loopback, and that api returns the ipv4 loopback?

  8. artursouza commented on Feb 7, 2020

    @artursouza
    Contributor

    I thought about it too. If both are present, client must use what dapr is using - which can only be known by trying to connect.

  9. changed the title [-]The sdk should let the user choose between ipv4 loopback and ipv6 loopback for daprd communication.[/-] [+]The sdk should auto-detect ipv4 loopback and ipv6 loopback for daprd communication.[/+] on Feb 13, 2020
  10. added and removed on Mar 18, 2020
  11. willtsai commented on Oct 26, 2021

    @willtsai
    Contributor

    /assign

  12. willtsai commented on Oct 30, 2021

    @willtsai
    Contributor

    I have made an investigation pass into this issue and have the following findings:

    • A constant called SIDECAR_IP has since been added as a part of Refactoring properties and constants. #333, which is implemented to detect the sidecar's IP address by inspecting the system properties via a call to Properties.SIDECAR_IP.get() that looks for the sidecar's IP using this logic: first try to get system property named "dapr.sidecar.ip", if not available try get environment variable named "DAPR_SIDECAR_IP", and if neither is available fallback to "DEFAULT_SIDECAR_IP" which is hardcoded to "127.0.0.1"
    • Given the above, I think that these points that were raised are now already addressed:
      -- "Doesn't it have to use the one daprd is using? Can't daprd be using the ipv6 loopback, and that api returns the ipv4 loopback?"
      -- "If both are present, client must use what dapr is using - which can only be known by trying to connect."

    Thus, I believe the remaining work for this issue would be as follows:

    1. Refactor the source code and tests to change the currently hardcoded "127.0.0.1" to use the value from Properties.SIDECAR_IP.get() instead.
    2. Change the DEFAULT_SIDECAR_IP constant's value from the hardcoded "127.0.0.1" to instead use the Java API getLoopbackAddress that @yaron2 suggested instead. This would make the IP default value more dynamic and account for situations where users operate in an exclusively ipv6 environment and the logic ends up falling back to the default value.

    @artursouza - thoughts on the above? If you think this is the right approach, I can start working on these changes.

  13. artursouza commented on Dec 30, 2021

    @artursouza
    Contributor

    I've just looked at the current code in master for runtime and this is the default behavior of the sidecar:

    • Standalone mode: listen to all addresses
    • K8s mode: listen to [::1],127.0.0.1

    So, this approach is fine as of now. Let's keep it. User can override this setting if he/she decided to override the default listen ports.

  14. willtsai commented on Jan 3, 2022

    @willtsai
    Contributor

    @artursouza - awesome, thanks for looking into this. I'd like to confirm here before proceeding:

    1. Are you saying that the approach of setting DEFAULT_SIDECAR_IP to the loopback address via InetAddress.getLoopbackAddress() is fine?
    2. Or are you thinking we need to set DEFAULT_SIDECAR_IP to the localhost address via InetAddress.getLocalHost()?

    Given the default behavior of the sidecar you've determined, I believe that Option 1 would be the correct approach given that it listens to the loopback addresses in K8s mode. Please let me know if you also agree with Option 1, thanks!

  15. willtsai commented on Jan 26, 2022

    @willtsai
    Contributor

    @artursouza - awesome, thanks for looking into this. I'd like to confirm here before proceeding:

    1. Are you saying that the approach of setting DEFAULT_SIDECAR_IP to the loopback address via InetAddress.getLoopbackAddress() is fine?
    2. Or are you thinking we need to set DEFAULT_SIDECAR_IP to the localhost address via InetAddress.getLocalHost()?

    Given the default behavior of the sidecar you've determined, I believe that Option 1 would be the correct approach given that it listens to the loopback addresses in K8s mode. Please let me know if you also agree with Option 1, thanks!

    Update: After reading your feedback again @artursouza I've gone ahead with Option 1 using InetAddress.getLoopbackAddress() - please see #649 for latest implementation.

  16. added this to the v1.12 milestone on Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions