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 #200

Closed
hashibot opened this issue Jul 27, 2017 · 3 comments · Fixed by #204
Closed

Terraform Crash #200

hashibot opened this issue Jul 27, 2017 · 3 comments · Fixed by #204
Assignees

Comments

@hashibot
Copy link

hashibot commented Jul 27, 2017

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


Terraform Version

In the gist

Terraform Configuration Files

# Configure the Microsoft Azure Provider
provider "azurerm" {
  subscription_id = "${var.subscription_id}"
  client_id       = "${var.client_id}"
  client_secret   = "${var.client_secret}"
  tenant_id       = "${var.tenant_id}"
}

# create a resource group
resource "azurerm_resource_group" "arg" {
    name = "${var.my_resource_group}"
    location = "${var.location_id}"

    tags {
      CreateDate = "${timestamp()}"
      CreatedBy = "${var.created_by}"
      AIT = "${var.ait}"
      Environment = "${var.environment}"
    }
}

# create storage account
resource "azurerm_storage_account" "asa" {
    name = "${var.my_storage_account}"
    resource_group_name = "${azurerm_resource_group.arg.name}"
    location = "${var.location_id}"
    account_type = "Standard_LRS"

    tags {
      CreateDate = "${timestamp()}"
      CreatedBy = "${var.created_by}"
      AIT = "${var.ait}"
      Environment = "${var.environment}"
    }
}

# create storage container
resource "azurerm_storage_container" "asc" {
    name = "${var.my_storage_container}"
    resource_group_name = "${azurerm_resource_group.arg.name}"
    storage_account_name = "${azurerm_storage_account.asa.name}"
    container_access_type = "private"
    depends_on = ["azurerm_storage_account.asa"]
    depends_on = ["azurerm_resource_group"]
}

# create NSG
resource "azurerm_network_security_group" "ansg" {
  name = "${var.my_network_security_group}"
  location = "${var.location_id}"
  resource_group_name = "${azurerm_resource_group.arg.name}"

  security_rule {
    name                       = "HTTP-Allow"
    priority                   = 110
    direction                  = "Inbound"
    access                     = "Allow"
    protocol                   = "Tcp"
    source_port_range          = "*"
    destination_port_range     = "80"
    source_address_prefix      = "*"
    destination_address_prefix = "10.0.1.0/24"
  }

  security_rule {
    name                       = "HTTPS-Allow"
    priority                   = 120
    direction                  = "Inbound"
    access                     = "Allow"
    protocol                   = "Tcp"
    source_port_range          = "*"
    destination_port_range     = "443"
    source_address_prefix      = "*"
    destination_address_prefix = "10.0.1.0/24"
  }

  tags {
    CreateDate = "${timestamp()}"
    CreatedBy = "${var.created_by}"
    AIT = "${var.ait}"
    Environment = "${var.environment}"
  }
}

# create virtual network
resource "azurerm_virtual_network" "analyticsVN" {
    name = "analyticsVN"
    address_space = ["10.1.0.0/16"]
    location = "${var.location_id}"
    resource_group_name = "${var.my_resource_group}"
    depends_on = ["azurerm_storage_account.asa"]
    depends_on = ["azurerm_resource_group"]
    
    tags {
      CreateDate = "${timestamp()}"
      CreatedBy = "${var.created_by}"
      AIT = "${var.ait}"
      Environment = "${var.environment}"
    }
}

# create subnet
resource "azurerm_subnet" "analyticsSN" {
    name = "analyticsSN"
    resource_group_name = "${var.my_resource_group}"
    virtual_network_name = "${azurerm_virtual_network.analyticsVN.name}"
    address_prefix = "10.1.0.0/22"
}

# create network interface
resource "azurerm_network_interface" "analyticsNIC" {
    count = "${var.my_count}"
    name = "analyticsNIC${format("%03d", count.index)}"
    location = "${var.location_id}"
    resource_group_name = "${var.my_resource_group}"

    ip_configuration {
        name = "analyticsNICip${format("%03d", count.index)}"
        subnet_id = "${azurerm_subnet.analyticsSN.id}"
        private_ip_address_allocation = "dynamic"
    }

    tags {
      CreateDate = "${timestamp()}"
      CreatedBy = "${var.created_by}"
      AIT = "${var.ait}"
      Environment = "${var.environment}"
    }
}

# create virtual machine
resource "azurerm_virtual_machine" "analyticsVM" {
    count = "${var.my_count}"
    name = "${var.computer_name}${format("%03d", count.index)}"
    location = "${var.location_id}"
    resource_group_name = "${var.my_resource_group}"
    network_interface_ids = ["${element(azurerm_network_interface.analyticsNIC.*.id, count.index)}"]
    vm_size = "Standard_D2"

    storage_image_reference {
        publisher = "RedHat"
        offer = "RHEL"
        sku = "7.3"
        version = "latest"
    }

    storage_os_disk {
        name = "osdisk${format("%03d", count.index)}"
        vhd_uri = "${azurerm_storage_account.asa.primary_blob_endpoint}${azurerm_storage_container.asc.name}/osdisk${format("%03d", count.index)}.vhd"
        caching = "ReadWrite"
        create_option = "FromImage"
    }

    os_profile {
        computer_name = "${var.computer_name}${format("%03d", count.index)}"
        admin_username = "${var.admin_username}${format("%03d", count.index)}"
        admin_password = "${var.admin_password}${format("%03d", count.index)}"
    }

    os_profile_linux_config {
        disable_password_authentication = false
    }

    tags {
      CreateDate = "${timestamp()}"
      CreatedBy = "${var.created_by}"
      AIT = "${var.ait}"
      Environment = "${var.environment}"
    }
}

Debug Output

Panic Output

https://gist.github.com/brettaukburg/7ef24d9d8ff70b58bc42c9708e640944

Expected Behavior

I expected the "terraform destroy -parallelism=200" to remove all the resources that I had built with Terraform.

Actual Behavior

Terraform panics instead of executing any of the destroy.

Steps to Reproduce

  1. terraform apply -parallelism=200
  2. wait for build to complete (in this case, there were Azure errors due to subscription limits so not all resources could be created)
  3. terraform destroy -parallelism=200

Important Factoids

Running in Azure
The subscription had a limit of 800 VMs which stopped the original apply

References

none

@grubernaut
Copy link
Contributor

Stack trace:

2017/07/27 10:04:40 [DEBUG] plugin: terraform: panic: runtime error: invalid memory address or nil pointer dereference
2017/07/27 10:04:40 [DEBUG] plugin: terraform: [signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x2a33710]
2017/07/27 10:04:40 [DEBUG] plugin: terraform: 
2017/07/27 10:04:40 [DEBUG] plugin: terraform: goroutine 7552 [running]:
2017/07/27 10:04:40 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/builtin/providers/azurerm.resourceArmNetworkInterfaceRead(0xc42023f730, 0x5ab8b40, 0xc42091a000, 0x0, 0x8e17dc0)
2017/07/27 10:04:40 [DEBUG] plugin: terraform: 	/opt/gopath/src/github.com/hashicorp/terraform/builtin/providers/azurerm/resource_arm_network_interface_card.go:258 +0x650
2017/07/27 10:04:40 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/helper/schema.(*Resource).Refresh(0xc420966720, 0xc42161b950, 0x5ab8b40, 0xc42091a000, 0xc420599478, 0xc420956601, 0x1050500)
2017/07/27 10:04:40 [DEBUG] plugin: terraform: 	/opt/gopath/src/github.com/hashicorp/terraform/helper/schema/resource.go:314 +0x21d
2017/07/27 10:04:40 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/helper/schema.(*Provider).Refresh(0xc42031c770, 0xc42161b900, 0xc42161b950, 0xa300000, 0xc4207661a0, 0x100feff)
2017/07/27 10:04:40 [DEBUG] plugin: terraform: 	/opt/gopath/src/github.com/hashicorp/terraform/helper/schema/provider.go:267 +0x91
2017/07/27 10:04:40 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/plugin.(*ResourceProviderServer).Refresh(0xc42095ac60, 0xc42047a980, 0xc42047b780, 0x0, 0x0)
2017/07/27 10:04:40 [DEBUG] plugin: terraform: 	/opt/gopath/src/github.com/hashicorp/terraform/plugin/resource_provider.go:510 +0x4e
2017/07/27 10:04:40 [DEBUG] plugin: terraform: reflect.Value.call(0xc42032bf20, 0xc4207b7980, 0x13, 0x61484cd, 0x4, 0xc422f1ff20, 0x3, 0x3, 0x0, 0xc4232ff6f8, ...)
2017/07/27 10:04:40 [DEBUG] plugin: terraform: 	/opt/go/src/reflect/value.go:434 +0x91f
2017/07/27 10:04:40 [DEBUG] plugin: terraform: reflect.Value.Call(0xc42032bf20, 0xc4207b7980, 0x13, 0xc4232ff720, 0x3, 0x3, 0xc4232ff7c0, 0x13ceb8e, 0xc421a8e780)
2017/07/27 10:04:40 [DEBUG] plugin: terraform: 	/opt/go/src/reflect/value.go:302 +0xa4
2017/07/27 10:04:40 [DEBUG] plugin: terraform: net/rpc.(*service).call(0xc42094f8c0, 0xc42094f880, 0xc420953f00, 0xc420307000, 0xc4207bb6e0, 0x523b3a0, 0xc42047a980, 0x16, 0x523b3e0, 0xc42047b780, ...)
2017/07/27 10:04:40 [DEBUG] plugin: terraform: 	/opt/go/src/net/rpc/server.go:387 +0x144
2017/07/27 10:04:40 [DEBUG] plugin: terraform: created by net/rpc.(*Server).ServeCodec
2017/07/27 10:04:40 [DEBUG] plugin: terraform: 	/opt/go/src/net/rpc/server.go:481 +0x404

@tombuildsstuff
Copy link
Contributor

Hey @brettaukburg

Thanks for reporting this issue - I've taken a look into this and opened PR #204 with a fix.

Thanks!

tombuildsstuff added a commit that referenced this issue Aug 1, 2017

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Checking the HTTP Response isn't `nil`. Fixes #200
@ghost
Copy link

ghost commented Apr 1, 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 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 1, 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.

3 participants