-
Notifications
You must be signed in to change notification settings - Fork 45
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
Add ns update support #74
Conversation
3aae520
to
3d41d5d
Compare
I don't know if this one is in line with your philosphy, as it tricks the zone update function to make a record update. It is an exception to not follow the API 1:1 but makes the use comfortable. Another way would be to remove the nameserver option. Regards |
powerdns/resource_powerdns_zone.go
Outdated
shouldUpdate := false | ||
if d.HasChange("kind") { | ||
zoneInfo := ZoneInfoUpd{} | ||
if d.HasChange("kind") || d.HasChange("account") || d.HasChange("soa_edit_api") { |
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.
These lines are not related to NS change, and shouldn't be part of this PR.
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.
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.
The PRs don't have to be accepted in chronological order. I would like to keep separate issues separate.
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.
Ok, I'll drop it soon
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.
OK, thanks 👍
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.
Removed
powerdns/resource_powerdns_zone.go
Outdated
rrSet := ResourceRecordSet{ | ||
Name: d.Get("name").(string), | ||
Type: "NS", | ||
TTL: 3600, |
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.
TTL shouldn't have value hard coded. It should be set, based on current value on the server. The 3600
is the default that PowerDNS server sets when none is provided(https://doc.powerdns.com/authoritative/settings.html#default-ttl), but according to first paragraph here: https://doc.powerdns.com/authoritative/settings.html, this can be changed in pdns.conf. file, meaning we would be overriding their setting. Also someone might change TTL to custom value, and we should override it.
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.
We could change the struct to mark this field with omitempty, at least.
I can also pull the records first to extract the TTL, or add a parameter to let the user provide one (and falling back to the retrieved value if none is provided).
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.
Pull the records first and extract TTL. Adding parameter for NS TTL to zone doesn't make sense from user point of view as this wouldn't have any effect during zone creation, but only during NS update.
Putting omitempty
is good idea, since based on documentation the PowerDNS will fall back to the default value if this field is not provided.
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.
Done. I tested it on my test instance:
- Setting a default ttl to 600
- Create the zone: the NS RRSet have a TTL of 600
- Adding a new name server in my tf code
- The RRSet is still 600.
- Removing the NS from tf also removes the zone NS.
- The API returns an error if the TTL is omitted in the RRSet: "Key 'ttl' not an Integer or not present". It is computed from existing NS (or default to the SOA value if none are present. The SOA can be removed. We can add a default value then or do not try the SOA at all)
powerdns/resource_powerdns_zone.go
Outdated
records = append(records, | ||
Record{Name: rrSet.Name, | ||
Type: rrSet.Type, | ||
TTL: 3600, |
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.
Same argument as it was made above, TTL shouldn't be hardcoded
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.
Same here, but It looks like it is obsolete to set it at the record level. It's commented so in the client.
Let me know, I can apply the same logic as the RRSet or just remove the field from the client.
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 confirm that with the API v1 the TTL is on the RRSet and not on the record
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.
Changing this has no effect in PowerDNS > 4.3 but I use the RRSet value anyway
7e67745
to
c6d7fdc
Compare
c6d7fdc
to
52b6376
Compare
@jbe-dw why did you add condition for checking size of nameserver list on this line? https://github.com/pan-net/terraform-provider-powerdns/blob/master/powerdns/resource_powerdns_zone.go#L143 I just realized the tests are failing and I have identified this to be the reason. I have used |
I added this check for the update, because the state would be different than the definition and it triggers a change that never applies when nameservers paramater is not used. And you wouldn't want to delete the NS records as they can be managed through powerdns_record. |
It seems that it breaks Here is one of the tests that fails.
|
Tests are still broken in importing nameservers section :( |
This is an example for issue #63