sunnysabor opened a new issue, #6904:
URL: https://github.com/apache/shenyu/issues/6904

   ### 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 with `url`, `weight`, `protocol`, `props`, and `status`, 
but no `namespaceId`.
   - `DiscoveryDataChangedEventSyncListener.buildProxySelectorData(...)` parses 
that JSON. When `DiscoveryUpstreamData.namespaceId` is blank, it defaults the 
upstream to `SYS_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
   
   1. Configure at least two ShenYu namespaces, including one non-default 
namespace.
   2. In the non-default namespace, configure a `divide` discovery selector 
with `discoveryType=eureka` and `listenerNode` equal to an Eureka application 
name.
   3. Ensure the initial full discovery refresh populates upstream data for 
that selector.
   4. Add, remove, or update an Eureka instance for that application.
   5. Observe that the incremental upstream event payload has no `namespaceId`, 
is defaulted to `SYS_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#buildUpstreamJsonFromInstance`
   - 
`org.apache.shenyu.admin.discovery.DiscoveryDataChangedEventSyncListener#buildProxySelectorData`
   - `org.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:
   
   ```java
   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.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to