Change "127.0.0.1" to SIDECAR_IP to dynamically account for IPv4 vs. IPv6 environments#649
Conversation
|
@artursouza Wasn't there was a particular reason why 127.0.0.1 was used instead of localhost? |
@mukundansundar according to #213, it was changed from localhost to 127.0.0.1 "to avoid local OS specific DNS lookups that might hinder performance". My changes here don't reintroduce the use of |
|
Work in progress, please do not merge |
Signed-off-by: Will Tsai <william.wl.tsai@gmail.com>
* Upgrade okhttp-mock dependency Version 1.3.2 was never deployed to Maven Central * No longer refer to JCenter, as it has been shut down Signed-off-by: Will Tsai <william.wl.tsai@gmail.com>
Signed-off-by: Will Tsai <william.wl.tsai@gmail.com>
Signed-off-by: Will Tsai <william.wl.tsai@gmail.com>
Signed-off-by: Will Tsai <william.wl.tsai@gmail.com>
Signed-off-by: Will Tsai <william.wl.tsai@gmail.com>
Signed-off-by: Will Tsai <william.wl.tsai@gmail.com>
Signed-off-by: Will Tsai <william.wl.tsai@gmail.com>
Signed-off-by: Will Tsai <william.wl.tsai@gmail.com>
Bumps [actions/setup-java](https://github.com/actions/setup-java) from 2.3.1 to 2.4.0. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](actions/setup-java@v2.3.1...v2.4.0) --- updated-dependencies: - dependency-name: actions/setup-java dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: Will Tsai <william.wl.tsai@gmail.com>
Signed-off-by: Will Tsai <william.wl.tsai@gmail.com>
Signed-off-by: Will Tsai <william.wl.tsai@gmail.com>
Signed-off-by: Will Tsai <william.wl.tsai@gmail.com>
Signed-off-by: Will Tsai <william.wl.tsai@gmail.com>
* Upgrade Dapr CLI and runtime. Signed-off-by: Artur Souza <artursouza.ms@outlook.com> * Fix expected vault output. Signed-off-by: Artur Souza <artursouza.ms@outlook.com> Signed-off-by: Will Tsai <william.wl.tsai@gmail.com>
* Update LICENSE to Apache 2.0 Signed-off-by: Artur Souza <artursouza.ms@outlook.com> * Update headers to Apache 2. Signed-off-by: Artur Souza <artursouza.ms@outlook.com> Co-authored-by: Artur Souza <artursouza.ms@outlook.com> Signed-off-by: Will Tsai <william.wl.tsai@gmail.com>
Bumps [actions/github-script](https://github.com/actions/github-script) from 1 to 5. - [Release notes](https://github.com/actions/github-script/releases) - [Commits](actions/github-script@v1...v5) --- updated-dependencies: - dependency-name: actions/github-script dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: Will Tsai <william.wl.tsai@gmail.com>
Issue reference: dapr/docs#2039 Signed-off-by: Will <william.wl.tsai@gmail.com> Signed-off-by: Will Tsai <william.wl.tsai@gmail.com>
Bumps [actions/setup-java](https://github.com/actions/setup-java) from 2.4.0 to 2.5.0. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](actions/setup-java@v2.4.0...v2.5.0) --- updated-dependencies: - dependency-name: actions/setup-java dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Artur Souza <artursouza.ms@outlook.com> Signed-off-by: Will Tsai <william.wl.tsai@gmail.com>
* inital draft for config api Signed-off-by: Pravin Pushkar <ppushkar@microsoft.com> * Introducing new client for preview apis and code refactoring Signed-off-by: Pravin Pushkar <ppushkar@microsoft.com> * Unit tests and code refactoring Signed-off-by: Pravin Pushkar <ppushkar@microsoft.com> * Adding integration test Signed-off-by: pravinpushkar <ppushkar@microsoft.com> * Copyright changes Signed-off-by: pravinpushkar <ppushkar@microsoft.com> * Review comments fixes Signed-off-by: pravinpushkar <ppushkar@microsoft.com> * Removed DaprPreviewClientProxy and updated example README Signed-off-by: pravinpushkar <ppushkar@microsoft.com> * Adding validate workflow for cofiguration api example Signed-off-by: pravinpushkar <ppushkar@microsoft.com> * fixing example autovalidation and code coverage Signed-off-by: pravinpushkar <ppushkar@microsoft.com> * Fixing autovalidation and removing getAllConfiguration Signed-off-by: pravinpushkar <ppushkar@microsoft.com> * Fixing review comments Signed-off-by: pravinpushkar <ppushkar@microsoft.com> * Add regex header checkstyle. Signed-off-by: Artur Souza <artursouza.ms@outlook.com> * Fix headers and add javadocs to some. Signed-off-by: Artur Souza <artursouza.ms@outlook.com> Co-authored-by: Artur Souza <artursouza.ms@outlook.com> Signed-off-by: Will Tsai <william.wl.tsai@gmail.com>
artursouza
left a comment
There was a problem hiding this comment.
I will give another pass tomorrow. Thanks.
Signed-off-by: Will Tsai <william.wl.tsai@gmail.com>
| * @return The loopback address String | ||
| */ | ||
| public static String getHostLoopbackAddress() { | ||
| return InetAddress.getLoopbackAddress().getHostAddress(); |
There was a problem hiding this comment.
Can this method automatically return the Ipv6 between "[]"?
There was a problem hiding this comment.
@artursouza Sorry for the delay, finally had some time to look into this. I changed some unit tests locally to validate IPv6 sidecar IP constants contained within "[]" and it seems like your suggestion is viable - for both URL endpoint invocation formats and Dapr client instantiation. Great recommendation!
However, before I proceed, I need to validate an implementation detail with you. To test for whether an address is IPv6, it would be convenient to leverage the Apache Commons Validator, though you have recommended against bringing in 3P libraries beyond the test scope. Is it possible to get an exception for this case, or do I have to write a custom IPv6 validator within NetworkUtils?
There was a problem hiding this comment.
@willtsai Is it complex to write a validator for IPv6 ? both standard pattern and hex compressed pattern along with IPv4 validation?
I am wary of adding a new dependency specifically for one validation ....
There was a problem hiding this comment.
Understood - should not be too complex but I wanted to see if the work (and subsequent unit tests) could be avoided. Seems like adding a new dependency is not worth it here, so I'll work on the custom validator.
There was a problem hiding this comment.
I started the implementation for this and have a working validator, but then realized that this would introduce inconsistencies into the Property<String> SIDECAR_IP config object since the result would be that the special IPv6 formatting would only get applied when DEFAULT_SIDECAR_IP is used in fallback scenarios, so the IPv6 address would not get "[]" applied to them when they are sourced from the system property name or env variable.
Thus, I think there are two options:
- Leave the implementation of adding "[]" to the http address to the client and thus just modifying our test clients accordingly, i.e. code in this PR remain as is.
- Make modifications to the
Propertyand/orPropertiesobjects to introduce a new object classIpProperty.javaor equivalent that would apply the required IPv6 formatting to the IP address it returns.
@artursouza @mukundansundar - what are your thoughts here? which option would you prefer? (I personally think option 1 introduces less surprises to the client who may not be expecting IPv6 address to be pre-formatted for http URLs)
Signed-off-by: Will <28876888+willtsai@users.noreply.github.com>
|
@willtsai mind resolving the conflicts? |
Signed-off-by: Will <28876888+willtsai@users.noreply.github.com>
Signed-off-by: Will Tsai <28876888+willtsai@users.noreply.github.com>
Signed-off-by: Will Tsai <28876888+willtsai@users.noreply.github.com>
Signed-off-by: Will Tsai <28876888+willtsai@users.noreply.github.com>
Signed-off-by: Will Tsai <28876888+willtsai@users.noreply.github.com>
Signed-off-by: Will Tsai <28876888+willtsai@users.noreply.github.com>
Signed-off-by: Will Tsai <28876888+willtsai@users.noreply.github.com>
|
@cicoyle i've addressed all merge conflicts and test failures, can you please take another look? (i think the build tests just need to be re-run) |
Signed-off-by: Will Tsai <28876888+willtsai@users.noreply.github.com>
Signed-off-by: Artur Souza <artursouza.ms@outlook.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #649 +/- ##
=========================================
Coverage 77.60% 77.61%
- Complexity 1570 1571 +1
=========================================
Files 144 144
Lines 4765 4767 +2
Branches 554 554
=========================================
+ Hits 3698 3700 +2
Misses 781 781
Partials 286 286 ☔ View full report in Codecov by Sentry. |
cicoyle
left a comment
There was a problem hiding this comment.
lgtm - nice to see this coming to a closing 🎉
|
woo! thanks @cicoyle @artursouza 🥳 |
Description
I've made some changes to move away from hardcoded "127.0.0.1" IP addresses (representing
localhost) to make the SDK and Tests compatible with exclusively IPv6 environments:Issue reference
We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.
Please reference the issue this PR will close: #218
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: