terraform-provider-powerdns icon indicating copy to clipboard operation
terraform-provider-powerdns copied to clipboard

Uncaught 500 error from API for malformed SOA record

Open m33x-7 opened this issue 4 years ago • 2 comments

Terraform Version

$terraform --version
Terraform v0.12.20
+ provider.powerdns v1.3.0

Affected Resource(s)

  • powerdns_record

Terraform Configuration Files

resource "powerdns_record" "a" {
  zone = "example.com"
  name = "test.example.com."
  type = "A"
  ttl  = "86400"
  records = ["192.168.1.1"]
}

Debug Output

https://gist.github.com/m33x-7/4714f03fc12e04640fd075098a1f9ae4#file-apply-trace-1 https://gist.github.com/m33x-7/4714f03fc12e04640fd075098a1f9ae4#file-apply-trace-2 https://gist.github.com/m33x-7/4714f03fc12e04640fd075098a1f9ae4#file-tfstate-after-apply https://gist.github.com/m33x-7/4714f03fc12e04640fd075098a1f9ae4#file-destroy-trace-1 https://gist.github.com/m33x-7/4714f03fc12e04640fd075098a1f9ae4#file-tfstate-after-destroy

pdns server log:

HTTP ISE for "/api/v1/servers/localhost/zones/example.com": STL Exception: Parsing record content (try 'pdnsutil check-zone'): missing field at the end of record content '  2020072800 28800 7200 604800 86400'

API curl:

curl -v -H "X-API-Key: <--snip-->" http://localhost:8081/api/v1/servers/localhost/zones/example.com
* About to connect() to localhost port 8081 (#0)
*   Trying localhost...
* Connected to localhost (localhost) port 8081 (#0)
> GET /api/v1/servers/localhost/zones/example.com HTTP/1.1
> User-Agent: curl/7.29.0
> Host: localhost:8081
> Accept: */*
> X-API-Key: <--snip-->
>
< HTTP/1.1 500 Internal Server Error
< Connection: close
< Content-Length: 21
< Content-Type: text/plain; charset=utf-8
< Server: PowerDNS/4.1.6
<
* Closing connection 0

Panic Output

None

Expected Behavior

On error from the API terraform bails out and doesn't create the record

Actual Behavior

Terraform created the record, even though there was an error, but doesn't see that it's been created so attempts to create it again on further applys, and can't destroy the record.

Steps to Reproduce

  1. Create a malformed SOA record, e.g. it's missing MNAME and / or RNAME
  2. terraform apply with the above config, record is created
  3. terraform apply or terraform plan attempts to create the record again, even though it's in the statefile
  4. terraform destroy removes state, but doesn't remove the record

Important Factoids

Malformed SOA record was created by PowerAdmin, likely down to a configuration fault on my end. However outside of using the API DNS lookups are / were working fine.

Fixing the SOA record resolves the issue.

References

None

m33x-7 avatar Jul 28 '20 18:07 m33x-7