-
Notifications
You must be signed in to change notification settings - Fork 153
Open
Labels
enhancementNew feature or requestNew feature or requestgoPull requests that update go codePull requests that update go codekubernetesItems related to KubernetesItems related to Kubernetesoperatortech-debtvmcpVirtual MCP Server related issuesVirtual MCP Server related issues
Description
Description
Refactor the VirtualMCPServer controller to delegate operational state management to the vMCP runtime. The controller should focus on infrastructure provisioning while the runtime owns backend discovery and health reporting.
Background
Currently the controller and runtime both discover backends:
- Controller:
discoverBackends()at reconcile time →status.discoveredBackends - Runtime:
k8sDiscovererat request time for routing
This creates duplication and stale status. Per team discussion: "the vmcp server should be k8s aware and do most of the work instead of operator needing to do it all."
Current vs Target State
Controller Responsibilities
| Responsibility | Current | Target |
|---|---|---|
| RBAC, Deployment, Service, ConfigMap | ✅ Keep | ✅ Keep |
| Validate GroupRef exists | ✅ Keep | ✅ Keep |
Set status.URL |
✅ Keep | ✅ Keep |
| Infrastructure conditions | ✅ Keep | ✅ Keep |
| Backend discovery | ❌ Remove | |
| Backend health status | ❌ Remove | |
status.discoveredBackends |
✅ Read from runtime | |
status.Phase |
✅ Read from runtime |
Runtime Responsibilities (via StatusReporter)
| Responsibility | Current | Target |
|---|---|---|
| Dynamic backend discovery | ✅ Has | ✅ Keep |
| Backend health monitoring | ✅ Full ownership | |
Report status.discoveredBackends |
❌ None | ✅ Add |
Report status.Phase |
❌ None | ✅ Add |
Implementation
Phase 1: Enable Runtime Reporting
Depends on: #2854 (StatusReporter abstraction)
Phase 2: Controller Reads Runtime Status
- Controller observes status changes via watch (already configured)
- Remove redundant
discoverBackends()call - Set infrastructure-only conditions
Files to Modify
cmd/thv-operator/controllers/virtualmcpserver_controller.go:
- Remove
discoverBackends()function - Remove backend health inference logic
- Simplify
Reconcile()to infrastructure-only
cmd/thv-operator/controllers/virtualmcpserver_deployment.go:
- Add VMCP_NAME and VMCP_NAMESPACE env vars for runtime identity
Reconciliation Flow (After)
Reconcile()
├── Validate GroupRef exists
├── Ensure RBAC (ServiceAccount, Role, RoleBinding)
├── Ensure ConfigMap with vMCP config
├── Ensure Deployment (with env vars for identity)
├── Ensure Service
├── Set infrastructure conditions (DeploymentReady, ServiceReady)
├── Set status.URL
└── Done (runtime reports operational status)
Acceptance Criteria
- Remove
discoverBackends()from controller - Controller sets only infrastructure conditions
- Runtime reports
status.discoveredBackendsvia StatusReporter - Runtime reports
status.Phase(Ready/Degraded/Failed) - No duplicate backend queries between controller and runtime
- E2E test validates runtime status appears in CRD
- Documentation updated for new responsibility split
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgoPull requests that update go codePull requests that update go codekubernetesItems related to KubernetesItems related to Kubernetesoperatortech-debtvmcpVirtual MCP Server related issuesVirtual MCP Server related issues