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

provider/azurerm: Crash in Virtual Machines on an empty Windows Config block #13754

Closed
wants to merge 6 commits into from

Conversation

tombuildsstuff
Copy link
Contributor

Currently Terraform crashes with the following stack trace when specifying an empty os_profile_windows_config block in an azurerm_virtual_machine resource (full details in #10744):

2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: panic: interface conversion: interface {} is nil, not map[string]interface {}
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: 
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: goroutine 76 [running]:
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: github.com/hashicorp/terraform/builtin/providers/azurerm.resourceArmVirtualMachineStorageOsProfileWindowsConfigHash(0x0, 0x0, 0xc4203cb798)
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: 	/Users/tharvey/code/src/github.com/hashicorp/terraform/builtin/providers/azurerm/resource_arm_virtual_machine.go:868 +0x3b9
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: github.com/hashicorp/terraform/helper/schema.(*Set).hash(0xc4203cb780, 0x0, 0x0, 0x1965f40, 0xc4201cb2c0)
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: 	/Users/tharvey/code/src/github.com/hashicorp/terraform/helper/schema/set.go:180 +0x3d
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: github.com/hashicorp/terraform/helper/schema.(*Set).add(0xc4203cb780, 0x0, 0x0, 0xc42037fc00, 0x0, 0xc4203cbae0)
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: 	/Users/tharvey/code/src/github.com/hashicorp/terraform/helper/schema/set.go:167 +0x81
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: github.com/hashicorp/terraform/helper/schema.(*ConfigFieldReader).readSet(0xc420481920, 0xc4204ab500, 0x1, 0x1, 0xc42037fc20, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: 	/Users/tharvey/code/src/github.com/hashicorp/terraform/helper/schema/field_reader_config.go:289 +0x3b0
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: github.com/hashicorp/terraform/helper/schema.(*ConfigFieldReader).readField(0xc420481920, 0xc4204ab500, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: 	/Users/tharvey/code/src/github.com/hashicorp/terraform/helper/schema/field_reader_config.go:115 +0x93c
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: github.com/hashicorp/terraform/helper/schema.(*ConfigFieldReader).ReadField(0xc420481920, 0xc4204ab500, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, ...)
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: 	/Users/tharvey/code/src/github.com/hashicorp/terraform/helper/schema/field_reader_config.go:27 +0xe3
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: github.com/hashicorp/terraform/helper/schema.(*MultiLevelFieldReader).ReadFieldExact(0xc420495b60, 0xc4204ab500, 0x1, 0x1, 0x1a6210d, 0x6, 0x0, 0x0, 0x0, 0x0, ...)
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: 	/Users/tharvey/code/src/github.com/hashicorp/terraform/helper/schema/field_reader_multi.go:31 +0xef
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: github.com/hashicorp/terraform/helper/schema.(*ResourceData).get(0xc420108930, 0xc4204ab500, 0x1, 0x1, 0xc4204ab512, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: 	/Users/tharvey/code/src/github.com/hashicorp/terraform/helper/schema/resource_data.go:475 +0x13a
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: github.com/hashicorp/terraform/helper/schema.(*ResourceData).getChange(0xc420108930, 0x1a7531e, 0x19, 0xc420451201, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: 	/Users/tharvey/code/src/github.com/hashicorp/terraform/helper/schema/resource_data.go:451 +0x135
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: github.com/hashicorp/terraform/helper/schema.(*ResourceData).diffChange(0xc420108930, 0x1a7531e, 0x19, 0xc42037b860, 0xc4206dd618, 0xc420108930, 0x1, 0x0)
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: 	/Users/tharvey/code/src/github.com/hashicorp/terraform/helper/schema/resource_data.go:428 +0x61
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: github.com/hashicorp/terraform/helper/schema.schemaMap.diffSet(0xc4201cb3b0, 0x1a7531e, 0x19, 0xc42037fc20, 0xc4206dd618, 0xc420108930, 0x1a19a00, 0x0, 0x0)
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: 	/Users/tharvey/code/src/github.com/hashicorp/terraform/helper/schema/schema.go:915 +0x5d
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: github.com/hashicorp/terraform/helper/schema.schemaMap.diff(0xc4201cb3b0, 0x1a7531e, 0x19, 0xc42037fc20, 0xc420495960, 0xc420108930, 0x111a400, 0x0, 0x0)
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: 	/Users/tharvey/code/src/github.com/hashicorp/terraform/helper/schema/schema.go:678 +0x4b1
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: github.com/hashicorp/terraform/helper/schema.schemaMap.Diff(0xc4201cb3b0, 0xc420016500, 0xc420481380, 0x0, 0x0, 0xa)
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: 	/Users/tharvey/code/src/github.com/hashicorp/terraform/helper/schema/schema.go:389 +0x1c2
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: github.com/hashicorp/terraform/helper/schema.(*Resource).Diff(0xc4201dbd40, 0xc420016500, 0xc420481380, 0x17, 0xc420392178, 0x1)
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: 	/Users/tharvey/code/src/github.com/hashicorp/terraform/helper/schema/resource.go:211 +0x15b
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: github.com/hashicorp/terraform/helper/schema.(*Provider).Diff(0xc4201d60e0, 0xc420016370, 0xc420016500, 0xc420481380, 0x23004b0, 0x0, 0xc42001f300)
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: 	/Users/tharvey/code/src/github.com/hashicorp/terraform/helper/schema/provider.go:255 +0x84
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: github.com/hashicorp/terraform/plugin.(*ResourceProviderServer).Diff(0xc4201c63a0, 0xc420495040, 0xc4204c3040, 0x0, 0x0)
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: 	/Users/tharvey/code/src/github.com/hashicorp/terraform/plugin/resource_provider.go:499 +0x57
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: reflect.Value.call(0xc42027f0e0, 0xc42024e750, 0x13, 0x1a6033d, 0x4, 0xc420233f20, 0x3, 0x3, 0x0, 0xc4204a66c0, ...)
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: 	/usr/local/Cellar/go/1.8/libexec/src/reflect/value.go:434 +0x91f
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: reflect.Value.Call(0xc42027f0e0, 0xc42024e750, 0x13, 0xc420211f20, 0x3, 0x3, 0xc4203421e0, 0xc420211f48, 0xc420211f48)
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: 	/usr/local/Cellar/go/1.8/libexec/src/reflect/value.go:302 +0xa4
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: net/rpc.(*service).call(0xc420353880, 0xc420353840, 0xc420359a48, 0xc42029f700, 0xc42028e800, 0x18ed440, 0xc420495040, 0x16, 0x18ed480, 0xc4204c3040, ...)
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: 	/usr/local/Cellar/go/1.8/libexec/src/net/rpc/server.go:387 +0x144
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: created by net/rpc.(*Server).ServeCodec
2017/04/18 20:41:06 [DEBUG] plugin: terraform-provider-azurerm: 	/usr/local/Cellar/go/1.8/libexec/src/net/rpc/server.go:481 +0x404

Fixes #10744

@tombuildsstuff
Copy link
Contributor Author

Tests pass (ignoring the subscription specific failure):
screen shot 2017-04-19 at 10 25 01

@tombuildsstuff tombuildsstuff changed the title [WIP] provider/azurerm: Crash in Virtual Machines on an empty Windows Config block provider/azurerm: Crash in Virtual Machines on an empty Windows Config block Apr 19, 2017
@@ -354,10 +354,12 @@ func resourceArmVirtualMachine() *schema.Resource {
"provision_vm_agent": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are changing these to have a default, we need to include a schema migration IMO

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking the Azure docs & #9995 - the default value for the provisionVMAgent field should be true if it's unset:

When this property is not specified in the request body, default behavior is to set it to true. This will ensure that VM Agent is installed on the VM so that extensions can be added to the VM later.

I'll update this and look into a schema migration

grubernaut
grubernaut previously approved these changes Apr 26, 2017
Copy link
Contributor

@grubernaut grubernaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :shipit:

@tombuildsstuff
Copy link
Contributor Author

Testing some edge-cases here, when using 0.9.3 and the following config:

  os_profile_windows_config {
    provision_vm_agent = false
  }

Which generates the following plan when switching to this branch:

    os_profile_windows_config.#:                                       "1" => "1"
    os_profile_windows_config.3590083716.additional_unattend_config.#: "" => "0"
    os_profile_windows_config.3590083716.enable_automatic_upgrades:    "" => "true" (forces new resource)
    os_profile_windows_config.3590083716.provision_vm_agent:           "" => "false" (forces new resource)
    os_profile_windows_config.3590083716.winrm.#:                      "" => "0"
    os_profile_windows_config.429474957.additional_unattend_config.#:  "0" => "0"
    os_profile_windows_config.429474957.enable_automatic_upgrades:     "false" => "false"
    os_profile_windows_config.429474957.provision_vm_agent:            "false" => "false"
    os_profile_windows_config.429474957.winrm.#:                       "0" => "0"

Which needs fixing

@grubernaut grubernaut dismissed their stale review April 26, 2017 12:02

State Migration needs some love

@rrudduck
Copy link
Contributor

rrudduck commented Jun 5, 2017

Just a FYI - In cases where you are attaching an existing OS drive, the entire resp.VirtualMachineProperties.OsProfile can be nil. I ran into that issue and patched it on my branch, but haven't had time to commit the tests, etc. It's just a simple check for resp.VirtualMachineProperties.OsProfile being nil - if it is exlcude the whole block.

rrudduck@0c3cfc7

@tombuildsstuff
Copy link
Contributor Author

(update: I've started fixing this & porting it over to the new repo)

@catsby
Copy link
Contributor

catsby commented Aug 8, 2017

@tombuildsstuff
Copy link
Contributor Author

I've migrated the fix for this crash identified in this issue over the new repository here: hashicorp/terraform-provider-azurerm#222

Rather than combine the fix for hashicorp/terraform-provider-azurerm#28 too - I've split this out into a separate PR so we can handle bumping the provider version at the same time

Closing this PR in the interim..

@tombuildsstuff tombuildsstuff deleted the fix-10744 branch August 8, 2017 20:20
@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

Successfully merging this pull request may close these issues.

Azure RM VM with Subnets issue
5 participants