Skip to content

Update MCPRegistry Controller for Standard Workload Status #4270

Description

@ChrisJBurns

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:

  • APIStatusCollector interface with SetAPIStatus(phase, message, endpoint) — remove or simplify
  • StatusDeriver interface with DeriveOverallStatus() — remove entirely
  • StatusCollector with apiStatus, apiCollector fields — simplify
  • DefaultStatusDeriver — remove entirely

Replace with a simple status manager that can:

  • Set Phase (Pending/Running/Failed/Terminating)
  • Set Message
  • Set Ready condition (True/False with reason)
  • Set URL and ReadyReplicas

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) — references status.SyncStatus.ServerCount
  • WaitForLastSyncTime (line 93) — references status.SyncStatus.LastSyncTime
  • WaitForLastSyncHash (line 105) — references status.SyncStatus.LastSyncHash
  • WaitForSyncCompletion (line 117) — references MCPRegistryPhaseReady (now Running)
  • WaitForManualSyncProcessed (line 133) — references status.LastManualSyncTrigger

Update:

  • WaitForPhase / WaitForPhaseAny — use new phase values (Running instead of Ready)
  • Keep WaitForCondition and WaitForConditionReason — these work with the new Ready condition

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 Phase directly (no DeriveOverallPhase())
  • Controller sets Ready condition with ObservedGeneration based on deployment status
  • Controller sets URL and ReadyReplicas from deployment
  • DefaultStatusDeriver removed
  • mcpregistrystatus package simplified or removed
  • registryapi/manager.go updated (no references to ConditionAPIReady)
  • No references to SyncStatus, APIStatus, SyncPhase, APIPhase remain in controller or helpers
  • Integration test helpers updated for new status shape
  • DESIGN.md updated
  • Unit tests cover all phase/condition transitions
  • task test passes
  • Generated mock mocks/mock_collector.go regenerated

Activity

  1. changed the title [-]Update MCPRegistry Controller for Conditions-Based Status[/-] [+]Update MCPRegistry Controller for Standard Workload Status[/+] on Apr 2, 2026
  2. added a commit that references this issue on Apr 7, 2026
    7929c07
  3. added a commit that references this issue on Apr 8, 2026
    d68ea47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

breaking-changekubernetesoperator

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions