Skip to content

Commit

Permalink
controllers: update status patch logic
Browse files Browse the repository at this point in the history
Hotfix to deal with the issue, as we will soon be moving to the patch
logic used by already rewritten controllers. This is however a pain for
many users, so worth solving now.

Signed-off-by: Hidde Beydals <[email protected]>
  • Loading branch information
hiddeco committed Mar 30, 2023
1 parent acf0cda commit 4310d42
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions internal/controllers/helmrelease_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -751,12 +751,13 @@ func (r *HelmReleaseReconciler) handleHelmActionResult(ctx context.Context,
}

func (r *HelmReleaseReconciler) patchStatus(ctx context.Context, hr *v2.HelmRelease) error {
key := client.ObjectKeyFromObject(hr)
latest := &v2.HelmRelease{}
if err := r.Client.Get(ctx, key, latest); err != nil {
if err := r.Client.Get(ctx, client.ObjectKeyFromObject(hr), latest); err != nil {
return err
}
return r.Client.Status().Patch(ctx, hr, client.MergeFrom(latest))
patch := client.MergeFrom(latest)
latest.Status = hr.Status
return r.Status().Patch(ctx, latest, patch, client.FieldOwner(r.ControllerName))
}

func (r *HelmReleaseReconciler) requestsForHelmChartChange(o client.Object) []reconcile.Request {
Expand Down

0 comments on commit 4310d42

Please sign in to comment.