Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
fix: add mergesource get before update
Browse files Browse the repository at this point in the history
  • Loading branch information
jonwinton committed Nov 14, 2023
1 parent 7399f45 commit 636412f
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions controllers/mergesource_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,21 @@ func (r *MergeSourceReconciler) reconcileMergeSource(
output += data
}

mergeSource.Status.Output = output
mergeSource.SetStatusCondition(cmmcv1beta1.MergeSourceConditionReady(len(sources)))
if err := r.Status().Update(ctx, mergeSource); err != nil {
// Retrieve new copy of the current MergeSource so that we're updating the most recent
// version of the resource when we update its status.
ms := &cmmcv1beta1.MergeSource{}
err = r.Get(ctx, types.NamespacedName{
Namespace: mergeSource.Namespace,
Name: mergeSource.Name,
}, ms)
if err != nil {
return false, errors.Wrapf(err, "error retrieving mergeSource %s during status update phase", mergeSource.Name)
}

// Use the newly retrieved MergeSource to update the status.
ms.Status.Output = output
ms.SetStatusCondition(cmmcv1beta1.MergeSourceConditionReady(len(sources)))
if err = r.Status().Update(ctx, ms); err != nil {
return false, errors.Wrap(err, "failed updating status after accumulating watched resources")
}

Expand Down

0 comments on commit 636412f

Please sign in to comment.