From ad21e7e3c89e3c1929410afc93a46dbaaac4d76b Mon Sep 17 00:00:00 2001 From: Hidde Beydals Date: Thu, 30 Mar 2023 15:22:12 +0200 Subject: [PATCH] controllers: update status patch logic 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 --- internal/controllers/helmrelease_controller.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/controllers/helmrelease_controller.go b/internal/controllers/helmrelease_controller.go index 5c09ebb8d..0de709770 100644 --- a/internal/controllers/helmrelease_controller.go +++ b/internal/controllers/helmrelease_controller.go @@ -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.DeepCopy()) + latest.Status = hr.Status + return r.Client.Status().Patch(ctx, latest, patch, client.FieldOwner(r.ControllerName)) } func (r *HelmReleaseReconciler) requestsForHelmChartChange(o client.Object) []reconcile.Request {