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

invalid memory / nil pointer error when manually removing RDS cluster instance #5350

Closed
reybard opened this issue Feb 26, 2016 · 2 comments · Fixed by #5717
Closed

invalid memory / nil pointer error when manually removing RDS cluster instance #5350

reybard opened this issue Feb 26, 2016 · 2 comments · Fixed by #5717

Comments

@reybard
Copy link

reybard commented Feb 26, 2016

Running Terraform 0.6.12

I have a couple of Aurora instances created using the following resource:

resource "aws_rds_cluster_instance" "ahs_db_cluster_instances" {
    count = 2
    identifier = "${var.environment}-ahs-db-${count.index + 1}"
    cluster_identifier = "${aws_rds_cluster.ahs_db_cluster.id}"
    instance_class = "db.r3.2xlarge"
    db_subnet_group_name = "default-vpc-aed899c6"
}

This creates instances named ENV-ahs-db-1 and ENV-ahs-db-2 and I am testing what Terraform does when I manually remove ENV-ahs-db-1 from the console (it is the reader in this case).

I expect Terraform to realize the discrepancy between its state and reality on refresh (which should then recreate the now-missing instance) but instead it panics:

panic: runtime error: invalid memory address or nil pointer dereference
2016/02/26 21:34:49 [DEBUG] terraform-provider-aws: [signal 0xb code=0x1 addr=0x38 pc=0x599615]
2016/02/26 21:34:49 [DEBUG] terraform-provider-aws:
2016/02/26 21:34:49 [DEBUG] terraform-provider-aws: goroutine 107 [running]:
2016/02/26 21:34:49 [DEBUG] terraform-provider-aws: panic(0x10ef260, 0xc82000a0d0)
2016/02/26 21:34:49 [DEBUG] terraform-provider-aws: /opt/go/src/runtime/panic.go:464 +0x3e6
2016/02/26 21:34:49 [DEBUG] terraform-provider-aws: github.com/hashicorp/terraform/builtin/providers/aws.resourceAwsRDSClusterInstanceRead(0xc820378120, 0xe10b60, 0xc820246200, 0x0, 0x0)
2016/02/26 21:34:49 [DEBUG] terraform-provider-aws: /opt/gopath/src/github.com/hashicorp/terraform/builtin/providers/aws/resource_aws_rds_cluster_instance.go:135 +0x335
2016/02/26 21:34:49 [DEBUG] terraform-provider-aws: github.com/hashicorp/terraform/helper/schema.(_Resource).Refresh(0xc82033de40, 0xc820456f30, 0xe10b60, 0xc820246200, 0xc8200620f0, 0x0, 0x0)
2016/02/26 21:34:49 [DEBUG] terraform-provider-aws: /opt/gopath/src/github.com/hashicorp/terraform/helper/schema/resource.go:209 +0x43a
2016/02/26 21:34:49 [DEBUG] terraform-provider-aws: github.com/hashicorp/terraform/helper/schema.(_Provider).Refresh(0xc820109920, 0xc8201f0b00, 0xc820456f30, 0x1d16001, 0x0, 0x0)
2016/02/26 21:34:49 [DEBUG] terraform-provider-aws: /opt/gopath/src/github.com/hashicorp/terraform/helper/schema/provider.go:187 +0x1da
2016/02/26 21:34:49 [DEBUG] terraform-provider-aws: github.com/hashicorp/terraform/rpc.(_ResourceProviderServer).Refresh(0xc8203b34c0, 0xc8201d66f0, 0xc8201d6900, 0x0, 0x0)
2016/02/26 21:34:49 [DEBUG] terraform-provider-aws: /opt/gopath/src/github.com/hashicorp/terraform/rpc/resource_provider.go:345 +0x6a
2016/02/26 21:34:49 [DEBUG] terraform-provider-aws: reflect.Value.call(0x103d360, 0x12dc798, 0x13, 0x137ecb8, 0x4, 0xc8203f3ed8, 0x3, 0x3, 0x0, 0x0, ...)
2016/02/26 21:34:49 [DEBUG] terraform-provider-aws: /opt/go/src/reflect/value.go:435 +0x120d
2016/02/26 21:34:49 [DEBUG] terraform-provider-aws: reflect.Value.Call(0x103d360, 0x12dc798, 0x13, 0xc8203f3ed8, 0x3, 0x3, 0x0, 0x0, 0x0)
2016/02/26 21:34:49 [DEBUG] terraform-provider-aws: /opt/go/src/reflect/value.go:303 +0xb1
2016/02/26 21:34:49 [DEBUG] terraform-provider-aws: net/rpc.(_service).call(0xc82029ea40, 0xc82029ea00, 0xc820105360, 0xc82017aa00, 0xc820260840, 0xe11ca0, 0xc8201d66f0, 0x16, 0xe11d00, 0xc8201d6900, ...)
2016/02/26 21:34:49 [DEBUG] terraform-provider-aws: /opt/go/src/net/rpc/server.go:383 +0x1c2
2016/02/26 21:34:49 [DEBUG] terraform-provider-aws: created by net/rpc.(*Server).ServeCodec
2016/02/26 21:34:49 [DEBUG] terraform-provider-aws: /opt/go/src/net/rpc/server.go:477 +0x49d

Adding the cluster instance back manually with the same name Terraform expects allows me to properly do plans/applys again.

@phinze
Copy link
Contributor

phinze commented Mar 18, 2016

Hi @jescochu - thanks for the report, and sorry for the trouble here! I've reproduced the crash locally and am starting work on a fix now.

phinze added a commit that referenced this issue Mar 18, 2016
Usage of a helper function was assuming that an error would be returned
in a not found condition, when in fact a nil pointer was
returned.

Attached test crashes w/o fix, passes with it.

Fixes #5350
Refs #5418
phinze added a commit that referenced this issue Mar 18, 2016
Usage of a helper function was assuming that an error would be returned
in a not found condition, when in fact a nil pointer was
returned.

Attached test crashes w/o fix, passes with it.

Fixes #5350
Refs #5418
phinze added a commit that referenced this issue Mar 18, 2016
Usage of a helper function was assuming that an error would be returned
in a not found condition, when in fact a nil pointer was
returned.

Attached test crashes w/o fix, passes with it.

Fixes #5350
Refs #5418
@ghost
Copy link

ghost commented Apr 27, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants