Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The Zookeeper adapter still drops DELETE events when data is null, so they do not reach the new handler.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Fixes path-based discovery-upstream DELETE handling and adds regression coverage.
Changes:
- Dispatches DELETE events to subscribers and parses selector IDs.
- Adds PUT/DELETE handler tests.
File summaries
| File | Reviewed changes |
|---|---|
shenyu-sync-data-center/shenyu-sync-data-api/src/test/java/org/apache/shenyu/sync/data/core/AbstractPathDataSyncServiceTest.java |
Tests discovery-upstream PUT and DELETE notifications. |
shenyu-sync-data-center/shenyu-sync-data-api/src/main/java/org/apache/shenyu/sync/data/core/AbstractPathDataSyncService.java |
Adds DELETE handling and subscriber uncache delegation. |
Review details
Suppressed comments (1)
shenyu-sync-data-center/shenyu-sync-data-api/src/main/java/org/apache/shenyu/sync/data/core/AbstractPathDataSyncService.java:143
- This new branch only forwards the delete to
DiscoveryUpstreamDataSubscriber, but the productionCommonDiscoveryUpstreamDataSubscriber.unSubscribeimplementation is still a no-op, so the normal gateway path performs no cache eviction and stale upstreams continue receiving traffic. Please include the downstream eviction (byselectorId) in this fix, or scope the PR/issue claim so it does not present #6661 as resolved.
unCacheDiscoveryUpstreamData(discoverySyncData);
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| .ifPresent(e -> cacheDiscoveryUpstreamData(GsonUtils.getInstance().fromJson(updateData, DiscoverySyncData.class))); | ||
| String pluginName = pathInfoArray[pathInfoArray.length - 2]; | ||
| String selectorId = pathInfoArray[pathInfoArray.length - 1]; | ||
| if (EventType.DELETE.equals(eventType)) { |
Aias00
approved these changes
Sep 19, 2026
Aias00
left a comment
Contributor
There was a problem hiding this comment.
Approved as PMC (Aias00). Small, well-scoped fix with regression tests; green CI, mergeable. Reviewed the diff.
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.
Make sure that:
./mvnw clean install -Dmaven.javadoc.skip=true.Summary
Fixes #6661.
Path-based sync services (etcd / zookeeper / consul, all extending
AbstractPathDataSyncService) do receive delete notifications for discovery upstream nodes:EtcdSyncDataService.watchChildChangefiressuper.event(configNamespace, deletePath, null, registerPath, EventType.DELETE)(EtcdSyncDataService.java:88), andevent()dispatches it todiscoveryUpstreamHandlerEvent. But that handler only acted when the event was not a delete, so the DELETE was silently dropped andDiscoveryUpstreamDataSubscriber#unSubscribewas never called. Every other entity in the same class (plugin, selector, rule, app auth, meta data, proxy selector) already handles DELETE.Changes:
AbstractPathDataSyncService.discoveryUpstreamHandlerEvent(AbstractPathDataSyncService.java:132) — added the missing DELETE branch: parsespluginNameand the last path segment with the samesplit("/")pattern used byproxyHandlerEvent, builds aDiscoverySyncDatacarrying them, and calls the new un-cache hook. The PUT path is unchanged.AbstractPathDataSyncService.unCacheDiscoveryUpstreamData(AbstractPathDataSyncService.java:290) — new protected hook delegating todiscoveryUpstreamDataSubscribers.forEach(e -> e.unSubscribe(...)), mirroring the existingunCacheProxySelectorData/unCacheMetaDatahelpers and the node-based counterpartAbstractNodeDataSyncService.unCacheDiscoveryUpstreamData.Note on the parsed path segment: the discovery-upstream path ends with the selector id, not the selector name —
AbstractPathDataChangedListener.onDiscoveryUpstreamChangedbuilds it withbuildDiscoveryUpstreamPath(data.getNamespaceId(), data.getPluginName(), data.getSelectorId()), and the node-based sync setsselectorIdfor the same reason. This PR therefore setsselectorId(the issue text suggested "selector name").Test Cases:
AbstractPathDataSyncServiceTest#testDiscoveryUpstreamHandlerEvent(AbstractPathDataSyncServiceTest.java:93) — dispatchesevent(...)for/{ns}/shenyu/discoveryUpstream/divide/{selectorId}: PUT triggersonSubscribe, DELETE triggersunSubscribe, and the capturedDiscoverySyncDatacarriespluginName=divide/selectorId=testSelectorId.Verification
./mvnw clean install -Dmaven.javadoc.skip=trueon JDK 21: whole reactor passes, with the one pre-existing order-dependent test excluded (-Dtest='!DubboReconcilerTest' -DfailIfNoTests=false).org.apache.shenyu.k8s.DubboReconcilerTestshares the staticIngressCachewithWebSocketReconcilerTest/DivideIngressReconcilerTest(all usemockedNamespace/mockedIngress) and fails purely on test execution order: it passes in isolation and reproduces the same failure on unmodifiedmaster.shenyu-kubernetes-controllerdoes not depend onshenyu-sync-data-api.shenyu-sync-data-api,shenyu-sync-data-etcd,shenyu-sync-data-zookeeper,shenyu-sync-data-consul— all tests pass.checkstyle:check— 0 violations.Not covered here: the gateway-side
CommonDiscoveryUpstreamDataSubscriber#unSubscribeis still a no-op (//ignore), so actually evicting the cached upstream list (UpstreamCacheManager.removeByKey(selectorId)) on deletion remains a separate change in the discovery plugin handlers.@Aias00, could you please help review this PR? Thank you!
close #6661