Open jamesbtate opened 4 years ago
I tried digging into this on my own even though I have essentially zero experience with Go. I see the actual interaction with Infoblox API occurs in the infoblox-go-client code. Specifically this function which is called from line 109 of resource_infoblox_ip_allocation.go: https://github.com/terraform-providers/terraform-provider-infoblox/blob/7efc53b7e406ddb319c0a351678c282118bed549/vendor/github.com/infobloxopen/infoblox-go-client/object_manager.go#L433
At the end of that function, there are these four lines (455-458):
ref, err := objMgr.connector.CreateObject(recordHost)
recordHost.Ref = ref
err = objMgr.connector.GetObject(recordHost, ref, &recordHost)
return recordHost, err
It looks to me like any error that occurs in line 455 is unchecked and the error is replaced by any error that may occur in line 457. Is that the correct interpretation? This would match my suspicion that this bug is caused by a bad search after the failed create.
Should I open a new issue i that repo for this issue?
The error message returned will be from the go-client code only. Terraform just appends the output thrown by the Go code. As you pointed out it looks suspicious on why that error is left out without being returned. For updates on that Git you should probably raise a request on that Git Page.
It turns out I don't understand how the infobloxopen/infoblox-go-client repo is included in this repo. Is it really just a copy of the source code? Is that how golang does dependencies?
In any case, this is actually fixed in the master
branch: https://github.com/infobloxopen/infoblox-go-client/blob/master/object_manager.go#L437. The expected check for non-nil err is present. It was added in this commit on August 5, 2020: https://github.com/infobloxopen/infoblox-go-client/commit/efdea6e938a75c51b6f7b5d3856616fc89bb2976.
What is the process to get this included in the Terraform provider? I don't see anything about that in the README.md.
Our plugin works on go-client dependency and hence its included. Will update the latest infoblox-go client to this branch.
When an attempt is made to create a host record (with DNS enabled) record using the infoblox_ip_allocation resource, but a record already exists with that name, the wrong error is shown in the output. Debug logging shows the expected error but the output only shows the below misleading error message.
I suspect the provider is doing some sort of search after the name conflict is detected. And erroneously using the
configure_for_dns
parameter in the search filter.Sample configuration:
Steps to reproduce:
Console output of the above steps:
Correct error in debug output:
Tested with Terraform 0.13.0 and 0.12.13. And with provider version 1.0.0 and 1.1.0. Same results in all cases.