Repository navigation
Description
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
SyncStatusstruct (lines 527-559)APIStatusstruct (lines 561-578)SyncPhasetype and constants:Syncing,Complete,Failed(lines 580-593)APIPhasetype and constants:NotStarted,Deploying,Ready,Unhealthy,Error(lines 595-614)StorageReferencestruct (lines 616-626) — never wired up in the controllerConditionSyncSuccessful,ConditionAPIReady,ConditionSourceAvailable,ConditionDataValidconstants (lines 649-665)DeriveOverallPhase()method (lines 716-756)- All
DeriveOverallPhasetests inmcpregistry_types_test.go
Simplify MCPRegistryPhase
Current values: Pending, Ready, Failed, Syncing, Terminating
New values to match MCPServerPhase: Pending, Running, Failed, Terminating
- Rename
ReadytoRunning— this is a deliberate semantic alignment with MCPServer. The healthy phase for all ToolHive workloads isRunning. 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, andLastManualSyncTriggerare 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
DeriveOverallPhasetests frommcpregistry_types_test.go - Add basic tests for the simplified status types if needed
task gensucceedstask testpasses
Acceptance Criteria
SyncStatus,APIStatus,SyncPhase,APIPhase,StorageReferencetypes all removedMCPRegistryPhasesimplified to: Pending/Running/Failed/Terminating (note:Readyrenamed toRunning)MCPRegistryStatuscontains only: Conditions, ObservedGeneration, Phase, Message, URL, ReadyReplicasDeriveOverallPhase()removedConditionRegistryPodTemplateValidunified with sharedConditionPodTemplateValid- Registry-specific condition constants (
ConditionSyncSuccessful,ConditionAPIReady, etc.) removed - Printer columns match MCPServer pattern
task gensucceeds (deepcopy, CRD YAMLs, mocks regenerated)task testpasses (existing tests updated/removed as needed)
Activity
Consolidate MCPRegistry status to match MCPServer pattern
Consolidate MCPRegistry status to match MCPServer pattern (stacklok#4643