diff --git a/controllers/bucket_controller.go b/controllers/bucket_controller.go index c3f4ba230..556940de1 100644 --- a/controllers/bucket_controller.go +++ b/controllers/bucket_controller.go @@ -151,7 +151,7 @@ func (r *BucketReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res case metav1.ConditionFalse: // As we are no longer reconciling and the end-state // is not ready, the reconciliation has stalled - conditions.MarkTrue(obj, meta.StalledCondition, readyCondition.Reason, readyCondition.Message) + conditions.MarkStalled(obj, readyCondition.Reason, readyCondition.Message) case metav1.ConditionTrue: // As we are no longer reconciling and the end-state // is ready, the reconciliation is no longer stalled @@ -187,7 +187,7 @@ func (r *BucketReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res func (r *BucketReconciler) reconcile(ctx context.Context, obj *sourcev1.Bucket) (ctrl.Result, error) { // Mark the resource as under reconciliation - conditions.MarkTrue(obj, meta.ReconcilingCondition, "Reconciling", "") + conditions.MarkReconciling(obj, "Reconciling", "") logr.FromContext(ctx).Info("Starting reconciliation") // Reconcile the storage data diff --git a/controllers/gitrepository_controller.go b/controllers/gitrepository_controller.go index 0a1c516fc..2fa014cc5 100644 --- a/controllers/gitrepository_controller.go +++ b/controllers/gitrepository_controller.go @@ -120,6 +120,9 @@ func (r *GitRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Reques obj.Status.SetLastHandledReconcileRequest(v) } + // We are no longer reconciling + conditions.Delete(obj, meta.ReconcilingCondition) + // Summarize Ready condition conditions.SetSummary(obj, meta.ReadyCondition, @@ -159,7 +162,7 @@ func (r *GitRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Reques case metav1.ConditionFalse: // As we are no longer reconciling and the end-state // is not ready, the reconciliation has stalled - conditions.MarkTrue(obj, meta.StalledCondition, readyCondition.Reason, readyCondition.Message) + conditions.MarkStalled(obj, readyCondition.Reason, readyCondition.Message) case metav1.ConditionTrue: // As we are no longer reconciling and the end-state // is ready, the reconciliation is no longer stalled @@ -194,6 +197,9 @@ func (r *GitRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Reques } func (r *GitRepositoryReconciler) reconcile(ctx context.Context, obj *sourcev1.GitRepository) (ctrl.Result, error) { + // Mark the resource as under reconciliation + conditions.MarkReconciling(obj, "Reconciling", "") + // Reconcile the storage data if result, err := r.reconcileStorage(ctx, obj); err != nil { return result, err diff --git a/controllers/helmchart_controller.go b/controllers/helmchart_controller.go index 1a4d9ce73..479e9aa37 100644 --- a/controllers/helmchart_controller.go +++ b/controllers/helmchart_controller.go @@ -187,7 +187,7 @@ func (r *HelmChartReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( case metav1.ConditionFalse: // As we are no longer reconciling and the end-state // is not ready, the reconciliation has stalled - conditions.MarkTrue(obj, meta.StalledCondition, readyCondition.Reason, readyCondition.Message) + conditions.MarkStalled(obj, readyCondition.Reason, readyCondition.Message) case metav1.ConditionTrue: // As we are no longer reconciling and the end-state // is ready, the reconciliation is no longer stalled @@ -223,7 +223,7 @@ func (r *HelmChartReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( func (r *HelmChartReconciler) reconcile(ctx context.Context, obj *sourcev1.HelmChart) (ctrl.Result, error) { // Mark the resource as under reconciliation - conditions.MarkTrue(obj, meta.ReconcilingCondition, "Reconciling", "") + conditions.MarkReconciling(obj, "Reconciling", "") // Reconcile the storage data if result, err := r.reconcileStorage(ctx, obj); err != nil { @@ -232,9 +232,7 @@ func (r *HelmChartReconciler) reconcile(ctx context.Context, obj *sourcev1.HelmC // Reconcile the source var sourcePath string - defer func() { - os.RemoveAll(sourcePath) - }() + defer os.RemoveAll(sourcePath) if result, err := r.reconcileSource(ctx, obj, &sourcePath); err != nil || conditions.IsFalse(obj, sourcev1.SourceAvailableCondition) { return result, err } @@ -242,9 +240,7 @@ func (r *HelmChartReconciler) reconcile(ctx context.Context, obj *sourcev1.HelmC // Reconcile the chart using the source data var artifact sourcev1.Artifact var resultPath string - defer func() { - os.RemoveAll(resultPath) - }() + defer os.RemoveAll(resultPath) if result, err := r.reconcileChart(ctx, obj, sourcePath, &artifact, &resultPath); err != nil { return result, err } diff --git a/controllers/helmrepository_controller.go b/controllers/helmrepository_controller.go index 4e0f9c784..0475a7b63 100644 --- a/controllers/helmrepository_controller.go +++ b/controllers/helmrepository_controller.go @@ -150,7 +150,7 @@ func (r *HelmRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Reque case metav1.ConditionFalse: // As we are no longer reconciling and the end-state // is not ready, the reconciliation has stalled - conditions.MarkTrue(obj, meta.StalledCondition, readyCondition.Reason, readyCondition.Message) + conditions.MarkStalled(obj, readyCondition.Reason, readyCondition.Message) case metav1.ConditionTrue: // As we are no longer reconciling and the end-state // is ready, the reconciliation is no longer stalled @@ -186,7 +186,7 @@ func (r *HelmRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Reque func (r *HelmRepositoryReconciler) reconcile(ctx context.Context, obj *sourcev1.HelmRepository) (ctrl.Result, error) { // Mark the resource as under reconciliation - conditions.MarkTrue(obj, meta.ReconcilingCondition, "Reconciling", "") + conditions.MarkReconciling(obj, "Reconciling", "") // Reconcile the storage data if result, err := r.reconcileStorage(ctx, obj); err != nil { diff --git a/go.mod b/go.mod index 22a535b34..fdfd259b2 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/fluxcd/pkg/gitutil v0.1.0 github.com/fluxcd/pkg/helmtestserver v0.2.0 github.com/fluxcd/pkg/lockedfile v0.1.0 - github.com/fluxcd/pkg/runtime v0.13.0-rc.1 + github.com/fluxcd/pkg/runtime v0.13.0-rc.2 github.com/fluxcd/pkg/ssh v0.1.0 github.com/fluxcd/pkg/testserver v0.1.0 github.com/fluxcd/pkg/untar v0.1.0 diff --git a/go.sum b/go.sum index a4d6d096d..3119b0a1c 100644 --- a/go.sum +++ b/go.sum @@ -237,8 +237,8 @@ github.com/fluxcd/pkg/helmtestserver v0.2.0 h1:cE7YHDmrWI0hr9QpaaeQ0vQ16Z0IiqZKi github.com/fluxcd/pkg/helmtestserver v0.2.0/go.mod h1:Yie8n7xuu5Nvf1Q7302LKsubJhWpwzCaK0rLJvmF7aI= github.com/fluxcd/pkg/lockedfile v0.1.0 h1:YsYFAkd6wawMCcD74ikadAKXA4s2sukdxrn7w8RB5eo= github.com/fluxcd/pkg/lockedfile v0.1.0/go.mod h1:EJLan8t9MiOcgTs8+puDjbE6I/KAfHbdvIy9VUgIjm8= -github.com/fluxcd/pkg/runtime v0.13.0-rc.1 h1:eeyo7fiJ2zk2hl5ClEzFZrru/ycY5/IU8j8Ncae32X8= -github.com/fluxcd/pkg/runtime v0.13.0-rc.1/go.mod h1:TmvE2cJl1QkgZNmmlr7XUKoWDQwUiM5/wTUxXsQVoc8= +github.com/fluxcd/pkg/runtime v0.13.0-rc.2 h1:+4uTEg+CU++hlr7NpOP4KYp60MtHDOgYvpz/74tbATg= +github.com/fluxcd/pkg/runtime v0.13.0-rc.2/go.mod h1:TmvE2cJl1QkgZNmmlr7XUKoWDQwUiM5/wTUxXsQVoc8= github.com/fluxcd/pkg/ssh v0.1.0 h1:cym2bqiT4IINOdLV0J6GYxer16Ii/7b2+RlK3CG+CnA= github.com/fluxcd/pkg/ssh v0.1.0/go.mod h1:KUuVhaB6AX3IHTGCd3Ti/nesn5t1Nz4zCThFkkjHctM= github.com/fluxcd/pkg/testserver v0.1.0 h1:nOYgM1HYFZNNSUFykuWDmrsxj4jQxUCvmLHWOQeqmyA=