Repository navigation
Description
Description
Update the MCPRegistry controller to set status using the standard Kubernetes workload pattern (matching MCPServer), instead of the current sync/API sub-phase model.
Why this simplification?
The previous approach tracked internal registry server states (sync progress, API readiness) as separate status fields. This requires the operator to make calls to the registry server itself — which with auth enabled is not feasible — and couples the operator to the server's internal application state. The operator should only care about whether the workload (container/pod) is running and ready.
Open for discussion, but the default position is to only care about deployment status/readiness of the container.
Depends on: #4269
Implementation Notes
Simplify mcpregistrystatus package
Files: cmd/thv-operator/pkg/mcpregistrystatus/
The current package has:
APIStatusCollectorinterface withSetAPIStatus(phase, message, endpoint)— remove or simplifyStatusDeriverinterface withDeriveOverallStatus()— remove entirelyStatusCollectorwithapiStatus,apiCollectorfields — simplifyDefaultStatusDeriver— remove entirely
Replace with a simple status manager that can:
- Set
Phase(Pending/Running/Failed/Terminating) - Set
Message - Set
Readycondition (True/False with reason) - Set
URLandReadyReplicas
Or remove the package entirely if the controller can set status directly (evaluate whether the batching in StatusCollector.UpdateStatus() is still valuable).
Fix ObservedGeneration on conditions
The current StatusCollector.SetCondition() (collector.go lines 63-70) does not set ObservedGeneration on individual conditions. MCPServer does this correctly (mcpserver_controller.go:697). When setting conditions, always include ObservedGeneration: registry.Generation:
meta.SetStatusCondition(&status.Conditions, metav1.Condition{
Type: "Ready",
Status: metav1.ConditionTrue,
Reason: "DeploymentAvailable",
Message: "Registry deployment is available",
ObservedGeneration: registry.Generation,
})Update registryapi/manager.go
This file uses mcpregistrystatus.Error with ConditionType: mcpv1alpha1.ConditionAPIReady. Since ConditionAPIReady is removed in #4269, update to use "Ready" (or a shared constant) instead.
Update controller
File: cmd/thv-operator/controllers/mcpregistry_controller.go
Replace all SetAPIStatus(APIPhaseXxx, ...) calls with direct phase + condition setting:
// Deployment not yet available
status.Phase = MCPRegistryPhasePending
status.Message = "Waiting for deployment to become available"
meta.SetStatusCondition(&status.Conditions, metav1.Condition{
Type: "Ready",
Status: metav1.ConditionFalse,
Reason: "DeploymentUnavailable",
Message: "Registry deployment is not yet available",
ObservedGeneration: registry.Generation,
})
// Deployment available and ready
status.Phase = MCPRegistryPhaseRunning
status.Message = "Registry is running"
status.URL = endpoint
status.ReadyReplicas = deployment.Status.ReadyReplicas
meta.SetStatusCondition(&status.Conditions, metav1.Condition{
Type: "Ready",
Status: metav1.ConditionTrue,
Reason: "DeploymentAvailable",
Message: "Registry deployment is available",
ObservedGeneration: registry.Generation,
})
// Deployment failed
status.Phase = MCPRegistryPhaseFailed
status.Message = "Registry deployment failed"
meta.SetStatusCondition(&status.Conditions, metav1.Condition{
Type: "Ready",
Status: metav1.ConditionFalse,
Reason: "DeploymentFailed",
Message: "Registry deployment failed: ...",
ObservedGeneration: registry.Generation,
})Update integration test helpers
File: cmd/thv-operator/test-integration/mcp-registry/status_helpers.go
Remove helpers that reference removed SyncStatus fields:
WaitForServerCount(line 81) — referencesstatus.SyncStatus.ServerCountWaitForLastSyncTime(line 93) — referencesstatus.SyncStatus.LastSyncTimeWaitForLastSyncHash(line 105) — referencesstatus.SyncStatus.LastSyncHashWaitForSyncCompletion(line 117) — referencesMCPRegistryPhaseReady(nowRunning)WaitForManualSyncProcessed(line 133) — referencesstatus.LastManualSyncTrigger
Update:
WaitForPhase/WaitForPhaseAny— use new phase values (Runninginstead ofReady)- Keep
WaitForConditionandWaitForConditionReason— these work with the newReadycondition
Also update any integration tests in cmd/thv-operator/test-integration/mcp-registry/ that use the removed helpers or old phase values.
Update DESIGN.md
File: cmd/thv-operator/DESIGN.md
Update sections on StatusCollector pattern and sync operation design to reflect the simplified status model.
Reference: MCPServer controller pattern
Look at how the MCPServer controller sets its status — that's the pattern to follow. The MCPRegistry controller should do the equivalent for the registry deployment.
Testing
- Deployment available → verify Phase=Running, Ready=True, ObservedGeneration set
- Deployment unavailable → verify Phase=Pending, Ready=False
- Deployment failed → verify Phase=Failed, Ready=False
- Deletion → verify Phase=Terminating
- Verify ObservedGeneration is set on both status and individual conditions
Acceptance Criteria
- Controller sets
Phasedirectly (noDeriveOverallPhase()) - Controller sets
Readycondition withObservedGenerationbased on deployment status - Controller sets
URLandReadyReplicasfrom deployment DefaultStatusDeriverremovedmcpregistrystatuspackage simplified or removedregistryapi/manager.goupdated (no references toConditionAPIReady)- No references to
SyncStatus,APIStatus,SyncPhase,APIPhaseremain in controller or helpers - Integration test helpers updated for new status shape
DESIGN.mdupdated- Unit tests cover all phase/condition transitions
task testpasses- Generated mock
mocks/mock_collector.goregenerated
Activity
[-]Update MCPRegistry Controller for Conditions-Based Status[/-][+]Update MCPRegistry Controller for Standard Workload Status[/+]Consolidate MCPRegistry status to match MCPServer pattern
Consolidate MCPRegistry status to match MCPServer pattern (stacklok#4643