Skip to content

Commit

Permalink
fix: Use a copied object to update (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
whynowy authored and ashwinidulams committed Feb 14, 2023
1 parent f0d9fc1 commit f8e7daa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pkg/reconciler/isbsvc/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ func (r *interStepBufferServiceReconciler) Reconcile(ctx context.Context, req ct
log.Errorw("Reconcile error", zap.Error(reconcileErr))
}
if r.needsUpdate(isbs, isbsCopy) {
if err := r.client.Update(ctx, isbsCopy); err != nil {
// Update with a DeepCopy because .Status will be cleaned up.
if err := r.client.Update(ctx, isbsCopy.DeepCopy()); err != nil {
return reconcile.Result{}, err
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/pipeline/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ func (r *pipelineReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
log := r.logger.With("namespace", pl.Namespace).With("pipeline", pl.Name)
plCopy := pl.DeepCopy()
ctx = logging.WithLogger(ctx, log)

result, reconcileErr := r.reconcile(ctx, plCopy)
if reconcileErr != nil {
log.Errorw("Reconcile error", zap.Error(reconcileErr))
}
plCopy.Status.LastUpdated = metav1.Now()
if needsUpdate(pl, plCopy) {
if err := r.client.Update(ctx, plCopy); err != nil {
// Update with a DeepCopy because .Status will be cleaned up.
if err := r.client.Update(ctx, plCopy.DeepCopy()); err != nil {
return result, err
}
}
Expand Down

0 comments on commit f8e7daa

Please sign in to comment.