Repository navigation
fix(nacos): skip loopback addresses for network interface (2025.0.x backport of #4350) - #4388
Merged
Merged
Conversation
Ensure both IPv4 and IPv6 candidates are checked for loopback addresses when a network interface is configured. Add regression coverage for selecting a non-loopback address. Backport of alibaba#4350 to 2025.0.x. Fixes alibabagh-4362
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe what this PR does / why we need it
This PR backports #4350 to
2025.0.x.When
spring.cloud.nacos.discovery.network-interfaceis configured, the current condition is evaluated asIPv4 || (IPv6 && !loopback). As a result, an IPv4 loopback address such as127.0.0.1can be selected before a usable address on the same interface.Does this pull request fix one issue?
Fixes #4362
Describe how you did it
127.0.0.1before192.168.1.10and verify that the usable address is selected.Describe how to verify it
Focused regression test:
./mvnw -pl spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-nacos-discovery -am -Dtest=NacosDiscoveryPropertiesTests#initShouldSkipLoopbackAddressFromNetworkInterface -Dsurefire.failIfNoSpecifiedTests=false testResult: 1 test passed, 0 failures, 0 errors.
Directly affected test classes:
./mvnw -pl spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-nacos-discovery -am -Dtest=NacosDiscoveryPropertiesTests,NacosAutoServiceRegistrationIpNetworkInterfaceTests -Dsurefire.failIfNoSpecifiedTests=false testResult: 8 tests passed, 0 failures, 0 errors.
Full Nacos Discovery module:
./mvnw -pl spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-nacos-discovery -am testResult: 62 tests passed, 0 failures, 0 errors. Checkstyle reported 0 violations.
Special notes for reviews
This PR replaces #4363, which has remained in draft and is blocked by a pending CLA. The patch is equivalent and is based on the latest
2025.0.xcommit9b3477ea4, including #4386 and #4387. A new 2025.0.x release is being prepared, so further updates can continue in this PR.