Skip to content

Handle "release not found" errors thrown on uninstall / equivalent to helm uninstall --ignore-not-found #1488

@sbocinec

Description

@sbocinec

Description

We are frequently hitting an issue with helm TF provider failing to destroy a helm_release resource when a K8s cluster (specifically GKE 1.28) throws an Internal Server Error and terraform destroy than fails with:

Error: uninstallation completed with 1 error(s): an error on the server (\\\"Internal Server Error: \\\\\\\"/api/v1/namespaces/ingress-nginx/services/ingress-nginx-controller-admission\\\\\\\": the server is currently unable to handle the request\\\") has prevented the request from succeeding (get services ingress-nginx-controller-admission)\\n\\n\"

Retrying the destroy operation then fails with release not found uninstallation error, e.g.:

Error: uninstall: Release not loaded: ingress-nginx: release: not found"

as the helm_release resource remains in the TF state, but its resources are already deleted from the K8s cluster.

In our case, we are destroying whole cluster so we want to ignore such errors. Helm CLI already provides a solution for this specific situation: helm uninstall --ignore-not-found:

$ helm uninstall --help |grep ignore-not-found
      --ignore-not-found     Treat "release not found" as a successful uninstall

Potential Terraform Configuration

#1487

Add ignore_not_found boolean attribute (defaulting to false) to the helm_release resource, enabling to ignore the error on uninstall.

resource "helm_release" "ingress_nginx" {
  name              = local.ingress_nginx
  chart             = local.ingress_nginx
  repository        = "https://kubernetes.github.io/ingress-nginx"
  version           = var.ingress_nginx_chart_version
  namespace         = local.ingress_nginx_namespace
  atomic            = true
  wait              = true
  wait_for_jobs     = true
  skip_crds         = true
  lint              = true
  cleanup_on_fail   = true
  dependency_update = false
  create_namespace  = false
  ignore_not_found  = true
}

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions