Skip to content
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

dns: Add special handling for ns records. #359

Merged
merged 3 commits into from
Nov 8, 2017
Merged

Conversation

paddycarver
Copy link
Contributor

Cloud DNS requires every managed zone to have an NS record at all times.
This means if people want to manage their own NS records, we need to add
their new record and remove the old one in the same call. It also means
we can't delete NS records, as we wouldn't know what to replace it with.
So deleting of NS records short-circuits. For the case of terraform destroy, this prevents the error. It does mean if the user explicitly
tries to remove their NS zone from their project, it silently does
nothing, but that's unavoidable unless we want to A) restore a default
value (and it looks like the default values change from zone to zone?
And that is arguably just as unexpected?) or B) let the (arguably more
reasonable) terraform destroy case be impossible.

Fixes #95.

Cloud DNS requires every managed zone to have an NS record at all times.
This means if people want to manage their own NS records, we need to add
their new record and remove the old one in the same call. It also means
we can't delete NS records, as we wouldn't know what to replace it with.
So deleting of NS records short-circuits. For the case of `terraform
destroy`, this prevents the error. It does mean if the user explicitly
tries to remove their NS zone from their project, it silently does
nothing, but that's unavoidable unless we want to A) restore a default
value (and it looks like the default values change from zone to zone?
And that is arguably just as unexpected?) or B) let the (arguably more
reasonable) `terraform destroy` case be impossible.
Copy link
Contributor

@catsby catsby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code wise 👍 , I'd like to see documentation for the users to understand what happens and why

@@ -77,6 +77,25 @@ func resourceDnsRecordSetCreate(d *schema.ResourceData, meta interface{}) error
},
}

if d.Get("type").(string) == "NS" {
log.Printf("{DEBUG] DNS record list request for %q", zone)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo { instead of [

// NS records must always have a value, so we short-circuit delete
// this allows terraform delete to work, but may have unexpected
// side-effects when deleting just that record set.
if d.Get("type").(string) == "NS" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put a [DEBUG] log here; Terraform is doing something "unexpected", or otherwise lying to people, so let's tell them that we aren't doing X because of Y, and link to some documentation. Either Google's or preferably some kind of NOTE on https://www.terraform.io/docs/providers/google/r/dns_record_set.html that explains the what and why here.

@radeksimko radeksimko added the bug label Oct 8, 2017
@danawillow
Copy link
Contributor

@paddycarver, what's the status on this?

Fix typo, add log line, and document what we're doing on the website.
@paddycarver
Copy link
Contributor Author

Sorry for the delay on this, believe I've addressed all the comments.

@danawillow danawillow self-requested a review November 7, 2017 23:51
Copy link
Contributor

@danawillow danawillow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just one quick thing (feel free to merge once you've addressed it, I don't need to re-review)

$ make testacc TEST=./google TESTARGS='-run=TestAccDnsRecordSet_ns'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./google -v -run=TestAccDnsRecordSet_ns -timeout 120m
=== RUN   TestAccDnsRecordSet_ns
--- PASS: TestAccDnsRecordSet_ns (12.23s)
PASS
ok  	github.com/terraform-providers/terraform-provider-google/google	12.375s

@@ -77,6 +77,25 @@ func resourceDnsRecordSetCreate(d *schema.ResourceData, meta interface{}) error
},
}

if d.Get("type").(string) == "NS" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment explaining why this section needs to happen? (even just a link to the docs is probably fine)

Add a comment explaining why we have such wonky update logic in the
create func for NS record sets.
@paddycarver
Copy link
Contributor Author

@danawillow just updated with the comment. Good to merge?

@danawillow
Copy link
Contributor

Yup

@paddycarver paddycarver merged commit 8b2486c into master Nov 8, 2017
@paultyng paultyng deleted the paddy_95_dns_ns branch October 29, 2018 19:29
chrisst pushed a commit to chrisst/terraform-provider-google that referenced this pull request Nov 9, 2018
…s_ns

dns: Add special handling for ns records.
@ghost
Copy link

ghost commented Nov 16, 2018

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Nov 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants