Skip to content

Add DynamicRegistry with version-based cache invalidation - #3188

Merged
yrobla merged 2 commits into
mainfrom
feat/issue-2999
Jan 5, 2026
Merged

yrobla merged 2 commits into
mainfrom
feat/issue-2999

Conversation

@yrobla

@yrobla yrobla commented Jan 5, 2026 •

Copy link
Copy Markdown
Contributor

Implement mutable registry for vMCP K8s-aware dynamic discovery mode. Supports thread-safe backend updates with lazy cache invalidation to enable real-time backend changes without thundering herd problems.

This is the first of several PRs , the k8s integration, watcher, etc... will be implemented in follow ups

Large PR Justification

This is a complete and atomic PR that covers a single functionality. It includes proper testing. Can't be split.

Closes: #2999

@github-actions github-actions Bot added the size/XL Extra large PR: 1000+ lines changed label Jan 5, 2026

@github-actions github-actions Bot 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.

Large PR Detected

This PR exceeds 1000 lines of changes and requires justification before it can be reviewed.

How to unblock this PR:

Add a section to your PR description with the following format:

## Large PR Justification

[Explain why this PR must be large, such as:]
- Generated code that cannot be split
- Large refactoring that must be atomic
- Multiple related changes that would break if separated
- Migration or data transformation

Alternative:

Consider splitting this PR into smaller, focused changes (< 1000 lines each) for easier review and reduced risk.

See our Contributing Guidelines for more details.


This review will be automatically dismissed once you add the justification section.

@github-actions github-actions Bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Jan 5, 2026
@github-actions github-actions Bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Jan 5, 2026
@github-actions github-actions Bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Jan 5, 2026
@codecov

codecov Bot commented Jan 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.15%. Comparing base (e583700) to head (f55af08).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
cmd/vmcp/app/commands.go 0.00% 3 Missing ⚠️
pkg/vmcp/server/server.go 66.66% 2 Missing ⚠️
test/integration/vmcp/helpers/vmcp_server.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3188      +/-   ##
==========================================
- Coverage   57.17%   57.15%   -0.02%     
==========================================
  Files         341      343       +2     
  Lines       34145    34377     +232     
==========================================
+ Hits        19521    19649     +128     
- Misses      13011    13087      +76     
- Partials     1613     1641      +28     

☔ View full report in Codecov by Sentry.
📢 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.

@github-actions

github-actions Bot commented Jan 5, 2026

Copy link
Copy Markdown
Contributor

✅ Large PR justification has been provided. The size review has been dismissed and this PR can now proceed with normal review.

@github-actions
github-actions Bot dismissed their stale review January 5, 2026 10:56

Large PR justification has been provided. Thank you!

@github-actions github-actions Bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Jan 5, 2026
@github-actions github-actions Bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Jan 5, 2026
@github-actions github-actions Bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Jan 5, 2026
@yrobla
yrobla requested a review from Copilot January 5, 2026 11:56

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 implements a DynamicRegistry for virtual MCP servers with version-based cache invalidation to support real-time backend changes in Kubernetes-aware dynamic discovery mode. The implementation uses lazy cache invalidation with monotonic version tracking to avoid thundering herd problems when backends are added or removed.

  • Adds DynamicRegistry interface with thread-safe Upsert, Remove, and Version operations
  • Integrates version-based cache invalidation into the discovery manager
  • Provides comprehensive unit and E2E tests (E2E tests marked as Pending awaiting operator integration)

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/vmcp/registry.go Adds DynamicRegistry interface and dynamicRegistry implementation with RWMutex-based thread safety, version tracking, and defensive copying for immutability
pkg/vmcp/registry_test.go Comprehensive unit tests for DynamicRegistry covering concurrent access, version tracking, and immutability guarantees
pkg/vmcp/discovery/manager.go Extends discovery manager with NewManagerWithRegistry constructor and version-based cache invalidation logic
pkg/vmcp/discovery/manager_test.go Unit tests verifying cache invalidation behavior when registry version changes
pkg/vmcp/mocks/mock_registry.go Generated mocks for both BackendRegistry and DynamicRegistry interfaces
pkg/vmcp/mocks/mock_backend_registry.go Deleted old mock file (consolidated into mock_registry.go)
test/e2e/thv-operator/virtualmcp/virtualmcp_lifecycle_test.go End-to-end tests for dynamic backend discovery lifecycle (marked Pending until operator integration)

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

@github-actions github-actions Bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Jan 5, 2026
@github-actions github-actions Bot added the size/XL Extra large PR: 1000+ lines changed label Jan 5, 2026
@yrobla
yrobla requested a review from Copilot January 5, 2026 12:54

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

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


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

Comment thread pkg/vmcp/registry.go Resolved
Comment thread pkg/vmcp/registry.go Resolved
Comment thread pkg/vmcp/registry.go Resolved
Comment thread pkg/vmcp/server/status.go Resolved
Comment thread pkg/vmcp/registry.go Resolved
Implement mutable registry for vMCP K8s-aware dynamic discovery mode.
Supports thread-safe backend updates with lazy cache invalidation to
enable real-time backend changes without thundering herd problems.

Closes: #2999
@github-actions github-actions Bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Jan 5, 2026
Comment thread pkg/vmcp/registry.go Resolved
Comment thread pkg/vmcp/registry.go Resolved

@dmjb dmjb 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.

See inline comments

@github-actions github-actions Bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Jan 5, 2026
@yrobla
yrobla requested a review from dmjb January 5, 2026 15:00
@yrobla
yrobla merged commit 674e321 into main Jan 5, 2026
33 checks passed
@yrobla
yrobla deleted the feat/issue-2999 branch January 5, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XL Extra large PR: 1000+ lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DynamicRegistry with version-based cache invalidation

4 participants