Closed arianvp closed 2 years ago
Hey @arianvp thanks for reporting and for the logs, I'll take a look.
Please remove X-Auth-Token lines from the 2nd gist, it's your EM token.
@displague The issue template says
Note: the debug log will contain your API key, please review the log and delete sensitive secrets before submitting.
Maybe we can change it to:
Note: the debug log will contain your API key, please search the log for "X-Auth-Token" (HTTP request header holding the API token) and remove it.
The nil deref comes from a very common cast from the Read method of device resource. The meta interface is passed to every provider method. It's quite strange, I've never seen it before. I also don't think that any provider checks the meta interface for nil.
func resourceMetalDeviceRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*packngo.Client) // <<<<<<<<<<<<<<<<< HERE
@t0mk I've deleted the Auth Token from my account. thanks for the heads up :)
@arianvp reading code and issues didn't help, so I will try to hit the limit for a project.
@arianvp @displague I spent some time debugging, and I got similar panic when getting HTTP error with empty error slice, like this:
---[ REQUEST ]---------------------------------------
DELETE /metal/v1/projects/0a286170-17fc-43a0-9b68-4ddfb41c4f4c HTTP/1.1
Host: api.equinix.com
User-Agent: HashiCorp Terraform/0.11+compatible (+https://www.terraform.io) Terraform Plugin SDK/2.7.0 terraform-provider-metal/dev packngo/v0.19.1
Connection: close
Accept: application/json
Content-Type: application/json
X-Consumer-Token: aZ9GmqHTPtxevvFq9SK3Pi2yr9YCbRzduCSXF2SNem5sjB91mDq7Th3ZwTtRqMWZ
Accept-Encoding: gzip
-----------------------------------------------------: timestamp=2021-10-18T18:19:22.374+0300
2021-10-18T18:19:23.206+0300 [INFO] provider.terraform-provider-metal: 2021/10/18 18:19:23 [DEBUG] Equinix Metal API Response Details:
---[ RESPONSE ]--------------------------------------
HTTP/1.1 422 Unprocessable Entity
Connection: close
Content-Length: 13
Cache-Control: no-cache
Content-Type: application/json; charset=utf-8
Date: Mon, 18 Oct 2021 15:19:23 GMT
Strict-Transport-Security: max-age=15724800; includeSubDomains
X-Request-Id: 6e1b741e5249ce3f03812ebad8fd1770
{
"errors": []
}
Terraform SDK then soemhow receives an empty error, or even some struct that is not the error actually.
The error handling is really hard to debug at this point, but I'll try to fix it and submit a PR with a fix. Once that's in, we will re-release and you can try again.
Community Note
Terraform Version
Affected Resource(s)
Terraform Configuration Files
https://github.com/arianvp/packet-ipv6-kubernetes/blob/metal/provision.tf
Debug Output
https://gist.github.com/arianvp/6c670ca5be1f4541c1c12d9b67942409
Panic Output
https://gist.github.com/arianvp/6c670ca5be1f4541c1c12d9b67942409
Expected Behavior
Resources get destroyed
Actual Behavior
Terraform panics
Steps to Reproduce
terraform apply