Open adamrmcclain opened 5 years ago
Hey @adamrmcclain, thanks for reporting this issue.
I'll try to look into this but a simplified, minimal setup to reproduce this would be very helpful. Particularly reducing that template to use as few as possible consul keys with example values provided. Thanks.
I'm seeing the same behavior with consul-template v0.20.0 (b709612c)
Can't think of a way to make this reproducible for troubleshooting efforts though.
In my case, I've got a file (rendered from a template) that is not updating even though the data in Consul would suggest it should be.
A consul-template -template <ctmpl_path>:<file_path> -once -dry
produces the correct output.
while consul-template -template <ctmpl_path>:<file_path> -once
does not seem to update the file with the correct output.
Additionally, if I pipe the output of the -dry
command into the file then start the consul-template service, it immediately re-writes the file with the incorrect/stale data.
This template is rather simple and just puts each datanode's IP address into a file, one per line:
{{ range service "datanode" }}{{ .Address }}
{{ end }}
The number of lines in the file on disk does not match the number of lines found when querying Consul or when doing a -dry
run:
$ wc -l /file/on/disk
4023 /file/on/disk
$ consul-template -template /path/to/template.ctmpl:/file/on/disk -once -dry | wc -l
6369
$ curl -s -G http://127.0.0.1:8500/v1/health/checks/datanode --data-urlencode 'filter=Status==passing' | jq ". | length"
6369
It looks like this issue might be related to stale cache/dedupe. I managed to get this working by doing the following:
Workaround:
consul kv delete -recurse consul-template
to delete the consul-template dedupe cachededuplicate
feature in the local consul-template configdeduplicate
in config and restart consul-templateThis problem happened when we scaled up a consul cluster to 6000 instances. So unfortunately, we can't help with a reasonable way to reproduce this issue.
Thanks for the additional context, particularly for finding a possible culprit @robbyt.
That sounds like it would be a problem with refreshing the dedup'd cache. Though I'm not sure how that plays with how -dry prevented the issue as -dry and dedup don't seem to cross logic paths in the code anywhere. I'll keep an eye out though.
Please note that the Consul Template issue tracker is reserved for bug reports and enhancements. For general usage questions, please use the Consul mailing list:
Consul Template version
consul-template v0.19.5 (57b6c71)
Configuration
(I have removed the commented out lines here for readability)
(I'm only pasting the template that we are having issues with, which is canary_demo.tmpl)
Command
Debug output
I think this is the important information
What's weird is that the KV values it says "is still needed" exist in the Consul Server KV. For example:
Expected behavior
The output from the dry command should match the output to the rendered file
Actual behavior
Dry output:
File output:
Steps to reproduce
consul-template -template "/webApps/nginx/conf/env/$PLATFORM_ENVIRONMENT/canary/canary_demo.tmpl:/webApps/nginx/conf/env/$PLATFORM_ENVIRONMENT/canary/canary_demo.rendered" -once -dry
consul-template -template "/webApps/nginx/conf/env/$PLATFORM_ENVIRONMENT/canary/canary_demo.tmpl:/webApps/nginx/conf/env/$PLATFORM_ENVIRONMENT/canary/canary_demo.rendered" -once
References
Are there any other GitHub issues (open or closed) that should be linked here? For example:
N\A