Skip to content

feat(metadata): add renew and GC policy for app-level metadata#3371

Open
eye-gu wants to merge 6 commits into
apache:developfrom
eye-gu:feat-3355-metadata-renew-and-gc
Open

feat(metadata): add renew and GC policy for app-level metadata#3371
eye-gu wants to merge 6 commits into
apache:developfrom
eye-gu:feat-3355-metadata-renew-and-gc

Conversation

@eye-gu

@eye-gu eye-gu commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #3355

Checklist

  • I confirm the target branch is develop
  • Code has passed local testing
  • I have added tests that prove my fix is effective or that my feature works

Comment thread registry/servicediscovery/service_discovery_registry.go Fixed
@codecov-commenter

codecov-commenter commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 63.11111% with 83 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.07%. Comparing base (60d1c2a) to head (f8beceb).
⚠️ Report is 827 commits behind head on develop.

Files with missing lines Patch % Lines
...try/servicediscovery/service_discovery_registry.go 60.82% 27 Missing and 11 partials ⚠️
metadata/report/zookeeper/report.go 62.85% 12 Missing and 1 partial ⚠️
metadata/info/metadata_info.go 0.00% 10 Missing ⚠️
metadata/report/nacos/report.go 80.85% 7 Missing and 2 partials ⚠️
metadata/report/etcd/report.go 76.00% 6 Missing ⚠️
metadata/report/report.go 0.00% 5 Missing ⚠️
metadata/report_instance.go 66.66% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3371      +/-   ##
===========================================
+ Coverage    46.76%   53.07%   +6.30%     
===========================================
  Files          295      494     +199     
  Lines        17172    38172   +21000     
===========================================
+ Hits          8031    20258   +12227     
- Misses        8287    16265    +7978     
- Partials       854     1649     +795     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread registry/servicediscovery/service_discovery_registry.go Fixed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a lifecycle policy for application-level metadata in remote metadata centers by introducing (1) a daily “renew” republish and (2) a GC routine to delete stale revisions, along with new MetadataReport APIs to support listing and unpublishing revisions across Nacos/Etcd/Zookeeper.

Changes:

  • Introduces daily app-metadata renew + stale-revision GC in serviceDiscoveryRegistry, gated by URL params.
  • Extends report.MetadataReport with UnPublishAppMetadata and ListAppRevisions, and implements them for Nacos/Etcd/Zookeeper.
  • Adds lastUpdatedTime to app metadata payloads and adds/updates tests for renew/GC and report backends.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
registry/servicediscovery/service_discovery_registry.go Adds daily renew timer and GC logic that deletes stale app-metadata revisions.
registry/servicediscovery/service_discovery_registry_test.go Adds unit tests for GC behavior, renew behavior, timer stop, and delay calculation.
metadata/report/zookeeper/report.go Adds zk client abstraction; implements publish update-on-exists, unpublish, and list revisions.
metadata/report/zookeeper/report_test.go Adds mock-based tests for publish/get/update, unpublish, and list revisions.
metadata/report/report.go Extends the metadata report interface with revision listing + unpublish and adds helper to parse lastUpdatedTime.
metadata/report/nacos/report.go Implements unpublish + list revisions for Nacos metadata configs.
metadata/report/nacos/report_test.go Adds tests for Nacos unpublish and list revisions behaviors.
metadata/report/etcd/report.go Fixes etcd app-metadata key path; adds unpublish + list revisions for etcd.
metadata/report/etcd/report_test.go Reworks etcd metadata-report tests with a lightweight in-memory mock.
metadata/report_instance.go Delegates the new metadata-report methods through DelegateMetadataReport.
metadata/report_instance_test.go Adds delegation tests for the new interface methods.
metadata/mapping/metadata/service_name_mapping_test.go Updates mock metadata report to satisfy the extended interface.
metadata/info/metadata_info.go Adds LastUpdatedTime field to app metadata payload.
common/constant/key.go Adds configuration keys for metadata renew-on-startup and GC settings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread metadata/report/zookeeper/report.go
Comment thread metadata/report/etcd/report.go
Comment thread registry/servicediscovery/service_discovery_registry.go Outdated
Comment thread metadata/report/nacos/report.go Outdated
Comment thread metadata/report/zookeeper/report_test.go
Comment thread registry/servicediscovery/service_discovery_registry.go
Comment thread registry/servicediscovery/service_discovery_registry.go
Comment thread metadata/report/nacos/report.go Outdated
Comment thread registry/servicediscovery/service_discovery_registry.go Outdated

@Alanxtl Alanxtl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Alanxtl

Alanxtl commented Jun 9, 2026

Copy link
Copy Markdown
Member
  1. 当前测试覆盖率偏低,建议至少补一两个 timer/GC 核心分支测试,尤其是 stale revision 被清理、alive revision 被保留这两个路径。
  2. doRenewAppMetadata 里依赖 MetadataInfo.Snapshot(),合并 feat(metadata): add concurrency safety for application-level metadata state (#3353) #3367 后要确认 Snapshot 是带锁/深拷贝语义,避免 renew 时读写 metadata 产生 race

@Alanxtl

Alanxtl commented Jun 9, 2026

Copy link
Copy Markdown
Member

合并顺序

#3360#3362 先合,低耦合。
#3367 作为并发安全底座。
#3369 合入,建立 registryId/report/cache 作用域。
#3370 rebase 到 #3367 + #3369 之后,特别检查 revision 计算不要绕开锁。
#3371 再合,接受 MetadataReport 接口扩展,并补确认 Snapshot() 与 #3367 锁语义一致。
#3373 最后 rebase,因为它和 #3371 同改 report backends;语义不重复,但文件冲突概率高。

@AlexStocks

Copy link
Copy Markdown
Contributor

@eye-gu fix file confliction

@eye-gu eye-gu force-pushed the feat-3355-metadata-renew-and-gc branch from 28773a8 to f8beceb Compare June 10, 2026 02:31
@sonarqubecloud

Copy link
Copy Markdown

@eye-gu

eye-gu commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

@eye-gu fix file confliction

已经rebase develop

@Alanxtl

添加了测试

@Alanxtl Alanxtl self-assigned this Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add cleanup and update policy for application-level metadata / 为应用级 metadata 增加清理和更新策略

6 participants