Skip to content

resource/helm_release: don't skip the uninstall when the release lookup fails - #1867

Open
bitte-ein-bit wants to merge 1 commit into
hashicorp:mainfrom
nitrobox:b-helm-release-read-transient-error
Open

resource/helm_release: don't skip the uninstall when the release lookup fails#1867
bitte-ein-bit wants to merge 1 commit into
hashicorp:mainfrom
nitrobox:b-helm-release-read-transient-error

Conversation

@bitte-ein-bit

@bitte-ein-bit bitte-ein-bit commented Jul 31, 2026

Copy link
Copy Markdown

Rollback Plan

If a change needs to be reverted, we will publish an updated version of the library.

Changes to Security Controls

No changes to security controls.

Description

resourceReleaseExists returns false in two very different situations: the release really is gone, and the lookup against the cluster failed. The two are only distinguishable through the diagnostics it returns alongside the boolean.

Delete acts on the boolean before appending those diagnostics, so the error is discarded:

exists, diags := resourceReleaseExists(ctx, name, namespace, meta)
if !exists {
	return
}
resp.Diagnostics.Append(diags...)   // never reached in the error case

A failed lookup is therefore treated as "already uninstalled". Delete returns without an error, the framework removes the resource from state, and the uninstall never runs — the release is left behind in the cluster with nothing tracking it any more. Recovering means importing it again or cleaning up with helm by hand.

We ran into the underlying failure on AKS during a brief API server outage: the same hiccup surfaced in the kubernetes provider as

Error: Invalid configuration for API client
Get "https://…azmk8s.io:443/apis": net/http: TLS handshake timeout

which was retried and succeeded, while the helm provider swallowed it. It hit us on the Read path rather than Delete (a release was dropped from state and the next apply failed with cannot re-use a name that is still in use), but Delete has the same ordering and a worse outcome, since the release is not just untracked but silently left running.

This moves the diagnostics check ahead of the exists check, so a failed lookup surfaces as an error instead of being interpreted as absence. Create already handles it in this order.

Scope: the identical ordering issue in Read is already addressed in #1734, so this PR deliberately leaves Read alone to avoid a conflicting change. #1734 does not touch Delete; the two are complementary and can merge in either order.

Acceptance tests

  • Have you added an acceptance test for the functionality being added?

No acceptance test: reproducing this requires the API server lookup to fail at a specific point during destroy, which the existing test harness has no hook for. Happy to add one if a maintainer can point at a suitable way to inject the failure.

Release Note

`resource/helm_release`: Fix `Delete` skipping the uninstall and dropping the resource from state when the release lookup fails because of a transient error (for example `net/http: TLS handshake timeout`), leaving the release behind in the cluster.

References

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

@bitte-ein-bit
bitte-ein-bit requested review from a team, iam404 and rigalGit as code owners July 31, 2026 13:35
@hashicorp-cla-app

hashicorp-cla-app Bot commented Jul 31, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@hashicorp-cla-app

Copy link
Copy Markdown

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes

Have you signed the CLA already but the status is still pending? Recheck it.

…up fails

resourceReleaseExists reports false both when a release is genuinely absent
and when the lookup against the cluster failed, telling the two apart only
through the returned diagnostics. Delete acts on the boolean before appending
those diagnostics, so a failed lookup is indistinguishable from "already
uninstalled": the function returns early, the resource is removed from state,
and the uninstall never runs. The release stays behind in the cluster with
nothing tracking it.

We ran into the underlying error during a short API server outage on AKS,
where the same hiccup surfaced in the kubernetes provider as
"net/http: TLS handshake timeout".

Check the diagnostics first, which is what Create already does.

The identical ordering issue in Read is being fixed in hashicorp#1734, so it is left
alone here.
@bitte-ein-bit
bitte-ein-bit force-pushed the b-helm-release-read-transient-error branch from c3e49ff to ba81f82 Compare July 31, 2026 13:41
@bitte-ein-bit bitte-ein-bit changed the title resource/helm_release: don't drop the release from state when the lookup fails resource/helm_release: don't skip the uninstall when the release lookup fails Jul 31, 2026
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 this pull request may close these issues.

1 participant