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

Terraform crash when trying to create resources #823

Closed
ghost opened this issue Feb 12, 2018 · 3 comments
Closed

Terraform crash when trying to create resources #823

ghost opened this issue Feb 12, 2018 · 3 comments

Comments

@ghost
Copy link

ghost commented Feb 12, 2018

This issue was originally opened by @pixelicous as hashicorp/terraform#17318. It was migrated here as a result of the provider split. The original body of the issue is below.


Terraform Version

Terraform v0.11.3
+ provider.azurerm v1.1.0
+ provider.random v1.1.0

Terraform Configuration Files


resource "azurerm_resource_group" "rg" {
  name = "${var.name_prefix}-net-rg"
  location            = "${var.location}"
}

data "azurerm_virtual_network" "vnet" {
    name = "${var.name_prefix}-net-vnet"
    resource_group_name = "${azurerm_resource_group.rg.name}"    
}

resource "azurerm_subnet" "subnet_management" {
  name  = "Management01"
  address_prefix = "${cidrsubnet(var.vnet_cidr, 9, 0)}"
  resource_group_name = "${azurerm_resource_group.rg.name}"
  virtual_network_name = "${data.azurerm_virtual_network.vnet.name}"
  #network_security_group_id = "${azurerm_network_security_group.Outbound_RDP.id}"
  #network_security_group_id = "${azurerm_network_security_group.Inbound_RDP.id}"
}

resource "azurerm_subnet" "subnet_deployment" {
  name  = "Deployment01"
  address_prefix = "${cidrsubnet(var.vnet_cidr, 9, 1)}"
  resource_group_name = "${azurerm_resource_group.rg.name}"
  virtual_network_name = "${data.azurerm_virtual_network.vnet.name}"
}

Debug Output

module.EastUS2.azurerm_resource_group.rg: Creation complete after 1s (ID: /subscriptions/7ba01b64-039e-45bb-9288-...664e0/resourceGroups/azeu2-mgmt-net-rg)
module.EastUS2.data.azurerm_virtual_network.vnet: Refreshing state...

Error: Error applying plan:

1 error(s) occurred:

  • module.EastUS2.data.azurerm_virtual_network.vnet: data.azurerm_virtual_network.vnet: unexpected EOF

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
panic: runtime error: invalid memory address or nil pointer dereference
2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: [signal 0xc0000005 code=0x0 addr=0x0 pc=0x13fac22]
2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe:
2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: goroutine 90 [running]:
2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: github.com/terraform-providers/terraform-provider-azurerm/azurerm.dataSourceArmVnetRead(0xc04220a230, 0x1898e60, 0xc0424b4000, 0xc04261e160, 0x17)
2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-azurerm/azurerm/data_source_virtual_network.go:80 +0x542
2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform/helper/schema.(*Resource).ReadDataApply(0xc0425a11a0, 0xc042616600, 0x1898e60, 0xc0424b4000, 0xc0424a0430, 0xc04215c901, 0x80000000018)
2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform/helper/schema/resource.go:259 +0xb7
2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform/helper/schema.(*Provider).ReadDataApply(0xc0421fcb60, 0xc042160320, 0xc042616600, 0x47406a8, 0x0, 0x18)
2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform/helper/schema/provider.go:398 +0xa1
2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform/plugin.(*ResourceProviderServer).ReadDataApply(0xc0424c1080, 0xc0425b43d0, 0xc0425b4450, 0x0, 0x0)
2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform/plugin/resource_provider.go:565 +0x55
2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: reflect.Value.call(0xc042329080, 0xc0424126b0, 0x13, 0x18da7dc, 0x4, 0xc042819f20, 0x3, 0x3, 0x0, 0x0, ...)
2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: /usr/local/go/src/reflect/value.go:434 +0x90c
2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: reflect.Value.Call(0xc042329080, 0xc0424126b0, 0x13, 0xc042819f20, 0x3, 0x3, 0x0, 0x0, 0x0)
2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: /usr/local/go/src/reflect/value.go:302 +0xab
2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: net/rpc.(*service).call(0xc042588ec0, 0xc0425741e0, 0xc042582138, 0xc042364480, 0xc042580a80, 0x16372a0, 0xc0425b43d0, 0x16, 0x16372e0, 0xc0425b4450, ...)
2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: /usr/local/go/src/net/rpc/server.go:381 +0x149
2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: created by net/rpc.(*Server).ServeCodec
2018-02-12T08:57:00.340+0200 [DEBUG] plugin.terraform-provider-azurerm_v1.1.0_x4.exe: /usr/local/go/src/net/rpc/server.go:475 +0x372
2018/02/12 08:57:00 [ERROR] root.EastUS2: eval: *terraform.EvalReadDataApply, err: data.azurerm_virtual_network.vnet: unexpected EOF
2018/02/12 08:57:00 [ERROR] root.EastUS2: eval: *terraform.EvalSequence, err: data.azurerm_virtual_network.vnet: unexpected EOF
2018/02/12 08:57:00 [TRACE] [walkApply] Exiting eval tree: module.EastUS2.data.azurerm_virtual_network.vnet
2018/02/12 08:57:00 [TRACE] dag/walk: upstream errored, not walking "module.EastUS2.azurerm_subnet.subnet_management"
2018/02/12 08:57:00 [TRACE] dag/walk: upstream errored, not walking "module.EastUS2.azurerm_subnet.subnet_deployment"
2018/02/12 08:57:00 [TRACE] dag/walk: upstream errored, not walking "meta.count-boundary (count boundary fixup)"
2018/02/12 08:57:00 [TRACE] dag/walk: upstream errored, not walking "provider.azurerm (close)"
2018/02/12 08:57:00 [TRACE] dag/walk: upstream errored, not walking "root"
2018/02/12 08:57:00 [TRACE] Preserving existing state lineage "3e996688-5cc5-4da5-83d5-2c07b83abc65"
2018-02-12T08:57:00.354+0200 [DEBUG] plugin: plugin process exited: path=C:\git\Infrastructure\CloudInfrastructure\providers\azure\production-account.terraform\plugins\windows_amd64\terraform-provider-azurerm_v1.1.0_x4.exe
2018/02/12 08:57:00 [DEBUG] plugin: waiting for all plugin processes to complete...
2018-02-12T08:57:00.354+0200 [WARN ] plugin: error closing client during Kill: err="connection is shut down"

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
A crash log has been placed at "crash.log" relative to your current
working directory. It would be immensely helpful if you could please
report the crash with Terraform1 so that we can fix this.

When reporting bugs, please include your terraform version. That
information is available on the first line of crash.log. You can also
get it by running 'terraform --version' on the command line.

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Crash Output

https://gist.github.com/pixelicous/ff1e24e74e9d2afba1d93fee53678f1b

Expected Behavior

Subnets created on VNET

Actual Behavior

Plan shows all green, apply as well, when it starts, after 2 resources i receive a crash, no matter how i try.

Steps to Reproduce

Create a resource group, vnet and a vpn gateway in azure rm

Additional Context

Basically creating more resources that rely on this subnet but not showing here.

I tried a couple of ways to write the HCL VNET and resource group. As data and as a resource, when referencing the resource group name as part of the VNET data object, changing between full interpolation some some text+interpolation made a difference, especially before even execution.

When planning / applying i had to use different state file as each time the state file got corrupted

@pixelicous
Copy link

pixelicous commented Feb 12, 2018

Found the problem, although i guess terraform should have as well..
The subnetting CIDR function that was used generated subnets our of the scope of the vnet, although terraform should have handled it i think instead of throwing such an exception, consecutive runs over this state file also crushed due to this.

Problem solved.

Close #823

@tombuildsstuff
Copy link
Contributor

hey @pixelicous

So this is a duplicate of #801 which was fixed in #803, which has since been merged and will ship as part of the next version of the Azure Provider this week.

Given the fix for this bug has been merged in (and you've got a workaround for this issue) - I'm going to close this issue for the moment, but please feel free to reopen it if you're seeing issues and we'll take another look :)

Thanks!

@tombuildsstuff tombuildsstuff added this to the 1.1.2 milestone Feb 12, 2018
@ghost
Copy link
Author

ghost commented Mar 31, 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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

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

No branches or pull requests

2 participants