Skip to content

Commit 8fb5a1e

Browse files
committed
helmrepo-oci: check before rec on type switching
When a HelmRepository with "default" spec.type is switched to "oci", the existing HelmRepository is processed by HelmRepositoryReconciler by running reconcileDelete() which removes all the previous status information and allows the HelmRepositoryOCIReconciler to process the object and add its own status data. But at times, when HelmRepositoryOCIReconciler starts processing a HelmRepository with stale status data from the client cache, it contains the stale conditions that are owned only by HelmRepositoryReconciler and isn't managed by HelmRepositoryOCIReconciler, it results in situations where Ready is marked as True with the latest generation of the object and the unmanaged stale conditions remain in the previous generation, resulting in unexpected status conditions. In the observed flaky tests, TestHelmRepositoryReconciler_ReconcileTypeUpdatePredicateFilter would fail because of stale ArtifactInStorage condition with previous generation value. This change adds a check in the HelmRepositoryOCIReconciler to start processing the object only once the stale conditions owned by HelmRepositoryReconciler have been removed. Signed-off-by: Sunny <darkowlzz@protonmail.com>
1 parent 9d640b6 commit 8fb5a1e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

controllers/helmrepository_controller_oci.go

+17
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ var helmRepositoryOCINegativeConditions = []string{
6767
meta.ReconcilingCondition,
6868
}
6969

70+
// Conditions owned by HelmRepositoryReconciler.
71+
var helmRepositoryOnlyConditions = []string{
72+
sourcev1.StorageOperationFailedCondition,
73+
sourcev1.FetchFailedCondition,
74+
sourcev1.ArtifactOutdatedCondition,
75+
sourcev1.ArtifactInStorageCondition,
76+
}
77+
7078
// +kubebuilder:rbac:groups=source.toolkit.fluxcd.io,resources=helmrepositories,verbs=get;list;watch;create;update;patch;delete
7179
// +kubebuilder:rbac:groups=source.toolkit.fluxcd.io,resources=helmrepositories/status,verbs=get;update;patch
7280
// +kubebuilder:rbac:groups=source.toolkit.fluxcd.io,resources=helmrepositories/finalizers,verbs=get;create;update;patch;delete
@@ -124,6 +132,15 @@ func (r *HelmRepositoryOCIReconciler) Reconcile(ctx context.Context, req ctrl.Re
124132
return ctrl.Result{}, client.IgnoreNotFound(err)
125133
}
126134

135+
// If the object contains any of the conditions managed by
136+
// HelmRepositoryReconciler, requeue and wait for those conditions to be
137+
// removed first before processing the object.
138+
// NOTE: This will happen only when a HelmRepository's spec.type is switched
139+
// from "default" to "oci".
140+
if conditions.HasAny(obj, helmRepositoryOnlyConditions) {
141+
return ctrl.Result{RequeueAfter: time.Second}, nil
142+
}
143+
127144
// Record suspended status metric
128145
r.RecordSuspend(ctx, obj, obj.Spec.Suspend)
129146

0 commit comments

Comments
 (0)