mongodb / terraform-provider-mongodbatlas

Terraform MongoDB Atlas Provider: Deploy, update, and manage MongoDB Atlas infrastructure as code through HashiCorp Terraform
https://registry.terraform.io/providers/mongodb/mongodbatlas
Mozilla Public License 2.0
244 stars 172 forks source link

Crash when refreshing TF State for a single cluster #330

Closed NikolaeVarius closed 4 years ago

NikolaeVarius commented 4 years ago

Terraform CLI and Terraform MongoDB Atlas Provider Version

Terraform v0.12.29

Terraform Configuration File

resource "mongodbatlas_cluster" "staging" {
  project_id                   = data.mongodbatlas_project.service.id
  name                         = var.mongodb_atlas_cluster_name
  mongo_db_major_version       = "4.2"
  provider_name                = local.atlas_shared_mode ? "TENANT" : "AWS"
  backing_provider_name        = local.atlas_shared_mode ? "AWS" : ""
  provider_instance_size_name  = var.cluster_tier
  provider_backup_enabled      = false
  auto_scaling_disk_gb_enabled = true
  disk_size_gb                 = 120
}

Steps to Reproduce

  1. terraform refresh

Expected Behavior

It refreshes

Actual Behavior

Crashes

Debug Output

Crash Output

https://gist.github.com/NikolaeVarius/dd04ff6f17663976be8444d9f7dfb722

Additional Context

References

nikhil-mongo commented 4 years ago

@NikolaeVarius

I will revert back with findings shortly.

nikhil-mongo commented 4 years ago

@NikolaeVarius

I could not reproduce this error. The terraform config used is as below:

Terraform v0.12.29
provider "mongodbatlas" (terraform-providers/mongodbatlas) 0.6.5
variable "mongodb_atlas_cluster_name" {
}
variable "cluster_tier" {
}
variable "project_id" {
}
locals {
  atlas_shared_mode = true
}
resource "mongodbatlas_cluster" "staging" {
  project_id = var.project_id
  name       = var.mongodb_atlas_cluster_name

  mongo_db_major_version       = "4.2"
  provider_name                = local.atlas_shared_mode == true ? "TENANT" : "AWS"
  backing_provider_name        = local.atlas_shared_mode == true ? "AWS" : ""
  provider_instance_size_name  = var.cluster_tier
  provider_backup_enabled      = false
  auto_scaling_disk_gb_enabled = local.atlas_shared_mode == true ? "false" : "true"
  disk_size_gb                 = 120
}

Also, the disk_size_gb value cannot be used as 120 GB when it is shared tier cluster M2/M5 as they have fixed disk size of 2 GB and 5 GB respectively. Therefore, please change it to a valid value and try again.

NikolaeVarius commented 4 years ago

I made mistake while copy pasting values to simplify report

Just some extra info

5.8.6-1-MANJARO
go version go1.15.2 linux/amd64
resource "mongodbatlas_cluster" "staging" {
  project_id                   = data.mongodbatlas_project.service.id
  name                         = var.mongodb_atlas_cluster_name
  mongo_db_major_version       = "4.2"
  provider_name                = local.atlas_shared_mode ? "TENANT" : "AWS"
  backing_provider_name        = local.atlas_shared_mode ? "AWS" : ""
  provider_instance_size_name  = "M10"
  provider_backup_enabled      = false
  auto_scaling_disk_gb_enabled = ! local.atlas_shared_mode
  disk_size_gb                 = 10
}

returns

mongodbatlas_cluster.staging: Refreshing state... [id=Y2x1c3Rlcl9pZA==:NWQzYjI3ZTNjZjA5YTJmYWM2Y2EyODQ5-cHJvamVjdF9pZA==:NWQzYjI3NWFhNmYyMzlmNDkwYjY3NzZk-Y2x1c3Rlcl9uYW1l:c3RhZ2luZy0zNA==]                                                                             

Error: rpc error: code = Unavailable desc = transport is closing                                                                                                                                                                                                         

panic: runtime error: invalid memory address or nil pointer dereference
2020-10-07T08:28:07.273-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xde0b49]
2020-10-07T08:28:07.273-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4: 
2020-10-07T08:28:07.273-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4: goroutine 23 [running]:
2020-10-07T08:28:07.273-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/mongodbatlas.flattenProcessArgs(0xc0002e1b40, 0x12b0b80)
2020-10-07T08:28:07.273-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/mongodbatlas/resource_mongodbatlas_cluster.go:1010 +0x39
2020-10-07T08:28:07.273-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/mongodbatlas.resourceMongoDBAtlasClusterRead(0xc0003389a0, 0xf844e0, 0xc000138500, 0xc0003389a0, 0x0)
2020-10-07T08:28:07.273-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/mongodbatlas/resource_mongodbatlas_cluster.go:625 +0x25c8
2020-10-07T08:28:07.273-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4: github.com/hashicorp/terraform/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc00054b500, 0xc000128780, 0xf844e0, 0xc000138500, 0xc000196990, 0xc000128780, 0x0)
2020-10-07T08:28:07.273-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/github.com/hashicorp/terraform/helper/schema/resource.go:447 +0x119
2020-10-07T08:28:07.273-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4: github.com/hashicorp/terraform/helper/plugin.(*GRPCProviderServer).ReadResource(0xc00000eb28, 0x12b0c00, 0xc0002efbc0, 0xc0007e2880, 0xc00000eb28, 0xc0002efbc0, 0xc000261a20)
2020-10-07T08:28:07.273-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/github.com/hashicorp/terraform/helper/plugin/grpc_provider.go:496 +0x332
2020-10-07T08:28:07.273-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4: github.com/hashicorp/terraform/internal/tfplugin5._Provider_ReadResource_Handler(0x102d6c0, 0xc00000eb28, 0x12b0c00, 0xc0002efbc0, 0xc0001285a0, 0x0, 0x12b0c00, 0xc0002efbc0, 0xc0002cc900, 0x801)
2020-10-07T08:28:07.273-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/github.com/hashicorp/terraform/internal/tfplugin5/tfplugin5.pb.go:2983 +0x217
2020-10-07T08:28:07.273-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4: google.golang.org/grpc.(*Server).processUnaryRPC(0xc000202780, 0x12bbbc0, 0xc000680780, 0xc00071d400, 0xc00020e420, 0x19eef50, 0x0, 0x0, 0x0)
2020-10-07T08:28:07.273-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc/server.go:998 +0x46a
2020-10-07T08:28:07.273-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4: google.golang.org/grpc.(*Server).handleStream(0xc000202780, 0x12bbbc0, 0xc000680780, 0xc00071d400, 0x0)
2020-10-07T08:28:07.273-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc/server.go:1278 +0xd3d
2020-10-07T08:28:07.273-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4: google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc000212120, 0xc000202780, 0x12bbbc0, 0xc000680780, 0xc00071d400)
2020-10-07T08:28:07.273-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc/server.go:717 +0xa1
2020-10-07T08:28:07.273-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4: created by google.golang.org/grpc.(*Server).serveStreams.func1
2020-10-07T08:28:07.273-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc/server.go:715 +0xa1
2020-10-07T08:28:07.278-0600 [DEBUG] plugin: plugin process exited: path={path to state}/.terraform/plugins/linux_amd64/terraform-provider-mongodbatlas_v0.5.1_x4 pid=330961 error="exit status 2"
2020/10/07 08:28:07 [ERROR] <root>: eval: *terraform.EvalRefresh, err: rpc error: code = Unavailable desc = transport is closing
2020/10/07 08:28:07 [ERROR] <root>: eval: *terraform.EvalSequence, err: rpc error: code = Unavailable desc = transport is closing
2020/10/07 08:28:07 [TRACE] [walkRefresh] Exiting eval tree: mongodbatlas_cluster.staging
2020/10/07 08:28:07 [TRACE] vertex "mongodbatlas_cluster.staging": visit complete
2020/10/07 08:28:07 [TRACE] vertex "mongodbatlas_cluster.staging": dynamic subgraph encountered errors
2020/10/07 08:28:07 [TRACE] vertex "mongodbatlas_cluster.staging": visit complete
2020/10/07 08:28:07 [TRACE] dag/walk: upstream of "provider.mongodbatlas (close)" errored, so skipping
2020/10/07 08:28:07 [TRACE] dag/walk: upstream of "root" errored, so skipping
2020-10-07T08:28:07.279-0600 [DEBUG] plugin: plugin exited

Setting to M5 and 5GB

resource "mongodbatlas_cluster" "staging" {
  project_id                   = data.mongodbatlas_project.service.id
  name                         = var.mongodb_atlas_cluster_name
  mongo_db_major_version       = "4.2"
  provider_name                = local.atlas_shared_mode ? "TENANT" : "AWS"
  backing_provider_name        = local.atlas_shared_mode ? "AWS" : ""
  provider_instance_size_name  = "M5"
  provider_backup_enabled      = false
  auto_scaling_disk_gb_enabled = ! local.atlas_shared_mode
  disk_size_gb                 = 5
}
mongodbatlas_cluster.staging: Refreshing state... [id=Yawdafwaaa]                                                                             

Error: rpc error: code = Unavailable desc = transport is closing                                                                                                                                                                                                         

panic: runtime error: invalid memory address or nil pointer dereference
2020-10-07T08:30:13.970-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xde0b49]
2020-10-07T08:30:13.970-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4: 
2020-10-07T08:30:13.970-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4: goroutine 48 [running]:
2020-10-07T08:30:13.970-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/mongodbatlas.flattenProcessArgs(0xc000342400, 0x12b0b80)
2020-10-07T08:30:13.970-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/mongodbatlas/resource_mongodbatlas_cluster.go:1010 +0x39
2020-10-07T08:30:13.970-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/mongodbatlas.resourceMongoDBAtlasClusterRead(0xc0002cc850, 0xf844e0, 0xc000236c80, 0xc0002cc850, 0x0)
2020-10-07T08:30:13.970-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/mongodbatlas/resource_mongodbatlas_cluster.go:625 +0x25c8
2020-10-07T08:30:13.970-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4: github.com/hashicorp/terraform/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0004fb500, 0xc0005e82d0, 0xf844e0, 0xc000236c80, 0xc00069ccc0, 0xc0005e82d0, 0x0)
2020-10-07T08:30:13.970-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/github.com/hashicorp/terraform/helper/schema/resource.go:447 +0x119
2020-10-07T08:30:13.970-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4: github.com/hashicorp/terraform/helper/plugin.(*GRPCProviderServer).ReadResource(0xc00000e5d8, 0x12b0c00, 0xc0001964b0, 0xc0001b60c0, 0xc00000e5d8, 0xc0001964b0, 0xc0002f3a20)
2020-10-07T08:30:13.970-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/github.com/hashicorp/terraform/helper/plugin/grpc_provider.go:496 +0x332
2020-10-07T08:30:13.970-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4: github.com/hashicorp/terraform/internal/tfplugin5._Provider_ReadResource_Handler(0x102d6c0, 0xc00000e5d8, 0x12b0c00, 0xc0001964b0, 0xc0005e80f0, 0x0, 0x12b0c00, 0xc0001964b0, 0xc00034a900, 0x801)
2020-10-07T08:30:13.970-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/github.com/hashicorp/terraform/internal/tfplugin5/tfplugin5.pb.go:2983 +0x217
2020-10-07T08:30:13.970-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4: google.golang.org/grpc.(*Server).processUnaryRPC(0xc000702600, 0x12bbbc0, 0xc000642600, 0xc000348000, 0xc0003e12f0, 0x19eef50, 0x0, 0x0, 0x0)
2020-10-07T08:30:13.970-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc/server.go:998 +0x46a
2020-10-07T08:30:13.970-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4: google.golang.org/grpc.(*Server).handleStream(0xc000702600, 0x12bbbc0, 0xc000642600, 0xc000348000, 0x0)
2020-10-07T08:30:13.970-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc/server.go:1278 +0xd3d
2020-10-07T08:30:13.970-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4: google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc0004927f0, 0xc000702600, 0x12bbbc0, 0xc000642600, 0xc000348000)
2020-10-07T08:30:13.970-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc/server.go:717 +0xa1
2020-10-07T08:30:13.970-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4: created by google.golang.org/grpc.(*Server).serveStreams.func1
2020-10-07T08:30:13.970-0600 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.5.1_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc/server.go:715 +0xa1
2020-10-07T08:30:13.975-0600 [DEBUG] plugin: plugin process exited: path=/{path to state}.terraform/plugins/linux_amd64/terraform-provider-mongodbatlas_v0.5.1_x4 pid=331631 error="exit status 2"
2020/10/07 08:30:13 [ERROR] <root>: eval: *terraform.EvalRefresh, err: rpc error: code = Unavailable desc = transport is closing
2020/10/07 08:30:13 [ERROR] <root>: eval: *terraform.EvalSequence, err: rpc error: code = Unavailable desc = transport is closing
2020/10/07 08:30:13 [TRACE] [walkRefresh] Exiting eval tree: mongodbatlas_cluster.staging
2020/10/07 08:30:13 [TRACE] vertex "mongodbatlas_cluster.staging": visit complete
2020/10/07 08:30:13 [TRACE] vertex "mongodbatlas_cluster.staging": dynamic subgraph encountered errors
2020/10/07 08:30:13 [TRACE] vertex "mongodbatlas_cluster.staging": visit complete
2020/10/07 08:30:13 [TRACE] dag/walk: upstream of "provider.mongodbatlas (close)" errored, so skipping
2020/10/07 08:30:13 [TRACE] dag/walk: upstream of "root" errored, so skipping
2020-10-07T08:30:13.976-0600 [DEBUG] plugin: plugin exited
nikhil-mongo commented 4 years ago

@NikolaeVarius

This seems to be a platform issue and not related to the provider. If you could try some other provider as well because at my end I am not able to repro this with terraform 0.12.29.

You could also try running the same config on some other platform apart from Manjaro and confirm.

NikolaeVarius commented 4 years ago

I'll close this. I took the leap and upgraded the mongodb atlas provider. 0.6.0 continued the crashing behavior, but the current release v0.6.5 worked and I was able to init/plan/apply. So whatever was in between those two releases fixed this I guess.

Thanks