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

Add support for DNS config hot-reload #4875

Merged
merged 1 commit into from
Apr 24, 2019

Conversation

ShimmerGlass
Copy link
Contributor

This PR adds support for hot-reloading recursors and dns_config.* settings on SIGHUP or consul reload.

DNS settings currently need an agent restart to be modified. This makes changing the configuration of consul agents queried by our DNS servers for .consul domains hard because they handle a lot of requests and cannot be easily restarted. The TTL and SOA settings are especially important due to their impact on performance.

This change stores the configuration in an atomic.Value and loads it at the beginning of each request. Reloading only affects requests that start after the reload. Ongoing requests are not affected. To match the current behavior the recursor handler is loaded and unloaded as needed on config change.

Copy link
Contributor

@pierresouchay pierresouchay left a comment

Choose a reason for hiding this comment

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

Looks great, being able to hot reload DNS config is a great feature when performing changes on a Consul agent while not degrading qOS on a DNS resolver, especially when it is a key in the infrastructure

Definitely deserves a look to increase operations in a real life cluster!

@pearkes pearkes added this to the Upcoming milestone Oct 31, 2018
@pierresouchay
Copy link
Contributor

@pearkes @mkeeler do you think it could be integrated?

The change is big in number of lines, but not that complex and would allow people using Consul DNS to limit the times agent do restart to take into account DNS parameters (such as cache settings)

It could be a huge win in terms of operability (since DNS is a very critical piece of infrastructure and limiting its downtime is really critical)

@pierresouchay
Copy link
Contributor

@Aestek Can you rebase this? it seems it still has conflicts...

The DNS config parameters `recursors` and `dns_config.*` are now hot
reloaded on SIGHUP or `consul reload` and do not need an agent restart
to be modified.
Config is stored in an atomic.Value and loaded at the beginning of each
request. Reloading only affects requests that start _after_ the
reload. Ongoing requests are not affected. To match the current
behavior the recursor handler is loaded and unloaded as needed on config
reload.
@pearkes pearkes modified the milestones: Upcoming, 1.4.4 Mar 8, 2019
@hanshasselberg hanshasselberg modified the milestones: 1.4.4, 1.5 Mar 19, 2019
Copy link
Member

@mkeeler mkeeler left a comment

Choose a reason for hiding this comment

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

This looks good to me. Everything I would have thought of looks to have already been handled.

One question I have is whether or not you are already running with this and if so have there been a noticeable performance degradation with the change? Doing an atomic Load once per request should be very minimal especially when stores are not happening often. Just curious if you have checked it out under load.

@pearkes
Copy link
Contributor

pearkes commented Apr 24, 2019

@Aestek Any feedback on the question from @mkeeler about any testing you might have done for this change?

@ShimmerGlass
Copy link
Contributor Author

@mkeeler @pearkes woops sorry didnt see the comment.
We've been running this for a while now althought we don't reload the config everyday and havnt noticed any difference.
This change shouldn't have any performance impact since an atomic read was already done for a specific setting (https://github.com/hashicorp/consul/pull/4875/files#diff-0f2130d66e011e1af6e42f93492a3536L264). I just extended that to all DNS settings.

@mkeeler
Copy link
Member

mkeeler commented Apr 24, 2019

@Aestek thanks for the update.

@mkeeler mkeeler merged commit f669bb7 into hashicorp:master Apr 24, 2019
Copy link
Contributor

@pearkes pearkes left a comment

Choose a reason for hiding this comment

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

I think we actually missed adding this to https://www.consul.io/docs/agent/options.html#reloadable-configuration as well, we should do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants