Skip to content

Commit ba81f82

Browse files
committed
resource/helm_release: don't skip the uninstall when the release lookup 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 #1734, so it is left alone here.
1 parent a4f1c1d commit ba81f82

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

.changelog/1867.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
`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.
3+
```

helm/resource_helm_release.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,14 +1251,20 @@ func (r *HelmRelease) Delete(ctx context.Context, req resource.DeleteRequest, re
12511251
name := state.Name.ValueString()
12521252
namespace := state.Namespace.ValueString()
12531253

1254+
// resourceReleaseExists reports false both when the release is gone and
1255+
// when the lookup itself failed, so the diagnostics have to be checked
1256+
// before treating the release as already uninstalled. Otherwise a
1257+
// transient error talking to the cluster ends the delete right here: the
1258+
// resource is dropped from state without the uninstall ever running, and
1259+
// the release stays behind in the cluster.
12541260
exists, diags := resourceReleaseExists(ctx, name, namespace, meta)
1255-
if !exists {
1256-
return
1257-
}
12581261
resp.Diagnostics.Append(diags...)
12591262
if resp.Diagnostics.HasError() {
12601263
return
12611264
}
1265+
if !exists {
1266+
return
1267+
}
12621268

12631269
// Get Helm configuration
12641270
actionConfig, err := meta.GetHelmConfiguration(ctx, namespace)

0 commit comments

Comments
 (0)