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

0.12-rc1 crashes on Terraform apply when specifying input plan #21258

Closed
tuckerwales opened this issue May 9, 2019 · 7 comments · Fixed by #21310
Closed

0.12-rc1 crashes on Terraform apply when specifying input plan #21258

tuckerwales opened this issue May 9, 2019 · 7 comments · Fixed by #21310

Comments

@tuckerwales
Copy link

Terraform Version

Terraform v0.12.0-rc1
+ provider.aws v2.9.0

Crash Output

  meta.count-boundary (EachMode fixup) - *terraform.Npanic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1921737]

goroutine 699 [running]:
github.com/hashicorp/terraform/terraform.(*NodeApplyableResourceInstance).EvalTree(0xc000c02d50, 0x276a220, 0xc000c02d50)
	/opt/gopath/src/github.com/hashicorp/terraform/terraform/node_resource_apply_instance.go:111 +0x2a7
github.com/hashicorp/terraform/terraform.(*Graph).walk.func1(0x276a220, 0xc000c02d50, 0x0, 0x0, 0x0)
	/opt/gopath/src/github.com/hashicorp/terraform/terraform/graph.go:78 +0xd30
github.com/hashicorp/terraform/dag.(*Walker).walkVertex(0xc0003e4180, 0x276a220, 0xc000c02d50, 0xc000d924c0)
	/opt/gopath/src/github.com/hashicorp/terraform/dag/walk.go:392 +0x353
created by github.com/hashicorp/terraform/dag.(*Walker).Update
	/opt/gopath/src/github.com/hashicorp/terraform/dag/walk.go:314 +0xa9b
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1921737]

goroutine 699 [running]:
github.com/hashicorp/terraform/terraform.(*NodeApplyableResourceInstance).EvalTree(0xc000c02d50, 0x276a220, 0xc000c02d50)
	/opt/gopath/src/github.com/hashicorp/terraform/terraform/node_resource_apply_instance.go:111 +0x2a7
github.com/hashicorp/terraform/terraform.(*Graph).walk.func1(0x276a220, 0xc000c02d50, 0x0, 0x0, 0x0)
	/opt/gopath/src/github.com/hashicorp/terraform/terraform/graph.go:78 +0xd30
github.com/hashicorp/terraform/dag.(*Walker).walkVertex(0xc0003e4180, 0x276a220, 0xc000c02d50, 0xc000d924c0)
	/opt/gopath/src/github.com/hashicorp/terraform/dag/walk.go:392 +0x353
created by github.com/hashicorp/terraform/dag.(*Walker).Update
	/opt/gopath/src/github.com/hashicorp/terraform/dag/walk.go:314 +0xa9b

Expected Behavior

For the plan to be applied.

Actual Behavior

The Terraform CLI crashes

Steps to Reproduce

terraform plan -out=terraform.plan
terraform apply terraform.plan

@ghost ghost added bug crash labels May 9, 2019
@jbardin
Copy link
Member

jbardin commented May 9, 2019

Hi @tuckerwales,

Thanks for filing the issue! Wold it be possible to provide some configuration that demonstrates how you arrived at this error?

@tuckerwales
Copy link
Author

@jbardin no problem,

What kind of config are you looking for? We're using modules to import quite a lot of config so it's probably infeasible to include all of that.

@jbardin
Copy link
Member

jbardin commented May 9, 2019

It would be nice if we could reduce it to a manageable size, but I understand that's not simple when there's a lot of configuration to work with. We may still be able to get enough info without it. Would it be possible to provide the log output with TF_LOG=trace?

Was this an apply from scratch, or was this after modifying an existing state?

Does the exact same operation work if you apply directly without saving the plan?

Thanks!

@apparentlymart apparentlymart added this to the v0.12.0 milestone May 9, 2019
@apparentlymart
Copy link
Member

Given the location of this panic...

// Eval info is different depending on what kind of resource this is
switch n.Config.Mode {
case addrs.ManagedResourceMode:
return n.evalTreeManagedResource(addr, stateId, stateDeps)
case addrs.DataResourceMode:
return n.evalTreeDataResource(addr, stateId, stateDeps)
default:
panic(fmt.Errorf("unsupported resource mode %s", n.Config.Mode))
}

It looks like we somehow ended up with a graph node with no configuration attached. Because plan and apply both use the same configuration by definition (the configuration is in the plan file), that is unexpected, and so I think as @jbardin said at least a more complete trace log could be helpful to see why that might be. Any additional context would be very helpful too.

@tuckerwales
Copy link
Author

Oddly enough, I just tried to get you more information and it seems to have started working. I rm -rf'ed my .terraform folder earlier and ran terraform init again so maybe that's related.

@jbardin this was an apply after modifying state. And yes, it worked when applying - that's how I got around the problem originally.

Sorry I can't offer any more information or logs.

@apparentlymart
Copy link
Member

Thanks for following up, @tuckerwales!

Since we don't have a clear reproduction process for this, we're going to address it for now by adding an explicit check prior to the line where the panic originated so that we can at least fail gracefully in this weird edge-case. If it crops up again then we'll dig further and try to get to the bottom of it.

Thanks again for reporting it!

@ghost
Copy link

ghost commented Jul 25, 2019

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 Jul 25, 2019
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.

3 participants