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

azure RM crash #9198

Closed
spuder opened this issue Oct 3, 2016 · 5 comments
Closed

azure RM crash #9198

spuder opened this issue Oct 3, 2016 · 5 comments

Comments

@spuder
Copy link
Contributor

spuder commented Oct 3, 2016

I'm suddenly getting the following terraform crash. I've successfully used this exact terraform config dozens of time over the last few days, so I'm at a loss of why terraform would suddenly start crashing

Terraform Version

Terraform v0.7.4

Steps to Reproduce

  1. terraform plan

Terraform Configuration Files

provider "azurerm" {
  subscription_id = "${var.subscription_id}"
  client_id = "${var.client_id}"
  client_secret = "${var.client_secret}"
  tenant_id = "${var.tenant_id}"
}

resource "azurerm_resource_group" "artifactory" {
    name = "artifactory"
    location = "West US"
}

resource "azurerm_virtual_network" "artifactory" {
    name = "artifactory-vnet"
    address_space = ["10.105.0.0/16"]
    location = "West US"
    resource_group_name = "${azurerm_resource_group.artifactory.name}"
}

resource "azurerm_subnet" "artifactory-backend" {
    name = "backend"
    resource_group_name = "${azurerm_resource_group.artifactory.name}"
    virtual_network_name = "${azurerm_virtual_network.artifactory.name}"
    address_prefix = "10.105.0.0/24"
}

resource "azurerm_subnet" "artifactory-gateway" {
    name = "GatewaySubnet"
    resource_group_name = "${azurerm_resource_group.artifactory.name}"
    virtual_network_name = "${azurerm_virtual_network.artifactory.name}"
    address_prefix = "10.105.10.0/27"
}

resource "azurerm_public_ip" "artifactory" {
  name = "artifactoryPublicIp1"
  location = "West US"
  resource_group_name = "${azurerm_resource_group.artifactory.name}"
  public_ip_address_allocation = "static"
}

resource "azurerm_network_interface" "artifactory" {
    name = "artifactory-nic"
    location = "West US"
    resource_group_name = "${azurerm_resource_group.artifactory.name}"

    ip_configuration {
        name = "artifactory-ipconfig"
        subnet_id = "${azurerm_subnet.artifactory-backend.id}"
        private_ip_address_allocation = "dynamic"
        public_ip_address_id = "${azurerm_public_ip.artifactory.id}"
    }
}

resource "azurerm_network_security_group" "artifactory" {
    name = "artifactory-nsg"
    location = "West US"
    resource_group_name = "${azurerm_resource_group.artifactory.name}"
}

resource "azurerm_network_security_rule" "artifactory_allow_https" {
    name = "allow_https_leh"
    priority = 100
    direction = "Inbound"
    access = "Allow"
    protocol = "Tcp"
    source_port_range = "*"
    destination_port_range = "443"
    source_address_prefix = "${var.us-leh_ip}"
    destination_address_prefix = "*"
    resource_group_name = "${azurerm_resource_group.artifactory.name}"
    network_security_group_name = "${azurerm_network_security_group.artifactory.name}"
}


resource "azurerm_network_security_rule" "artifactory_allow_ssh" {
    name = "default-allow-ssh"
    priority = 200
    direction = "Inbound"
    access = "Allow"
    protocol = "Tcp"
    source_port_range = "*"
    destination_port_range = "22"
    source_address_prefix = "${var.us-leh_ip}"
    destination_address_prefix = "*"
    resource_group_name = "${azurerm_resource_group.artifactory.name}"
    network_security_group_name = "${azurerm_network_security_group.artifactory.name}"
}

resource "azurerm_storage_account" "artifactory" {
    name = "ndartifactorysa"
    resource_group_name = "${azurerm_resource_group.artifactory.name}"
    location = "westus"
    account_type = "Standard_LRS"
}

resource "azurerm_storage_container" "artifactory" {
    name = "vhds"
    resource_group_name = "${azurerm_resource_group.artifactory.name}"
    storage_account_name = "${azurerm_storage_account.artifactory.name}"
    container_access_type = "private"
}

resource "azurerm_virtual_machine" "artifactory" {
  name = "us-artifactory"
   location = "West US"
   resource_group_name = "${azurerm_resource_group.artifactory.name}"
   network_interface_ids = ["${azurerm_network_interface.artifactory.id}"]
   vm_size = "Standard_DS1_v2"

   storage_image_reference {
     publisher = "Canonical"
     offer = "UbuntuServer"
     sku = "16.04.0-LTS"
     version = "latest"
   }

   storage_os_disk {
       name = "disk1"
       vhd_uri = "${azurerm_storage_account.artifactory.primary_blob_endpoint}${azurerm_storage_container.artifactory.name}/disk1.vhd"
       caching = "ReadWrite"
       create_option = "FromImage"
   }

   storage_data_disk {
     name = "datadisk0"
     vhd_uri = "${azurerm_storage_account.artifactory.primary_blob_endpoint}${azurerm_storage_container.artifactory.name}/datadisk0.vhd"
     disk_size_gb  = "1023"
     create_option = "Empty"
     lun           = 0
   }

   os_profile {
       computer_name = "artifactory"
       admin_username = "${var.username}"
       admin_password = "${var.password}"
   }

   os_profile_linux_config {
       disable_password_authentication = false
   }

}

resource "azurerm_local_network_gateway" "artifactory" {
  name = "us-leh"
  resource_group_name = "${azurerm_resource_group.artifactory.name}"
  location = "${azurerm_resource_group.artifactory.location}"
  gateway_address = "${var.us-leh_ip}"
  address_space = ["${var.us_addres_sspace}"]
}

Debug Output

https://gist.github.com/spuder/cfb85af76ed41e8807e95bb8c70f0142

Terraform is complaining about an unexpected EOF

Panic Output

https://gist.github.com/spuder/8e46e9fb684066ee3bf959eb5435ef98

If I backup and then move the tfstate file, then terraform no longer crashes (though it wants to rebuild all resources).

@partamonov
Copy link

partamonov commented Dec 5, 2016

I will add here.

I tried to import azurerm_local_network_gateway and got similar issue:

  • azurerm_local_network_gateway.a2b: unexpected EOF
terraform import azurerm_local_network_gateway.a2b /subscriptions/<some subscription id>/resourceGroups/myRG/providers/microsoft.network/localnetworkgateways/a2b
azurerm_local_network_gateway.a2b: Importing from ID "/subscriptions/<some subscription id>/resourceGroups/myRG/providers/microsoft.network/localnetworkgateways/a2b"...
azurerm_local_network_gateway.a2b: Import complete!
  Imported azurerm_local_network_gateway (ID: /subscriptions/<some subscription id>/resourceGroups/myRG/providers/microsoft.network/localnetworkgateways/a2b)
azurerm_local_network_gateway.a2b: Refreshing state... (ID: /subscriptions/<some subscription id>/resourceGroups/myRG/providers/microsoft.network/localnetworkgateways/a2b)
Error importing: 1 error(s) occurred:

* azurerm_local_network_gateway.a2b: unexpected EOF
panic: runtime error: invalid memory address or nil pointer dereference
2016/12/05 14:49:15 [DEBUG] plugin: terraform: [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x6b027e]
2016/12/05 14:49:15 [DEBUG] plugin: terraform:
2016/12/05 14:49:15 [DEBUG] plugin: terraform: goroutine 79 [running]:
2016/12/05 14:49:15 [DEBUG] plugin: terraform: panic(0x2947900, 0xc420012060)
2016/12/05 14:49:15 [DEBUG] plugin: terraform: 	/opt/go/src/runtime/panic.go:500 +0x1a1
2016/12/05 14:49:15 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/builtin/providers/azurerm.resourceArmLocalNetworkGatewayRead(0xc4205c8e40, 0x2b45760, 0xc420087a00, 0x0, 0x1d)
2016/12/05 14:49:15 [DEBUG] plugin: terraform: 	/opt/gopath/src/github.com/hashicorp/terraform/builtin/providers/azurerm/resource_arm_local_network_gateway.go:123 +0x47e
2016/12/05 14:49:15 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/helper/schema.(*Resource).Refresh(0xc4200a34a0, 0xc4204894f0, 0x2b45760, 0xc420087a00, 0xc4203b00a0, 0x1, 0x0)
2016/12/05 14:49:15 [DEBUG] plugin: terraform: 	/opt/gopath/src/github.com/hashicorp/terraform/helper/schema/resource.go:259 +0x131
2016/12/05 14:49:15 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/helper/schema.(*Provider).Refresh(0xc42039e7e0, 0xc420489450, 0xc4204894f0, 0x0, 0x18, 0x18)
2016/12/05 14:49:15 [DEBUG] plugin: terraform: 	/opt/gopath/src/github.com/hashicorp/terraform/helper/schema/provider.go:203 +0x91
2016/12/05 14:49:15 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/plugin.(*ResourceProviderServer).Refresh(0xc420170a40, 0xc420410190, 0xc4204103a0, 0x0, 0x0)
2016/12/05 14:49:15 [DEBUG] plugin: terraform: 	/opt/gopath/src/github.com/hashicorp/terraform/plugin/resource_provider.go:482 +0x4e
2016/12/05 14:49:15 [DEBUG] plugin: terraform: reflect.Value.call(0xc42039b9e0, 0xc4200e4628, 0x13, 0x2f64412, 0x4, 0xc42059ded0, 0x3, 0x3, 0xc420166c00, 0xc4203f0300, ...)
2016/12/05 14:49:15 [DEBUG] plugin: terraform: 	/opt/go/src/reflect/value.go:434 +0x5c8
2016/12/05 14:49:15 [DEBUG] plugin: terraform: reflect.Value.Call(0xc42039b9e0, 0xc4200e4628, 0x13, 0xc42059ded0, 0x3, 0x3, 0xb66e5f, 0xc42033cef0, 0xc42033cf00)
2016/12/05 14:49:15 [DEBUG] plugin: terraform: 	/opt/go/src/reflect/value.go:302 +0xa4
2016/12/05 14:49:15 [DEBUG] plugin: terraform: net/rpc.(*service).call(0xc420134fc0, 0xc420134f80, 0xc42012f818, 0xc420099880, 0xc4201716a0, 0x25c6800, 0xc420410190, 0x16, 0x25c6840, 0xc4204103a0, ...)
2016/12/05 14:49:15 [DEBUG] plugin: terraform: 	/opt/go/src/net/rpc/server.go:383 +0x148
2016/12/05 14:49:15 [DEBUG] plugin: terraform: created by net/rpc.(*Server).ServeCodec
2016/12/05 14:49:15 [DEBUG] plugin: terraform: 	/opt/go/src/net/rpc/server.go:477 +0x421
2016/12/05 14:49:15 [ERROR] root: eval: *terraform.EvalRefresh, err: azurerm_local_network_gateway.a2b: unexpected EOF
2016/12/05 14:49:15 [ERROR] root: eval: *terraform.EvalSequence, err: azurerm_local_network_gateway.a2b: unexpected EOF
2016/12/05 14:49:15 [TRACE] [walkImport] Exiting eval tree: import azurerm_local_network_gateway.a2b result: /subscriptions/<some subscription id>/resourceGroups/myRG/providers/microsoft.network/localnetworkgateways/a2b
2016/12/05 14:49:15 [DEBUG] vertex "provider.azurerm (close)", got dep: "azurerm_local_network_gateway.a2b (import id: /subscriptions/<some subscription id>/resourceGroups/myRG/providers/microsoft.network/localnetworkgateways/a2b)"
2016/12/05 14:49:15 [DEBUG] plugin: /Users/petrartamonov/bin/terraform: plugin process exited
2016/12/05 14:49:15 [DEBUG] plugin: waiting for all plugin processes to complete...



!!!!!!!!!!!!!!!!!!!!!!!!!!! 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 Terraform[1] 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.

[1]: https://github.com/hashicorp/terraform/issues

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

crash.txt

@whiskeyjay
Copy link
Contributor

@spuder Do you still see this issue? It sounds like a corrupted tfstate file caused the crash. If you still have the backup of the tfstate file, can you check whether it is in a valid json format? (Like all "{" and "}" are matching, so the parser won't hit EOF unexpectedly)

Thanks!

@spuder
Copy link
Contributor Author

spuder commented Mar 21, 2017

No, I'm not using terraform with azure at the moment. I'll close the issue. If someone else sees the issue I'll reopen.

@kmcquade
Copy link

kmcquade commented Sep 2, 2017

I know you probably figured it out by now... but you misspelled your us_address_space variable in the second to last line:

  address_space = ["${var.us_addres_sspace}"]

should be:

  address_space = ["${var.us_address_space}"]

@ghost
Copy link

ghost commented Apr 7, 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 7, 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

5 participants