-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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: Reordering the checks after an Azure API Get #8607
Conversation
We are receiving suggestions of a panic as follows: ``` 2016/09/01 07:21:55 [DEBUG] plugin: terraform: panic: runtime error: invalid memory address or nil pointer dereference 2016/09/01 07:21:55 [DEBUG] plugin: terraform: [signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0xa3170f] 2016/09/01 07:21:55 [DEBUG] plugin: terraform: 2016/09/01 07:21:55 [DEBUG] plugin: terraform: goroutine 114 [running]: 2016/09/01 07:21:55 [DEBUG] plugin: terraform: panic(0x27f4e60, 0xc4200100e0) 2016/09/01 07:21:55 [DEBUG] plugin: terraform: /opt/go/src/runtime/panic.go:500 +0x1a1 2016/09/01 07:21:55 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/builtin/providers/azurerm.resourceArmVirtualMachineRead(0xc4206d8060, 0x2995620, 0xc4204d0000, 0x0, 0x17) 2016/09/01 07:21:55 [DEBUG] plugin: terraform: /opt/gopath/src/github.com/hashicorp/terraform/builtin/providers/azurerm/resource_arm_virtual_machine.go:488 +0x1ff 2016/09/01 07:21:55 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/helper/schema.(*Resource).Refresh(0xc420017a40, 0xc42040c780, 0x2995620, 0xc4204d0000, 0xc42019c990, 0x1, 0x0) ``` This is because the code is as follows: ``` resp, err := client.Get(resGroup, vnetName, name) if resp.StatusCode == http.StatusNotFound { d.SetId("") return nil } if err != nil { return fmt.Errorf("Error making Read request on Azure virtual network peering %s: %s", name, err) } ``` When a request throws an error, the response object isn't valid. Therefore, we need to flip that code to check the error first ``` resp, err := client.Get(resGroup, vnetName, name) if err != nil { return fmt.Errorf("Error making Read request on Azure virtual network peering %s: %s", name, err) } if resp.StatusCode == http.StatusNotFound { d.SetId("") return nil } ```
|
||
"github.com/Azure/azure-sdk-for-go/arm/network" | ||
"github.com/Azure/azure-sdk-for-go/core/http" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed this is still in some of the provider code, but no longer exists in the main repo. We should probably remove this throughout, and get rid of core/tls in the vendor dir too. (doesn't need to be in this PR though)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i will follow up with a PR for the SDK updates that should happen :)
LGTM |
Regressions were introduced when fixing hashicorp#8607 . Specifically when resources in the statefile are deleted or missing in real life, then terraform plan would exit with an error when it recieved a 404 not found. The correct behaviour would be to show a plan with the offer to create the missing resources.
Regressions were introduced when fixing hashicorp#8607 . Specifically when resources in the statefile are deleted or missing in real life, then terraform plan would exit with an error when it recieved a 404 not found. The correct behaviour would be to show a plan with the offer to create the missing resources.
Regressions were introduced when fixing hashicorp/terraform#8607 . Specifically when resources in the statefile are deleted or missing in real life, then terraform plan would exit with an error when it recieved a 404 not found. The correct behaviour would be to show a plan with the offer to create the missing resources.
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. |
We are receiving suggestions of a panic as follows:
This is because the code is as follows:
When a request throws an error, the response object isn't valid. Therefore, we need to flip that code to check the error first