Reloading consul-template to reload templates

1,662 views
Skip to first unread message

Pete Emerson

unread,
Jan 30, 2015, 6:32:16 PM1/30/15
to consu...@googlegroups.com
I'm just getting into consul-template (running 0.6.0). What you've allowed me to do is get AirBnB's nerve / synapse functionality without zookeeper and all of the extra stuff. Awesome!

I notice that if my template changes (not the variables in the template, but the template itself), consul-template does not trigger a change. I conclude that consul-template is caching the template file. This means that if I change the template file (say, an nginx or haproxy config file), I need to restart consul-template.

Does it make sense to add a flag so that watching the template file itself is optional? It would be nice to atomically move a file into place and have the target file regenerated automatically, but I can also see situations where it would NOT be desired, too. Thoughts?

Related, I notice that sending a HUP to the consul-template process tries to do the right thing but then crashes the process. I submitted bug #175.

Pete

Seth Vargo

unread,
Jan 30, 2015, 9:51:11 PM1/30/15
to Pete Emerson, consu...@googlegroups.com
Hi Pete,

Thank you for your question - I'm glad Consul Template is solving a problem for you. I saw you opened #175 re: SIGHUP; I'll need to do more testing, but we actually have tests in the test suite specifically for that use case. It would be great if you could run the tests locally and see if they pass for you. But let's keep discussion about that issue on the issue (so we have all the communication on the ticket for reference).

Re: watching templates/config for changes on disk, we discussed this pretty heavily and decided against it in https://github.com/hashicorp/consul-template/issues/109. Specifically:

> After thinking this through further, we've decided against implementing this. The primary reason is that it makes it hard to stage changes to the template and control the roll out. Using an explicit SIGHUP allows for fine grained control of the reloading, where automatic reloading does not. In addition, this would introduce more complexity to the project. Instead, using a SIGHUP is a standard approach almost all software uses to handle configuration file updates.

Obviously that does not help if SIGHUP is broken in your situation, but we did not feel it was appropriate behavior for Consul Template to watch templates on disk (mostly for the reasons you've already identified). Consider a tool like nginx - you write the config, then you run `reload`. If you write a bad config, etc, YOU (the user) have control over the processes decision to reload it :).

Best,
Seth

--
You received this message because you are subscribed to the Google Groups "Consul" group.
To unsubscribe from this group and stop receiving emails from it, send an email to consul-tool...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pete Emerson

unread,
Feb 2, 2015, 12:58:37 PM2/2/15
to consu...@googlegroups.com, pe...@theemersons.org
Thanks for the info on #109. I don't think I agree fully, yet, as I think there's a difference between a configuration file (consul-template.conf) and a template file (nginx.ctmpl).

I think you could claim that the template is enforcing proper syntax of the file and the variables are simply populating it, but I don't think there's anything preventing you from doing something dumb with your variables which would then break the syntax of the file (Little Bobby Tables, we call him!).

On the other other hand, I could put the entire contents of the template into consul, which would give me automatic reloads anyway (not an elegant solution IMHO) ...

Given the lack of go file watching abilities (as mentioned in the ticket) and other priorities, I think you're probably coming to the right decision.

I've added more data to #175 to help figure out the HUP issue I'm having. Let me know how I can help further!

Thanks,
Pete

Seth Vargo

unread,
Feb 2, 2015, 1:03:49 PM2/2/15
to Pete Emerson, consu...@googlegroups.com
I'm looking into the weird HUP issues today/tomorrow.

Best,
Seth
Reply all
Reply to author
Forward
0 new messages