Skip to content

Commit cc45a89

Browse files
committed
Update status only on changes
1 parent c42bd75 commit cc45a89

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

controllers/managedcloudprofile_controller.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,16 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
7272
return ctrl.Result{}, fmt.Errorf("failed to create or patch CloudProfile: %w", err)
7373
}
7474
log.Info("applied cloud profile", "op", op)
75-
76-
if err := r.patchStatusAndCondition(ctx, &mcp, v1alpha1.SucceededReconcileStatus, metav1.Condition{
77-
Type: CloudProfileAppliedConditionType,
78-
Status: metav1.ConditionTrue,
79-
ObservedGeneration: mcp.Generation,
80-
Reason: "Applied",
81-
Message: "Generated CloudProfile applied successfully",
82-
}); err != nil {
83-
return ctrl.Result{}, fmt.Errorf("failed to patch ManagedCloudProfile status: %w", err)
75+
if op != controllerutil.OperationResultNone {
76+
if err := r.patchStatusAndCondition(ctx, &mcp, v1alpha1.SucceededReconcileStatus, metav1.Condition{
77+
Type: CloudProfileAppliedConditionType,
78+
Status: metav1.ConditionTrue,
79+
ObservedGeneration: mcp.Generation,
80+
Reason: "Applied",
81+
Message: "Generated CloudProfile applied successfully",
82+
}); err != nil {
83+
return ctrl.Result{}, fmt.Errorf("failed to patch ManagedCloudProfile status: %w", err)
84+
}
8485
}
8586
log.Info("reconciled ManagedCloudProfile")
8687
return ctrl.Result{RequeueAfter: 5 * time.Minute}, nil

0 commit comments

Comments
 (0)