Skip to content

Refactor MCPRegistry Status Types #4269

Closed

Description

@ChrisJBurns

Description

Replace the over-engineered three-phase-enum status model in MCPRegistry with the same standard Kubernetes workload status pattern used by MCPServer. Remove all sync/API-specific status types and simplify to Phase + Ready condition.

Why not track sync/API status?

Tracking internal registry server states (sync progress, API readiness) requires the operator to call the registry server itself — which with auth is not feasible — and couples the operator to the server's internal application state. The operator should only care about whether the workload is running and ready as a standard Kubernetes workload.

Open for discussion, but the default position is to only care about deployment status/readiness of the container.

Implementation Notes

File: cmd/thv-operator/api/v1alpha1/mcpregistry_types.go

Remove entirely

  • SyncStatus struct (lines 527-559)
  • APIStatus struct (lines 561-578)
  • SyncPhase type and constants: Syncing, Complete, Failed (lines 580-593)
  • APIPhase type and constants: NotStarted, Deploying, Ready, Unhealthy, Error (lines 595-614)
  • StorageReference struct (lines 616-626) — never wired up in the controller
  • ConditionSyncSuccessful, ConditionAPIReady, ConditionSourceAvailable, ConditionDataValid constants (lines 649-665)
  • DeriveOverallPhase() method (lines 716-756)
  • All DeriveOverallPhase tests in mcpregistry_types_test.go

Simplify MCPRegistryPhase

Current values: Pending, Ready, Failed, Syncing, Terminating

New values to match MCPServerPhase: Pending, Running, Failed, Terminating

  • Rename Ready to Running — this is a deliberate semantic alignment with MCPServer. The healthy phase for all ToolHive workloads is Running. This rename affects downstream code (see Update image validation for MCPRegistry phase rename #4510 for image validation impact).
  • Remove Syncing (internal implementation detail, not a workload phase)

Unify ConditionRegistryPodTemplateValid

The current MCPRegistry uses a registry-specific constant ConditionRegistryPodTemplateValid ("PodTemplateValid"). MCPServer uses the shared ConditionPodTemplateValid. These are identical in value — unify by removing the registry-specific constant and using the shared one from mcpserver_types.go. Update ConditionReasonRegistryPodTemplateValid and ConditionReasonRegistryPodTemplateInvalid similarly.

Simplify MCPRegistryStatus

Replace the current struct with:

type MCPRegistryStatus struct {
    // Conditions represent the latest available observations of the MCPRegistry's state
    // +optional
    // +listType=map
    // +listMapKey=type
    Conditions []metav1.Condition `json:"conditions,omitempty"`

    // ObservedGeneration reflects the generation most recently observed by the controller
    // +optional
    ObservedGeneration int64 `json:"observedGeneration,omitempty"`

    // Phase is the current phase of the MCPRegistry
    // +optional
    Phase MCPRegistryPhase `json:"phase,omitempty"`

    // Message provides additional information about the current phase
    // +optional
    Message string `json:"message,omitempty"`

    // URL is the endpoint where the registry API is accessible
    // +optional
    URL string `json:"url,omitempty"`

    // ReadyReplicas is the number of ready registry replicas
    // +optional
    ReadyReplicas int32 `json:"readyReplicas,omitempty"`
}

Fields removed: SyncStatus, APIStatus, LastAppliedFilterHash, StorageRef, LastManualSyncTrigger

Note: LastAppliedFilterHash, StorageRef, and LastManualSyncTrigger are all designed-but-never-wired-up — the controller never reads or writes them. Safe to remove.

Update printer columns

Replace current columns (lines 678-683):

//+kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.phase"
//+kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
//+kubebuilder:printcolumn:name="Replicas",type="integer",JSONPath=".status.readyReplicas"
//+kubebuilder:printcolumn:name="URL",type="string",JSONPath=".status.url"
//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"

Reference: MCPServer status pattern

This is the target pattern — see mcpserver_types.go lines 882-944 for the exact implementation MCPRegistry should mirror.

Post-implementation: Run task gen to regenerate deepcopy (zz_generated.deepcopy.go), CRD YAMLs in deploy/charts/operator-crds/, and mocks.

Testing

  • Remove all DeriveOverallPhase tests from mcpregistry_types_test.go
  • Add basic tests for the simplified status types if needed
  • task gen succeeds
  • task test passes

Acceptance Criteria

  • SyncStatus, APIStatus, SyncPhase, APIPhase, StorageReference types all removed
  • MCPRegistryPhase simplified to: Pending/Running/Failed/Terminating (note: Ready renamed to Running)
  • MCPRegistryStatus contains only: Conditions, ObservedGeneration, Phase, Message, URL, ReadyReplicas
  • DeriveOverallPhase() removed
  • ConditionRegistryPodTemplateValid unified with shared ConditionPodTemplateValid
  • Registry-specific condition constants (ConditionSyncSuccessful, ConditionAPIReady, etc.) removed
  • Printer columns match MCPServer pattern
  • task gen succeeds (deepcopy, CRD YAMLs, mocks regenerated)
  • task test passes (existing tests updated/removed as needed)

Activity

  1. added a commit that references this issue on Apr 7, 2026
    7929c07
  2. 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