feat(etcdv3): support unsubscribe and subscription recovery#3387
feat(etcdv3): support unsubscribe and subscription recovery#3387leno23 wants to merge 9 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3387 +/- ##
===========================================
+ Coverage 46.76% 53.50% +6.73%
===========================================
Files 295 493 +198
Lines 17172 38350 +21178
===========================================
+ Hits 8031 20520 +12489
- Misses 8287 16194 +7907
- Partials 854 1636 +782 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Addressed the remaining Codecov patch coverage feedback by covering the delete-event skip path and the valid-client DoUnregister path. Local validation passes: go test -coverprofile=/tmp/etcdv3.cover ./registry/etcdv3, go test ./registry/etcdv3 ./remoting/etcdv3, and git diff --check. |
There was a problem hiding this comment.
Pull request overview
This PR fills several missing lifecycle behaviors in the etcdv3 registry to bring it closer to other registries (notably zookeeper): unregistering removes the etcd key, subscribe/unsubscribe is managed per-service (rather than via a single shared listener), and subscriptions are preserved across client restarts by reconstructing listeners during InitListeners() recovery.
Changes:
- Implement
DoUnregister()by validating the etcd client and deleting the registered key. - Refactor subscription handling to per-service listeners, adding
DoUnsubscribe()that closes/removes the service listener. - Add subscription recovery on reconnect by rebuilding listeners from previously subscribed URLs and restarting service-event watches; expand tests accordingly.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
registry/etcdv3/registry.go |
Implements unregister/unsubscribe, switches to per-service subscription listeners, and adds listener recovery during re-init. |
registry/etcdv3/listener.go |
Reworks the data listener to dispatch to multiple subscribed listeners and adds listener close semantics/state. |
registry/etcdv3/registry_test.go |
Adds coverage for unregister, subscribe/unsubscribe behavior, listener close, and recovery logic. |
registry/etcdv3/listener_test.go |
Adds coverage for dispatch behavior, wildcard matching, unsubscribe/close behavior, and listener close/next behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Follow-up for the remaining Codecov partial coverage warning in registry/etcdv3/listener.go: added a focused test that drives configurationListener.Next through the skipped delete-event path when the etcd client is invalid, then verifies the next add event is returned. Local validation passes: go test ./registry/etcdv3 ./remoting/etcdv3, go test -race ./registry/etcdv3, go test -coverprofile=/tmp/etcdv3_after.out ./registry/etcdv3, and git diff --check. |
|
Addressed the P1 DoUnsubscribe feedback. DoUnsubscribe now validates the event listener and the subscribed entry type before calling unsubscribeURLLocked, so error paths no longer close/remove the local subscription. I also added a regression test covering the nil event-listener path and verifying the subscription remains in the map and open. Local validation passes: go test ./registry/etcdv3 ./remoting/etcdv3, go test -race ./registry/etcdv3, go test -coverprofile=/tmp/etcdv3_fix.out ./registry/etcdv3, and git diff --check. |
|
Follow-up for the failed CI lint job: changed the new error assertion to require.ErrorContains to satisfy testifylint. Local validation passes: go test ./registry/etcdv3 ./remoting/etcdv3, go test -race ./registry/etcdv3, and git diff --check. golangci-lint is not installed in this local environment, so I verified the exact reported lint issue by matching the CI log. |
|



Description
Fixes #3366.
This PR fills the missing etcdv3 registry subscription lifecycle behavior:
DoUnregisterby deleting the registered etcd key after validating the clientDoUnsubscribeby closing and removing the service listenerValidation
go test ./registry/etcdv3gofmton touched filesgit diff --checkChecklist