Prevent null reference when reading boot_diagnostics settings. #10283
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I ran into this scenario on a few virtual machines. The rest response contained this:
2016/11/21 22:12:40 [DEBUG] plugin: terraform.exe: "diagnosticsProfile": {
2016/11/21 22:12:40 [DEBUG] plugin: terraform.exe: "bootDiagnostics": {
2016/11/21 22:12:40 [DEBUG] plugin: terraform.exe: "enabled": false
2016/11/21 22:12:40 [DEBUG] plugin: terraform.exe: }
2016/11/21 22:12:40 [DEBUG] plugin: terraform.exe: },
Which caused the following panic in 0.7.10 and 0.7.11:
2016/11/21 21:48:10 [DEBUG] plugin: terraform.exe: panic: runtime error: invalid memory address or nil pointer dereference
2016/11/21 21:48:10 [DEBUG] plugin: terraform.exe: [signal 0xc0000005 code=0x0 addr=0x0 pc=0xb1e6cb]
2016/11/21 21:48:10 [DEBUG] plugin: terraform.exe:
2016/11/21 21:48:10 [DEBUG] plugin: terraform.exe: goroutine 3642 [running]:
2016/11/21 21:48:10 [DEBUG] plugin: terraform.exe: panic(0x2a99da0, 0xc04200e090)
2016/11/21 21:48:10 [DEBUG] plugin: terraform.exe: /opt/go/src/runtime/panic.go:500 +0x1af
2016/11/21 21:48:10 [DEBUG] plugin: terraform.exe: github.com/hashicorp/terraform/builtin/providers/azurerm.resourceArmVirtualMachineRead(0xc042e762a0, 0x2cce4e0, 0xc042061a00, 0x0, 0x17)
2016/11/21 21:48:10 [DEBUG] plugin: terraform.exe: /opt/gopath/src/github.com/hashicorp/terraform/builtin/providers/azurerm/resource_arm_virtual_machine.go:613 +0xedb
2016/11/21 21:48:10 [DEBUG] plugin: terraform.exe: github.com/hashicorp/terraform/helper/schema.(*Resource).Refresh(0xc0422fcae0, 0xc042ee20f0, 0x2cce4e0, 0xc042061a00, 0xc0420422b0, 0x1, 0x18)
This fix handles this case by preventing the nil dereference in this case. I'm not sure why only a few VMs experienced the initial issue but this solved it for me.