Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fatal error: concurrent map writes when deploying multiple resources #33

Closed
rporres opened this issue Dec 19, 2017 · 2 comments
Closed

Comments

@rporres
Copy link

rporres commented Dec 19, 2017

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

v0.10.7

Affected Resource(s)

helm_chart

Terraform Configuration Files

provider "helm" {
  kubernetes {
    config_context = "minikube"
  }
}

resource "helm_chart" "kube_lego" {
  name           = "test-kube-lego"
  repository_url = "https://kubernetes-charts.storage.googleapis.com"
  chart          = "stable/kube-lego"
  version        = "0.1.11"

  set {
    name  = "config.LEGO_URL"
    value = "https://acme-staging.api.letsencrypt.org/directory"
  }

  set {
    name  = "config.LEGO_EMAIL"
    value = "rafa@sourced.tech"
  }
}

resource "helm_chart" "kube_cert_manager" {
  name           = "test-kube-cert-manager"
  repository_url = "https://src-d.github.io/charts/"
  chart          = "srcd/kube-cert-manager"
  version        = "0.1.0"

  set {
    name  = "args.acmeUrl"
    value = "https://acme-staging.api.letsencrypt.org/directory"
  }

  set {
    name  = "args.class"
    value = "default"
  }

  set {
    name  = "args.defaultEmail"
    value = "xxx@yyy.com"
  }

  set {
    name  = "google.base64JsonKey"
    value = "eyJhIjoxfQo="
  }

  set {
    name  = "google.project"
    value = "my-project"
  }

  set {
    name  = "installCertificateType"
    value = true
  }
}

Debug Output

Part of the log with the error

2017-12-04T19:53:58.229+0100 [DEBUG] plugin.terraform-provider-helm: fatal error: concurrent map writes
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm:
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm: goroutine 24 [running]:
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm: runtime.throw(0x2d64dcd, 0x15)
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm:    /home/travis/.gimme/versions/go1.9.linux.amd64/src/runtime/panic.go:605 +0x95 fp=0xc4208731e0 sp=0xc4208731c0 pc=0x102a715
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm: runtime.mapassign_faststr(0x2ac6660, 0xc420828480, 0x2d59513, 0xc, 0xc420816c30)
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm:    /home/travis/.gimme/versions/go1.9.linux.amd64/src/runtime/hashmap_fast.go:685 +0x4da fp=0xc420873260 sp=0xc4208731e0 pc=0x100cb4a
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm: github.com/mcuadros/terraform-provider-helm/vendor/github.com/hashicorp/terraform/helper/schema.(*DiffFieldReader).ReadField(0xc420828420, 0xc42049a390, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc4208735f8, ...)
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm:    /home/travis/gopath/src/github.com/mcuadros/terraform-provider-helm/vendor/github.com/hashicorp/terraform/helper/schema/field_reader_diff.go:80 +0x3a6 fp=0xc4208734c0 sp=0xc420873260 pc=0x16a1976
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm: github.com/mcuadros/terraform-provider-helm/vendor/github.com/hashicorp/terraform/helper/schema.(*MultiLevelFieldReader).ReadFieldMerge(0xc420544aa0, 0xc42049a390, 0x1, 0x1, 0x2d4ee09, 0x3, 0x0, 0x0, 0x0, 0x0, ...)
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm:    /home/travis/gopath/src/github.com/mcuadros/terraform-provider-helm/vendor/github.com/hashicorp/terraform/helper/schema/field_reader_multi.go:45 +0x260 fp=0xc420873608 sp=0xc4208734c0 pc=0x16a5890
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm: github.com/mcuadros/terraform-provider-helm/vendor/github.com/hashicorp/terraform/helper/schema.(*ResourceData).get(0xc42034c070, 0xc42049a390, 0x1, 0x1, 0xc42049a308, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm:    /home/travis/gopath/src/github.com/mcuadros/terraform-provider-helm/vendor/github.com/hashicorp/terraform/helper/schema/resource_data.go:493 +0x3ed fp=0xc420873740 sp=0xc420873608 pc=0x16b0dad
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm: github.com/mcuadros/terraform-provider-helm/vendor/github.com/hashicorp/terraform/helper/schema.(*ResourceData).getRaw(0xc42034c070, 0x2d59513, 0xc, 0x2f06e08, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm:    /home/travis/gopath/src/github.com/mcuadros/terraform-provider-helm/vendor/github.com/hashicorp/terraform/helper/schema/resource_data.go:129 +0x95 fp=0xc4208737d8 sp=0xc420873740 pc=0x16ae785
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm: github.com/mcuadros/terraform-provider-helm/vendor/github.com/hashicorp/terraform/helper/schema.(*ResourceData).GetOk(0xc42034c070, 0x2d59513, 0xc, 0x29fb100, 0xc420815fd0, 0xc4205ac401)
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm:    /home/travis/gopath/src/github.com/mcuadros/terraform-provider-helm/vendor/github.com/hashicorp/terraform/helper/schema/resource_data.go:90 +0x5f fp=0xc420873888 sp=0xc4208737d8 pc=0x16ae4bf
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm: github.com/mcuadros/terraform-provider-helm/vendor/github.com/hashicorp/terraform/helper/schema.(*ResourceData).Get(0xc42034c070, 0x2d59513, 0xc, 0x29fb100, 0xc420815fd0)
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm:    /home/travis/gopath/src/github.com/mcuadros/terraform-provider-helm/vendor/github.com/hashicorp/terraform/helper/schema/resource_data.go:69 +0x3f fp=0xc4208738c8 sp=0xc420873888 pc=0x16ae29f
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm: github.com/mcuadros/terraform-provider-helm/helm.(*Meta).installTillerIfNeeded(0xc420801c20, 0xc42034c070, 0xc4205ac3f0, 0x46fbf78)
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm:    /home/travis/gopath/src/github.com/mcuadros/terraform-provider-helm/helm/provider.go:315 +0xc1 fp=0xc420873938 sp=0xc4208738c8 pc=0x28d6421
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm: github.com/mcuadros/terraform-provider-helm/helm.(*Meta).connect(0xc420801c20, 0x46926c8, 0x0)
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm:    /home/travis/gopath/src/github.com/mcuadros/terraform-provider-helm/helm/provider.go:215 +0x38 fp=0xc420873968 sp=0xc420873938 pc=0x28d5268
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm: github.com/mcuadros/terraform-provider-helm/helm.(*Meta).GetHelmClient(0xc420801c20, 0x0, 0xc42078b9d0, 0x1010eb8, 0x70)
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm:    /home/travis/gopath/src/github.com/mcuadros/terraform-provider-helm/helm/provider.go:206 +0x66 fp=0xc420873990 sp=0xc420873968 pc=0x28d51e6
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm: github.com/mcuadros/terraform-provider-helm/helm.resourceChartExists(0xc4205ac3f0, 0x2bfb000, 0xc420801c20, 0x24, 0x3ec5340, 0x0)
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm:    /home/travis/gopath/src/github.com/mcuadros/terraform-provider-helm/helm/resource_chart.go:302 +0x44 fp=0xc4208739e0 sp=0xc420873990 pc=0x28da744
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm: github.com/mcuadros/terraform-provider-helm/vendor/github.com/hashicorp/terraform/helper/schema.(*Resource).Refresh(0xc420801440, 0xc42033c1e0, 0x2bfb000, 0xc420801c20, 0xc4201cfdc8, 0xc42074bf01, 0x80000000018)
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm:    /home/travis/gopath/src/github.com/mcuadros/terraform-provider-helm/vendor/github.com/hashicorp/terraform/helper/schema/resource.go:298 +0x3bf fp=0xc420873a88 sp=0xc4208739e0 pc=0x16ad0bf
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm: github.com/mcuadros/terraform-provider-helm/vendor/github.com/hashicorp/terraform/helper/schema.(*Provider).Refresh(0xc4201bf570, 0xc42033c190, 0xc42033c1e0, 0x46926c8, 0x0, 0x18)
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm:    /home/travis/gopath/src/github.com/mcuadros/terraform-provider-helm/vendor/github.com/hashicorp/terraform/helper/schema/provider.go:284 +0x9a fp=0xc420873ae0 sp=0xc420873a88 pc=0x16aac0a
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm: github.com/mcuadros/terraform-provider-helm/vendor/github.com/hashicorp/terraform/plugin.(*ResourceProviderServer).Refresh(0xc42045fa00, 0xc42049a280, 0xc42049a350, 0x0, 0x0)
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm:    /home/travis/gopath/src/github.com/mcuadros/terraform-provider-helm/vendor/github.com/hashicorp/terraform/plugin/resource_provider.go:510 +0x4e fp=0xc420873b38 sp=0xc420873ae0 pc=0x1696eee
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm: runtime.call64(0xc42074bf20, 0xc42000cdb8, 0xc4206b0510, 0x1800000028)
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm:    /home/travis/.gimme/versions/go1.9.linux.amd64/src/runtime/asm_amd64.s:510 +0x3b fp=0xc420873b88 sp=0xc420873b38 pc=0x1055b2b
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm: reflect.Value.call(0xc42076cd20, 0xc42000cdb8, 0x13, 0x2d4f14b, 0x4, 0xc42078bf20, 0x3, 0x3, 0x0, 0x0, ...)
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm:    /home/travis/.gimme/versions/go1.9.linux.amd64/src/reflect/value.go:434 +0x906 fp=0xc420873e60 sp=0xc420873b88 pc=0x10ba516
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm: reflect.Value.Call(0xc42076cd20, 0xc42000cdb8, 0x13, 0xc42002cf20, 0x3, 0x3, 0x0, 0x0, 0x0)
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm:    /home/travis/.gimme/versions/go1.9.linux.amd64/src/reflect/value.go:302 +0xa4 fp=0xc420873ec8 sp=0xc420873e60 pc=0x10b9af4
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm: net/rpc.(*service).call(0xc4207e1780, 0xc42049d8b0, 0xc4202b6da0, 0xc420447080, 0xc42045fac0, 0x29994a0, 0xc42049a280, 0x16, 0x29994e0, 0xc42049a350, ...)
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm:    /home/travis/.gimme/versions/go1.9.linux.amd64/src/net/rpc/server.go:381 +0x142 fp=0xc420873f78 sp=0xc420873ec8 pc=0x13e4a52
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm: runtime.goexit()
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm:    /home/travis/.gimme/versions/go1.9.linux.amd64/src/runtime/asm_amd64.s:2337 +0x1 fp=0xc420873f80 sp=0xc420873f78 pc=0x10582a1
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm: created by net/rpc.(*Server).ServeCodec
2017-12-04T19:53:58.233+0100 [DEBUG] plugin.terraform-provider-helm:    /home/travis/.gimme/versions/go1.9.linux.amd64/src/net/rpc/server.go:475 +0x36b

Full log is here

Expected Behavior

What should have happened?

No error

Actual Behavior

What actually happened?

Terraform crashed

$ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

helm_chart.kube_lego: Refreshing state... (ID: test-kube-lego)
helm_chart.kube_cert_manager: Refreshing state... (ID: test-kube-cert-manager)
Error refreshing state: 2 error(s) occurred:

* helm_chart.kube_lego: 1 error(s) occurred:

* helm_chart.kube_lego: helm_chart.kube_lego: unexpected EOF
* helm_chart.kube_cert_manager: 1 error(s) occurred:

* helm_chart.kube_cert_manager: helm_chart.kube_cert_manager: unexpected EOF

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform plan

Workaround

Use parallelism=1

@rporres
Copy link
Author

rporres commented Dec 19, 2017

I've worked around this problem by adding a mutex in the Meta struct. See rporres@eb58c27

@mcuadros I wonder if this is the correct approach and if we should also lock other Meta methods such as getK8sConfig

@mcuadros
Copy link
Collaborator

Yep, this was the correct solution, I did a similar one, to ensure a safer access to the helm client.

@ghost ghost locked and limited conversation to collaborators Apr 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants