Just the default configuration.
The template:
{{- with $REDIRECTS := key "/redirects" | parseJSON }}{{ range $K, $V := $REDIRECTS }}
http-request redirect location http://{{ $V }}%[capture.req.uri] if { hdr(host) -i {{ $K }} }
{{- end }}{{ end }}
In the /redirects key:
{
"foo": "bar",
"baz": "bazza
}
consul-template -retry 1s -consul-retry-attempts 10080 --template foo.ctmpl -dry
https://gist.github.com/niko/8dac306eed91b673a3209831941e0c7b
It should just log an error to STDout (or STDerr) and do nothing else. Don't write templates, don't restart any attached processes.
It crashes when parseJSON encounters corrupt json.
IMHO it should not be possible to crash a running consul-template process not matter the data in consul changes. In containers consul-template is meant to be PID 1. It should never crash.
I added a comment here: https://github.com/hashicorp/consul-template/issues/1165
I'm not sure that my issue and that are actually describing the same thing.
@niko @TwitchChen
Given the current architecture we're in an all or nothing situation when it comes to errors occurring during template execution. Any error in the template bubbles up to the top and consul-template exits.
I'm thinking of an option to change enable changing this behavior. When set it would change things so that template errors would get logged instead of exiting. This option could be per-template or global.
How does this sound?
A config switch to prevent exits on errors would be very much appreciated.
In situations where consul-template, for example, handles nginx configs, there will be edge cases that prevent an immediate nginx reload (eg, due to connection issues). With the current design, this will cause consul-template to crash, making the the problem even worse because nginx config will slowly get out of sync, especially if upstream servers keep changing (eg, in a microservices setup of any kind).
Having the ability to tell consul-template not to crash due to such issues, and to simply try again in a few minutes, would help address this.
Thanks for chiming in @crypt1d.
Please :+1: the original issue as we use that to gauge peoples interest in an issue and help to prioritize things. Thanks.
Most helpful comment
@niko @TwitchChen
Given the current architecture we're in an all or nothing situation when it comes to errors occurring during template execution. Any error in the template bubbles up to the top and consul-template exits.
I'm thinking of an option to change enable changing this behavior. When set it would change things so that template errors would get logged instead of exiting. This option could be per-template or global.
How does this sound?