Skip to content

Commit a53c47f

Browse files
committed
Restores return early Reconcile loop
Signed-off-by: Brett Tofel <[email protected]>
1 parent c6d6f07 commit a53c47f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

internal/controllers/clusterextension_controller.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,16 @@ func (r *ClusterExtensionReconciler) Reconcile(ctx context.Context, req ctrl.Req
119119
reconciledExt := existingExt.DeepCopy()
120120
res, reconcileErr := r.reconcile(ctx, reconciledExt)
121121

122+
var updateErrors []error
123+
122124
// Do checks before any Update()s, as Update() may modify the resource structure!
123125
updateStatus := !equality.Semantic.DeepEqual(existingExt.Status, reconciledExt.Status)
124126
updateFinalizers := !equality.Semantic.DeepEqual(existingExt.Finalizers, reconciledExt.Finalizers)
125127
unexpectedFieldsChanged := checkForUnexpectedFieldChange(*existingExt, *reconciledExt)
126128

127129
if updateStatus {
128130
if updateErr := r.Client.Status().Update(ctx, reconciledExt); updateErr != nil {
129-
return res, utilerrors.NewAggregate([]error{reconcileErr, updateErr})
131+
updateErrors = append(updateErrors, updateErr)
130132
}
131133
}
132134

@@ -136,11 +138,15 @@ func (r *ClusterExtensionReconciler) Reconcile(ctx context.Context, req ctrl.Req
136138

137139
if updateFinalizers {
138140
if updateErr := r.Client.Update(ctx, reconciledExt); updateErr != nil {
139-
return res, utilerrors.NewAggregate([]error{reconcileErr, updateErr})
141+
updateErrors = append(updateErrors, updateErr)
140142
}
141143
}
142144

143-
return res, utilerrors.NewAggregate([]error{reconcileErr, nil})
145+
if reconcileErr != nil {
146+
updateErrors = append(updateErrors, reconcileErr)
147+
}
148+
149+
return res, utilerrors.NewAggregate(updateErrors)
144150
}
145151

146152
// ensureAllConditionsWithReason checks that all defined condition types exist in the given ClusterExtension,

0 commit comments

Comments
 (0)