Fix HelmRelease reconciliation loop

Likely after the upgrade to controller-runtime v0.15.0 a regression
surfaced for long-running reconciliations of HelmRelease resources (e.g.
for charts having pre-upgrade hooks taking a few minutes to complete).
This regression would cause the controller to immediately re-run the
upgrade after a successful upgrade, thus entering an almost-endless
loop.

Apparently, the only fix to this issue is to ensure
`.Status.LastReleaseRevision` is updated as soon as possible in the
reconiliation cycle rather than wait for the update at the end of the
cycle.

Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
This commit is contained in:
Aurel Canciu 2023-06-20 14:52:50 +03:00
parent d267907aab
commit 7c75fc4d3d
No known key found for this signature in database
GPG Key ID: AB25339971E6F81E
1 changed files with 4 additions and 0 deletions

View File

@ -483,6 +483,10 @@ func (r *HelmReleaseReconciler) reconcileRelease(ctx context.Context,
}
hr.Status.LastReleaseRevision = util.ReleaseRevision(rel)
if updateStatusErr := r.patchStatus(ctx, &hr); updateStatusErr != nil {
log.Error(updateStatusErr, "unable to update status after state update")
return hr, updateStatusErr
}
if err != nil {
reason := v2.ReconciliationFailedReason