From 7044fdeaf76902da3f3f5440e9c4ba53228a16e8 Mon Sep 17 00:00:00 2001 From: Joe Lanford Date: Mon, 22 Apr 2019 20:44:55 -0400 Subject: [PATCH] pkg/helm/controller/reconcile.go: fix conditions logic (#1321) * pkg/helm/controller/reconcile.go: fix conditions logic If a change is made to the CR spec that causes a release failure, a ConditionReleaseFailed is added to the status conditions. If that change is then reverted to its previous state, the operator will stop attempting the release and will resume reconciling. In this case, we need to remove the ConditionReleaseFailed because the failing release is no longer being attempted. * CHANGELOG.md: add bug fix #1321 --- CHANGELOG.md | 2 ++ pkg/helm/controller/reconcile.go | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc87b55e2d..3c8249083a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ ### Bug Fixes +- In Helm-based operators, when a custom resource with a failing release is reverted back to a working state, the `ReleaseFailed` condition is now correctly removed. ([#1321](https://github.com/operator-framework/operator-sdk/pull/1321)) + ## v0.7.0 ### Added diff --git a/pkg/helm/controller/reconcile.go b/pkg/helm/controller/reconcile.go index a13592813c..f4407d6e97 100644 --- a/pkg/helm/controller/reconcile.go +++ b/pkg/helm/controller/reconcile.go @@ -242,6 +242,14 @@ func (r HelmOperatorReconciler) Reconcile(request reconcile.Request) (reconcile. return reconcile.Result{RequeueAfter: r.ReconcilePeriod}, err } + // If a change is made to the CR spec that causes a release failure, a + // ConditionReleaseFailed is added to the status conditions. If that change + // is then reverted to its previous state, the operator will stop + // attempting the release and will resume reconciling. In this case, we + // need to remove the ConditionReleaseFailed because the failing release is + // no longer being attempted. + status.RemoveCondition(types.ConditionReleaseFailed) + expectedRelease, err := manager.ReconcileRelease(context.TODO()) if err != nil { log.Error(err, "Failed to reconcile release")