Skip to content
This repository was archived by the owner on Jan 25, 2019. It is now read-only.

Commit 0a420ad

Browse files
authored
Merge pull request #47 from joelanford/bugfix/reconciliation
pkg/helm,pkg/helm/controller: fixing reconciliation loop bugs
2 parents 5a7f6f8 + ef2cfaf commit 0a420ad

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

helm-app-operator/pkg/helm/controller/reconcile.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (r helmOperatorReconciler) Reconcile(request reconcile.Request) (reconcile.
4242

4343
if o.GetResourceVersion() == lastResourceVersion {
4444
logrus.Infof("skipping %s because resource version has not changed", request.NamespacedName)
45-
return reconcile.Result{}, nil
45+
return reconcile.Result{RequeueAfter: r.ResyncPeriod}, nil
4646
}
4747

4848
updatedResource, err := r.Installer.InstallRelease(o)

helm-app-operator/pkg/helm/helm.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,20 @@ func (c installer) InstallRelease(r *v1alpha1.HelmApp) (*v1alpha1.HelmApp, error
162162
// UninstallRelease accepts a custom resource, uninstalls the existing Helm release
163163
// using Tiller, and returns the custom resource with updated `status`.
164164
func (c installer) UninstallRelease(r *v1alpha1.HelmApp) (*v1alpha1.HelmApp, error) {
165+
// Get history of this release
166+
h, err := c.storageBackend.History(releaseName(r))
167+
if err != nil {
168+
return r, err
169+
}
170+
171+
// If there is no history, the release has already been uninstalled,
172+
// so there's nothing to do.
173+
if len(h) == 0 {
174+
return r, nil
175+
}
176+
165177
tiller := tillerRendererForCR(r, c.storageBackend, c.tillerKubeClient)
166-
_, err := tiller.UninstallRelease(context.TODO(), &services.UninstallReleaseRequest{
178+
_, err = tiller.UninstallRelease(context.TODO(), &services.UninstallReleaseRequest{
167179
Name: releaseName(r),
168180
Purge: true,
169181
})

0 commit comments

Comments
 (0)