Skip to content

Commit ace9141

Browse files
authored
Merge pull request #1430 from fluxcd/fix-1429
Fix enqueing the same revision while reconciling
2 parents 0e8bf5f + 9a44598 commit ace9141

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

internal/controller/helmrelease_indexers.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ import (
3030
v2 "github.com/fluxcd/helm-controller/api/v2"
3131
)
3232

33+
func isReadyOrReconciling(from conditions.Getter) bool {
34+
return conditions.IsReady(from) || conditions.IsReconciling(from)
35+
}
36+
3337
// requestsForHelmChartChange enqueues requests for watched HelmCharts
3438
// according to the specified index.
3539
func (r *HelmReleaseReconciler) requestsForHelmChartChange(ctx context.Context, o client.Object) []reconcile.Request {
@@ -54,9 +58,9 @@ func (r *HelmReleaseReconciler) requestsForHelmChartChange(ctx context.Context,
5458

5559
var reqs []reconcile.Request
5660
for i, hr := range list.Items {
57-
// If the HelmRelease is ready and the revision of the artifact equals to the
61+
// If the HelmRelease is ready or reconciling and the revision of the artifact equals to the
5862
// last attempted revision, we should not make a request for this HelmRelease
59-
if conditions.IsReady(&list.Items[i]) && hc.GetArtifact().HasRevision(hr.Status.GetLastAttemptedRevision()) {
63+
if isReadyOrReconciling(&list.Items[i]) && hc.GetArtifact().HasRevision(hr.Status.GetLastAttemptedRevision()) {
6064
continue
6165
}
6266
reqs = append(reqs, reconcile.Request{NamespacedName: client.ObjectKeyFromObject(&list.Items[i])})
@@ -88,7 +92,7 @@ func (r *HelmReleaseReconciler) requestsForOCIRepositoryChange(ctx context.Conte
8892

8993
var reqs []reconcile.Request
9094
for i, hr := range list.Items {
91-
// If the HelmRelease is ready and the digest of the artifact equals to the
95+
// If the HelmRelease is ready or reconciling and the digest of the artifact equals to the
9296
// last attempted revision digest, we should not make a request for this HelmRelease,
9397
// likewise if we cannot retrieve the artifact digest.
9498
digest := extractDigest(or.GetArtifact().Revision)
@@ -97,8 +101,8 @@ func (r *HelmReleaseReconciler) requestsForOCIRepositoryChange(ctx context.Conte
97101
continue
98102
}
99103

100-
// Skip if the HelmRelease is ready and the digest matches the last attempted revision digest.
101-
if conditions.IsReady(&list.Items[i]) && digest == hr.Status.LastAttemptedRevisionDigest {
104+
// Skip if the HelmRelease is ready or reconciling and the digest matches the last attempted revision digest.
105+
if isReadyOrReconciling(&list.Items[i]) && digest == hr.Status.LastAttemptedRevisionDigest {
102106
continue
103107
}
104108

@@ -136,12 +140,12 @@ func (r *HelmReleaseReconciler) requestsForExternalArtifactChange(ctx context.Co
136140
// Handle both revision formats: digest or semantic version.
137141
if strings.Contains(revision, ":") {
138142
// Skip if the HelmRelease is ready and the digest matches the last attempted revision digest.
139-
if conditions.IsReady(&list.Items[i]) && extractDigest(revision) == hr.Status.LastAttemptedRevisionDigest {
143+
if isReadyOrReconciling(&list.Items[i]) && extractDigest(revision) == hr.Status.LastAttemptedRevisionDigest {
140144
continue
141145
}
142146
} else {
143147
// Skip if the HelmRelease is ready and the revision matches the last attempted revision.
144-
if conditions.IsReady(&list.Items[i]) && revision == hr.Status.LastAttemptedRevision {
148+
if isReadyOrReconciling(&list.Items[i]) && revision == hr.Status.LastAttemptedRevision {
145149
continue
146150
}
147151
}

0 commit comments

Comments
 (0)