diff --git a/internal/controller/system_helm_reconciler.go b/internal/controller/system_helm_reconciler.go index 83117c42..0a92aa78 100644 --- a/internal/controller/system_helm_reconciler.go +++ b/internal/controller/system_helm_reconciler.go @@ -54,6 +54,7 @@ func (r *CozystackConfigReconciler) Reconcile(ctx context.Context, _ ctrl.Reques if !isSystemApp && !isTenantRoot { continue } + patchTarget := hr.DeepCopy() if hr.Annotations == nil { hr.Annotations = map[string]string{} @@ -62,13 +63,12 @@ func (r *CozystackConfigReconciler) Reconcile(ctx context.Context, _ ctrl.Reques if hr.Annotations[digestAnnotation] == digest { continue } + patchTarget.Annotations[digestAnnotation] = digest + patchTarget.Annotations[forceReconcileKey] = now + patchTarget.Annotations[requestedAt] = now patch := client.MergeFrom(hr.DeepCopy()) - hr.Annotations[digestAnnotation] = digest - hr.Annotations[forceReconcileKey] = now - hr.Annotations[requestedAt] = now - - if err := r.Patch(ctx, &hr, patch); err != nil { + if err := r.Patch(ctx, patchTarget, patch); err != nil { log.Error(err, "failed to patch HelmRelease", "name", hr.Name, "namespace", hr.Namespace) continue }