Closed ChipV223 closed 4 years ago
@ChipV223 I think you might have a token set in a less obvious place as I can't reproduce this if I don't have the token set anywhere.
It can be set in any of the following...
token
in config fileVAULT_TOKEN
environment variable~/.vault-token
file (default for the vault_agent_token_file config setting)If there is no token in any of these places, you shouldn't see those token-refreshing errors.
@eikenb : The config I posted earlier shows no token in the config, I don't have VAULT_TOKEN
set in my env nor do I was able to find ~/.vault-token
in my Windows env
I'll try running C.T. on a different env to see if I'm able to replicate this
I looked over the code again and it comes down to this line...
That line has 2 parts that both must be true for it to try to renew the token. Starting with the second, the config setting config.Bool(c.Vault.RenewToken)
defaults to true
. So it is likely true in your tests.
The first check clients.Vault().Token() != ""
is the problem. To run through it... clients.Vault()
returns the vault API client. Running Token()
on it just returns its internal client.token
value. That only gets set if you set it with client.SetToken()
or if the environment variable VAULT_TOKEN
is set. Consul-template only calls SetToken if the configuration system finds a token which must come from one of those 3 places I mentioned.
Hey @ChipV223. If you have anything else that might let me reproduce this, please let me know. Otherwise I'd like to close this ticket.
the config setting config.Bool(c.Vault.RenewToken) defaults to true.
This just bit me. It shouldn't default to true if Vault isn't used. I'm re-opening this ticket and changing it to changing the default to false when no vault tokens are in use.
@ChipV223 Note that your original ticket did say this when reading it in hindsight. I just had a certain interpretation in my head based on my knowledge of things at the time and got stuck there. The problem is with the default setting when vault is not in use (as I mentioned)... which should be fixable.
Consul Template version
v0.22.0
Configuration
Command
Debug output
Expected behavior
What should have happened?
If Consul Template doesn't detect any Vault parameters in the template config file, the Vault token renew check should be happen once. After it is found that there is no Vault token, the check stops and Consul Template should continue to run
Actual behavior
What actually happened?
Consul Template will continuously try to find a Vault token, resulting in unnecessary logging as well as the process shutting down after the maximum Vault token renew tries have been exceeded