Open nvanthao opened 1 year ago
Hi @nvanthao and thanks for raising this feature request and I think it makes sense and would be a useful addition.
Thanks @jrasell,
I have submitted a PR adding the new flag at task
block level.
Please let me know how it goes.
Proposal
Add new parameter
render_on_task_restart
fortemplate
block. When this boolean flag is set totrue
, the template will be re-rendered when a task is restarted.The flag can be added to the check here.
https://github.com/hashicorp/nomad/blob/b30f76e7d72114f9d06a4ee2c34c7242a1f5572c/client/allocrunner/taskrunner/template_hook.go#L98-L101
Use-cases
For template retrieving secrets from Vault, due to lack of blocking query in Vault, the template will only re-render when getting closer to the lease duration. This is not ideal when Vault secret is no longer relevant, e.g. lease get revoked.
Having this parameter will enable template to be re-rendered explicitly when the task is restarted.
Attempted Solutions
The current workaround is to modify jobspec with some unique meta so that new alloc will be created, which means template will be re-rendered.
I can help with the PR if the feature request is accepted.