Skip to content

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

Closed
@cebernardi

Description

@cebernardi

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"?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions