Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perform an installation if last release status is "uninstalled" #367

Closed
cebernardi opened this issue Nov 26, 2021 · 3 comments · Fixed by #738
Closed

Perform an installation if last release status is "uninstalled" #367

cebernardi opened this issue Nov 26, 2021 · 3 comments · Fixed by #738

Comments

@cebernardi
Copy link
Contributor

During a HelmRelease reconciliation cycle, Helm-Controller decides to perform an install or an upgrade based on the fact that a revision of a release with the provided name exists ( https://github.com/fluxcd/helm-controller/blob/main/controllers/helmrelease_controller.go#L291 ).

if at least a revision exists, it performs an upgrade, otherwise an install: (

if rel == nil {
r.event(ctx, hr, revision, events.EventSeverityInfo, "Helm install has started")
deployAction = hr.Spec.GetInstall()
rel, err = run.Install(hr, chart, values)
err = r.handleHelmActionResult(ctx, &hr, revision, err, deployAction.GetDescription(),
v2.ReleasedCondition, v2.InstallSucceededReason, v2.InstallFailedReason)
} else {
r.event(ctx, hr, revision, events.EventSeverityInfo, "Helm upgrade has started")
deployAction = hr.Spec.GetUpgrade()
rel, err = run.Upgrade(hr, chart, values)
err = r.handleHelmActionResult(ctx, &hr, revision, err, deployAction.GetDescription(),
v2.ReleasedCondition, v2.UpgradeSucceededReason, v2.UpgradeFailedReason)
}
)

For HelmReleases configured with

uninstall:
  keepHistory: true
install:
  remediation:
    retries: 3

this behavior creates a situation where, if the first installation fails, the uninstall performed before the following installation attempt doesn't purge the history, but retains a record of this particular release being in status "uninstalled".

REVISION        UPDATED                         STATUS          CHART           APP VERSION     DESCRIPTION
1               Thu Nov 25 17:01:58 2021        uninstalled     mychart-0.0.3     1.2.0           Uninstallation complete

The next reconciliation will find this revision when calling run.ObserveLastRelease and will decide to perform an upgrade, which will fail because the underlying helm logic returns a "my-chart has no deployed releases" error.

From this issue, it looks like this is helm intended behavior for the upgrade action, and instead, a user should recover from this situation performing a helm install --replace.

However, in this situation, Helm-Controller won't perform any more installations of the release, and any further modification will end up in a upgrade.

Is it possible to change this behavior and perform an install if the release last status is "uninstalled"?

@hiddeco
Copy link
Member

hiddeco commented Nov 26, 2021

Should be taken into account as part of #324

@cebernardi
Copy link
Contributor Author

to add some more context and explanation I've opened a draft PR for a possible solution (if this is confirmed as something to change by the maintainers): #368

@cebernardi
Copy link
Contributor Author

@hiddeco from your comment it looks like you agree that the current behavior should change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants