Terraform-provider-helm: Error: cannot re-use a name that is still in use

Created on 27 Feb 2020  路  7Comments  路  Source: hashicorp/terraform-provider-helm

Terraform Version

v0.12.21

Affected Resource(s)

  • helm_release

Terraform Configuration Files

https://github.com/ironPeakServices/infrastructure/tree/master/modules/helm

Debug Output

https://github.com/ironPeakServices/infrastructure/runs/471718289?check_suite_focus=true

Expected Behavior

successful terraform apply

Actual Behavior

Error: cannot re-use a name that is still in use

  on modules/helm/istio.tf line 9, in resource "helm_release" "istio_init":
   9: resource "helm_release" "istio_init" {

Steps to Reproduce

  1. terraform apply in CI/CD of https://github.com/ironPeakServices/infrastructure

Important Factoids

n/a

References

https://github.com/terraform-providers/terraform-provider-helm/blob/cfda75d3bd4770fa49a2ef057fe89eb5b8d8eb69/vendor/helm.sh/helm/v3/pkg/action/install.go#L358

acknowledged bug needs-investigation

Most helpful comment

I had the same problem, and after exploring all kinds of resources in k8s, I found a secret "sh.helm.release.v1.spa-demo.v1" that had been left behind after a partial deployment of my app "spa-demo" with a crashing container.
I had to examine every resource I could think of to look for left behind resources from the failed deploy and remove them manually.鈥疐ound most of them quickly, but the secret was easy to miss and also the service account.

All 7 comments

I bumped into the error after cancelling a previous run (the cloud provider stack on fulfilling a PVC request). That left some orphan resources (svc,cm,sa,...), after deleting them I could re-run the apply just fine.

@hazcod did you manage to solve this? I'm running into the same issue

@aqabawe not really :-(

I had the same problem, and after exploring all kinds of resources in k8s, I found a secret "sh.helm.release.v1.spa-demo.v1" that had been left behind after a partial deployment of my app "spa-demo" with a crashing container.
I had to examine every resource I could think of to look for left behind resources from the failed deploy and remove them manually.鈥疐ound most of them quickly, but the secret was easy to miss and also the service account.

workaround is definitely as stated in previous comment:

search and delete all related helm resource by name: secrets, services, deployments, etc.

Same here... I started with helm list and then tried to find objects... Remember to use the appropriate namespace...

  • Deleted deployment, found secret
$ helm list -n kube-system
NAME            NAMESPACE   REVISION    UPDATED                                 STATUS      CHART               APP VERSION

$ kubectl get deployments -n kube-system
NAME           READY   UP-TO-DATE   AVAILABLE   AGE
coredns        2/2     2            2           92m
external-dns   0/1     1            0           3m47s

$ kubectl delete deployment -n kube-system external-dns
deployment.apps "external-dns" deleted

$ kubectl -n kube-system get secrets | grep helm
sh.helm.release.v1.external-dns.v1               helm.sh/release.v1                    1      2m54s

$ kubectl delete secret sh.helm.release.v1.external-dns.v1 -n kube-system
secret "sh.helm.release.v1.external-dns.v1" deleted
  • Everything worked again re-running terraform apply

The possible solution to import that existing release to terraform state $ terraform import helm_release.example default/example-name.
https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release#import

Was this page helpful?
0 / 5 - 0 ratings