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

Only handle root NS records special. #807

Merged
merged 2 commits into from
Nov 30, 2017
Merged

Only handle root NS records special. #807

merged 2 commits into from
Nov 30, 2017

Conversation

paddycarver
Copy link
Contributor

We introduced special handling for NS records in 1.2.0 under the
assumption that ALL NS records can't be deleted. This isn't actually
true. Only NS records for the naked domain of the managed zone can't be
removed; all other NS records can be. Because of this, 1.2.0 contains a
bug where all NS records are removed.

This update fixes the situation to only use special handling on NS
records that are for the naked root domain of the managed zone, and
treat all subdomain NS records as normal records. It also adds a test to
ensure this functionality.

Fixes #729.

We introduced special handling for NS records in 1.2.0 under the
assumption that ALL NS records can't be deleted. This isn't actually
true. Only NS records for the naked domain of the managed zone can't be
removed; all other NS records can be. Because of this, 1.2.0 contains a
bug where all NS records are removed.

This update fixes the situation to only use special handling on NS
records that are for the naked root domain of the managed zone, and
treat all subdomain NS records as normal records. It also adds a test to
ensure this functionality.

Fixes #729.
// if it's not actually a subdomain
var domain string
if d.Get("type").(string) == "NS" {
if domain == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

this condition will always be true... var domain is never updated after being set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Domain is updated 5 lines below, on line 190.

Copy link
Contributor

Choose a reason for hiding this comment

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

domain == "" will always be true. Nothing updates it between 183 and 185.

Copy link
Contributor Author

@paddycarver paddycarver Nov 30, 2017

Choose a reason for hiding this comment

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

Ah, yes, for some reason I was trying to reuse that request between records.

Which makes no sense. o.o

domain = mz.DnsName
}

if domain == d.Get("name").(string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why not comparing with record.Name like above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Above, we're comparing if a record exists with the same name we've configured. Here, we're testing if the root of the domain is the same as what we're trying to delete.

Basically, testing for two different things:

  1. On create, we want to make sure any NS records that currently exist are removed in the same request we're adding NS records in.
  2. On delete, we want to delete the record iff it's not both an NS record and the same name as the zone.

The first is achieved by listing the NS records on a zone, and making note of any that have the same name as the one we're adding, so they can be removed. The second is achieved by retrieving the name of the managed zone, and comparing it to the record we're trying to delete.

@paddycarver paddycarver merged commit 63df11e into master Nov 30, 2017
@paultyng paultyng deleted the paddy_729_ns branch October 29, 2018 19:29
@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 👉 hashibot-feedback@hashicorp.com. 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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression/Bug in 1.2.0 - Sub DNS Delegation broken with NS Changes
2 participants