Skip to content

Commit 08bb991

Browse files
committed
Use MarkStalled, MarkReconciling from runtime
Signed-off-by: Hidde Beydals <[email protected]>
1 parent 5600c78 commit 08bb991

File tree

6 files changed

+18
-16
lines changed

6 files changed

+18
-16
lines changed

controllers/bucket_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func (r *BucketReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res
151151
case metav1.ConditionFalse:
152152
// As we are no longer reconciling and the end-state
153153
// is not ready, the reconciliation has stalled
154-
conditions.MarkTrue(obj, meta.StalledCondition, readyCondition.Reason, readyCondition.Message)
154+
conditions.MarkStalled(obj, readyCondition.Reason, readyCondition.Message)
155155
case metav1.ConditionTrue:
156156
// As we are no longer reconciling and the end-state
157157
// is ready, the reconciliation is no longer stalled
@@ -187,7 +187,7 @@ func (r *BucketReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res
187187

188188
func (r *BucketReconciler) reconcile(ctx context.Context, obj *sourcev1.Bucket) (ctrl.Result, error) {
189189
// Mark the resource as under reconciliation
190-
conditions.MarkTrue(obj, meta.ReconcilingCondition, "Reconciling", "")
190+
conditions.MarkReconciling(obj, "Reconciling", "")
191191
logr.FromContext(ctx).Info("Starting reconciliation")
192192

193193
// Reconcile the storage data

controllers/gitrepository_controller.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ func (r *GitRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Reques
120120
obj.Status.SetLastHandledReconcileRequest(v)
121121
}
122122

123+
// We are no longer reconciling
124+
conditions.Delete(obj, meta.ReconcilingCondition)
125+
123126
// Summarize Ready condition
124127
conditions.SetSummary(obj,
125128
meta.ReadyCondition,
@@ -159,7 +162,7 @@ func (r *GitRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Reques
159162
case metav1.ConditionFalse:
160163
// As we are no longer reconciling and the end-state
161164
// is not ready, the reconciliation has stalled
162-
conditions.MarkTrue(obj, meta.StalledCondition, readyCondition.Reason, readyCondition.Message)
165+
conditions.MarkStalled(obj, readyCondition.Reason, readyCondition.Message)
163166
case metav1.ConditionTrue:
164167
// As we are no longer reconciling and the end-state
165168
// is ready, the reconciliation is no longer stalled
@@ -194,6 +197,9 @@ func (r *GitRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Reques
194197
}
195198

196199
func (r *GitRepositoryReconciler) reconcile(ctx context.Context, obj *sourcev1.GitRepository) (ctrl.Result, error) {
200+
// Mark the resource as under reconciliation
201+
conditions.MarkReconciling(obj, "Reconciling", "")
202+
197203
// Reconcile the storage data
198204
if result, err := r.reconcileStorage(ctx, obj); err != nil {
199205
return result, err

controllers/helmchart_controller.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func (r *HelmChartReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
187187
case metav1.ConditionFalse:
188188
// As we are no longer reconciling and the end-state
189189
// is not ready, the reconciliation has stalled
190-
conditions.MarkTrue(obj, meta.StalledCondition, readyCondition.Reason, readyCondition.Message)
190+
conditions.MarkStalled(obj, readyCondition.Reason, readyCondition.Message)
191191
case metav1.ConditionTrue:
192192
// As we are no longer reconciling and the end-state
193193
// is ready, the reconciliation is no longer stalled
@@ -223,7 +223,7 @@ func (r *HelmChartReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
223223

224224
func (r *HelmChartReconciler) reconcile(ctx context.Context, obj *sourcev1.HelmChart) (ctrl.Result, error) {
225225
// Mark the resource as under reconciliation
226-
conditions.MarkTrue(obj, meta.ReconcilingCondition, "Reconciling", "")
226+
conditions.MarkReconciling(obj, "Reconciling", "")
227227

228228
// Reconcile the storage data
229229
if result, err := r.reconcileStorage(ctx, obj); err != nil {
@@ -232,19 +232,15 @@ func (r *HelmChartReconciler) reconcile(ctx context.Context, obj *sourcev1.HelmC
232232

233233
// Reconcile the source
234234
var sourcePath string
235-
defer func() {
236-
os.RemoveAll(sourcePath)
237-
}()
235+
defer os.RemoveAll(sourcePath)
238236
if result, err := r.reconcileSource(ctx, obj, &sourcePath); err != nil || conditions.IsFalse(obj, sourcev1.SourceAvailableCondition) {
239237
return result, err
240238
}
241239

242240
// Reconcile the chart using the source data
243241
var artifact sourcev1.Artifact
244242
var resultPath string
245-
defer func() {
246-
os.RemoveAll(resultPath)
247-
}()
243+
defer os.RemoveAll(resultPath)
248244
if result, err := r.reconcileChart(ctx, obj, sourcePath, &artifact, &resultPath); err != nil {
249245
return result, err
250246
}

controllers/helmrepository_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func (r *HelmRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Reque
150150
case metav1.ConditionFalse:
151151
// As we are no longer reconciling and the end-state
152152
// is not ready, the reconciliation has stalled
153-
conditions.MarkTrue(obj, meta.StalledCondition, readyCondition.Reason, readyCondition.Message)
153+
conditions.MarkStalled(obj, readyCondition.Reason, readyCondition.Message)
154154
case metav1.ConditionTrue:
155155
// As we are no longer reconciling and the end-state
156156
// is ready, the reconciliation is no longer stalled
@@ -186,7 +186,7 @@ func (r *HelmRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Reque
186186

187187
func (r *HelmRepositoryReconciler) reconcile(ctx context.Context, obj *sourcev1.HelmRepository) (ctrl.Result, error) {
188188
// Mark the resource as under reconciliation
189-
conditions.MarkTrue(obj, meta.ReconcilingCondition, "Reconciling", "")
189+
conditions.MarkReconciling(obj, "Reconciling", "")
190190

191191
// Reconcile the storage data
192192
if result, err := r.reconcileStorage(ctx, obj); err != nil {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/fluxcd/pkg/gitutil v0.1.0
1313
github.com/fluxcd/pkg/helmtestserver v0.2.0
1414
github.com/fluxcd/pkg/lockedfile v0.1.0
15-
github.com/fluxcd/pkg/runtime v0.13.0-rc.1
15+
github.com/fluxcd/pkg/runtime v0.13.0-rc.2
1616
github.com/fluxcd/pkg/ssh v0.1.0
1717
github.com/fluxcd/pkg/testserver v0.1.0
1818
github.com/fluxcd/pkg/untar v0.1.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ github.com/fluxcd/pkg/helmtestserver v0.2.0 h1:cE7YHDmrWI0hr9QpaaeQ0vQ16Z0IiqZKi
237237
github.com/fluxcd/pkg/helmtestserver v0.2.0/go.mod h1:Yie8n7xuu5Nvf1Q7302LKsubJhWpwzCaK0rLJvmF7aI=
238238
github.com/fluxcd/pkg/lockedfile v0.1.0 h1:YsYFAkd6wawMCcD74ikadAKXA4s2sukdxrn7w8RB5eo=
239239
github.com/fluxcd/pkg/lockedfile v0.1.0/go.mod h1:EJLan8t9MiOcgTs8+puDjbE6I/KAfHbdvIy9VUgIjm8=
240-
github.com/fluxcd/pkg/runtime v0.13.0-rc.1 h1:eeyo7fiJ2zk2hl5ClEzFZrru/ycY5/IU8j8Ncae32X8=
241-
github.com/fluxcd/pkg/runtime v0.13.0-rc.1/go.mod h1:TmvE2cJl1QkgZNmmlr7XUKoWDQwUiM5/wTUxXsQVoc8=
240+
github.com/fluxcd/pkg/runtime v0.13.0-rc.2 h1:+4uTEg+CU++hlr7NpOP4KYp60MtHDOgYvpz/74tbATg=
241+
github.com/fluxcd/pkg/runtime v0.13.0-rc.2/go.mod h1:TmvE2cJl1QkgZNmmlr7XUKoWDQwUiM5/wTUxXsQVoc8=
242242
github.com/fluxcd/pkg/ssh v0.1.0 h1:cym2bqiT4IINOdLV0J6GYxer16Ii/7b2+RlK3CG+CnA=
243243
github.com/fluxcd/pkg/ssh v0.1.0/go.mod h1:KUuVhaB6AX3IHTGCd3Ti/nesn5t1Nz4zCThFkkjHctM=
244244
github.com/fluxcd/pkg/testserver v0.1.0 h1:nOYgM1HYFZNNSUFykuWDmrsxj4jQxUCvmLHWOQeqmyA=

0 commit comments

Comments
 (0)