Skip to content

Commit c28cd63

Browse files
committed
Fix PodTemplateSpec validation condition persistence
The issue was that PodTemplateSpec validation was happening early and setting the PodTemplateValid condition, but then image validation was also setting the ImageValidated condition without persisting it to status. This caused the ImageValidated condition to overwrite the PodTemplateValid condition in subsequent status updates. The fix ensures that both validation conditions are persisted immediately after being set: - PodTemplateSpec validation updates status after setting condition - Image validation now also updates status after setting condition This ensures both conditions are present in the MCPServer status and the invalid-podtemplatespec e2e test will pass. Signed-off-by: Juan Antonio Osorio <[email protected]>
1 parent e4d1360 commit c28cd63

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cmd/thv-operator/controllers/mcpserver_controller.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ func (r *MCPServerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
217217
setImageValidationCondition(mcpServer, metav1.ConditionTrue,
218218
mcpv1alpha1.ConditionReasonImageValidationSkipped,
219219
"Image validation was not performed (no enforcement configured)")
220+
// Update status to persist the condition
221+
if statusErr := r.Status().Update(ctx, mcpServer); statusErr != nil {
222+
ctxLogger.Error(statusErr, "Failed to update MCPServer status after image validation")
223+
}
220224
} else if goerr.Is(err, validation.ErrImageInvalid) {
221225
ctxLogger.Error(err, "MCPServer image validation failed", "image", mcpServer.Spec.Image)
222226
// Update status to reflect validation failure
@@ -247,6 +251,10 @@ func (r *MCPServerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
247251
setImageValidationCondition(mcpServer, metav1.ConditionTrue,
248252
mcpv1alpha1.ConditionReasonImageValidationSuccess,
249253
"Image validation passed - image found in enforced registries")
254+
// Update status to persist the condition
255+
if statusErr := r.Status().Update(ctx, mcpServer); statusErr != nil {
256+
ctxLogger.Error(statusErr, "Failed to update MCPServer status after image validation")
257+
}
250258
}
251259

252260
// Check if the MCPServer instance is marked to be deleted

0 commit comments

Comments
 (0)