[BUG] Eureka incremental upstream updates are filtered for non-default namespaces
Is there an existing issue for this?
I have searched the existing issues.
Current Behavior
When the same Eureka service is configured as a discovery listener node in a non-default ShenYu namespace, the initial discovery refresh can populate upstreams with the correct namespace, but subsequent Eureka incremental events may be filtered out.
The incremental event path currently has a namespace mismatch risk:
EurekaInstanceRegisterRepository.buildUpstreamJsonFromInstance(...)builds upstream JSON withurl,weight,protocol,props, andstatus, but nonamespaceId.DiscoveryDataChangedEventSyncListener.buildProxySelectorData(...)parses that JSON. WhenDiscoveryUpstreamData.namespaceIdis blank, it defaults the upstream toSYS_DEFAULT_NAMESPACE_ID.- The listener then filters upstreams by
discoverySyncData.getNamespaceId().
For a non-default namespace, a blank upstream namespace is converted to the default namespace and then filtered out.
Expected Behavior
When a registry event payload does not include a ShenYu namespace, the upstream should inherit the namespace of the current discovery sync context, i.e. discoverySyncData.getNamespaceId().
This is consistent with AbstractDiscoveryProcessor.fetchAll(...), which fills missing upstream namespaces from proxySelectorDTO.getNamespaceId() during the full refresh path.
Payloads that explicitly include namespaceId should keep the current filtering behavior.
Steps To Reproduce
- Configure at least two ShenYu namespaces, including one non-default namespace.
- In the non-default namespace, configure a
dividediscovery selector withdiscoveryType=eurekaandlistenerNodeequal to an Eureka application name. - Ensure the initial full discovery refresh populates upstream data for that selector.
- Add, remove, or update an Eureka instance for that application.
- Observe that the incremental upstream event payload has no
namespaceId, is defaulted toSYS_DEFAULT_NAMESPACE_ID, and is filtered out for the non-default namespace.
Environment
ShenYu version(s): current master
Debug logs
Relevant code paths:
org.apache.shenyu.registry.eureka.EurekaInstanceRegisterRepository#buildUpstreamJsonFromInstanceorg.apache.shenyu.admin.discovery.DiscoveryDataChangedEventSyncListener#buildProxySelectorDataorg.apache.shenyu.admin.discovery.AbstractDiscoveryProcessor#fetchAll
Anything else?
The minimal behavior-preserving fix is to fill missing upstream namespaces from the current discovery sync context:
if (StringUtils.isBlank(discoveryUpstreamData.getNamespaceId())) {
discoveryUpstreamData.setNamespaceId(discoverySyncData.getNamespaceId());
}
This preserves behavior for payloads that explicitly include namespaceId, while making blank namespace handling consistent with the full refresh path.
👋 Hello @Aias00
A new issue has been opened by @sunnysabor:
- Title: [BUG] Eureka incremental upstream updates are filtered for non-default namespaces
- Link: https://github.com/apache/shenyu/issues/6904
Please review when you have time. Thank you! 🙏