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

Consistent template identifier #1381

Open
findkim opened this issue May 12, 2020 · 0 comments
Open

Consistent template identifier #1381

findkim opened this issue May 12, 2020 · 0 comments

Comments

@findkim
Copy link
Contributor

findkim commented May 12, 2020

Consul Template version

consul-template v0.25.0 (99efa64)

Configuration

Config: test.hcl

log_level = debug

template {
  contents = "{{ key \"hello\" }}"
  destination = "hello.txt"
  exec {
    command = "cat hello.txt"
  }
}

template {
  contents = "{{ key \"sleep\" }}"
  destination = "sleep.txt"
  exec {
    command = "sleep 2s"
    timeout = "4s"
  }
}

Consul KVs

consul kv put hello world
consul kv put sleep later

Command

consul-template -config test.hcl

Debug output

2020/05/12 19:49:57.881403 [DEBUG] (runner) checking template ff25035e863086f20cba2c81ff3f1ea6
...
2020/05/12 19:49:57.897472 [DEBUG] (runner) checking template 546af8255e26376df4176668d9e11c30
...
2020/05/12 19:50:57.282109 [DEBUG] (runner) initiating run
2020/05/12 19:50:57.282117 [DEBUG] (runner) checking template 803618397e94d78093493e0186c41428
...
2020/05/12 19:50:57.282485 [DEBUG] (runner) checking template 546af8255e26376df4176668d9e11c30

Steps to reproduce

  1. Update the first template content to "hello, {{ key \"hello\" }}"
  2. Send SIGHUP signal to reload config/template
  3. ID for the first template is different

Expected behavior

Consistent identifier for a template even upon changes to its content.

This is not a bug, and the template IDs changing are expected on reload since the identifier of templates are currently the md5 hash of the template content. This however makes it difficult to track log events for a template over time for all changes to the content.

Metrics have been recently added to Consul Template #1378 and is also using the template hash as its ID.

In addition to having a consistent identifier for a template, it would be ideal for the identifier to be easily mapped to a template. It is not immediately clear in the above example which hash corresponds to which template.

References

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

No branches or pull requests

1 participant