Skip to content

Commit 8b91717

Browse files
fix(ScalityUIComponent): skip status update when validation condition unchanged
Avoid a tight reconcile loop: when validation fails repeatedly with the same error, Status().Update() triggers an immediate watch event that bypasses the intended 30s RequeueAfter. Only update status when the condition actually changes (first failure or different error message). Made-with: Cursor
1 parent 34c8543 commit 8b91717

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

internal/controller/scalityuicomponent/controller.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,15 +391,25 @@ func (r *ScalityUIComponentReconciler) parseAndApplyConfig(ctx context.Context,
391391
if err := validateMicroAppConfig(&config); err != nil {
392392
logger.Error(err, "Invalid micro-app configuration")
393393

394-
meta.SetStatusCondition(&scalityUIComponent.Status.Conditions, metav1.Condition{
394+
newCondition := metav1.Condition{
395395
Type: ConditionTypeConfigurationRetrieved,
396396
Status: metav1.ConditionFalse,
397397
Reason: "ValidationFailed",
398398
Message: fmt.Sprintf("Configuration validation failed for image %s: %v", currentImage, err),
399-
})
399+
}
400400

401-
if statusErr := r.Status().Update(ctx, scalityUIComponent); statusErr != nil {
402-
logger.Error(statusErr, "Failed to update ScalityUIComponent status after validation failure")
401+
existing := meta.FindStatusCondition(scalityUIComponent.Status.Conditions, ConditionTypeConfigurationRetrieved)
402+
conditionChanged := existing == nil ||
403+
existing.Status != newCondition.Status ||
404+
existing.Reason != newCondition.Reason ||
405+
existing.Message != newCondition.Message
406+
407+
meta.SetStatusCondition(&scalityUIComponent.Status.Conditions, newCondition)
408+
409+
if conditionChanged {
410+
if statusErr := r.Status().Update(ctx, scalityUIComponent); statusErr != nil {
411+
logger.Error(statusErr, "Failed to update ScalityUIComponent status after validation failure")
412+
}
403413
}
404414

405415
// Remove force-refresh annotation even on failure to prevent infinite fetch loops

0 commit comments

Comments
 (0)