Closed njegosrailic closed 2 years ago
This may have been fixed by https://github.com/hashicorp/vault/pull/15204, available in Vault 1.11.0.
Thank you. I'll test it and let you know.
Hi @jasonodonnell,
Unless I'm missing something the issue still persist:
/ $ vault version
Vault v1.11.1 (0f634755745f4adf62ec0723a0b93d6dce5bc33e), built 2022-07-19T20:16:47Z
/ $ cat /vault/config.json | grep -A 6 vault\":
"vault": {
"address": "https://vault.service.intra:8200",
"retry": [
{
"num_retries": "3"
}
]
/ $ cat /vault/config.json | grep -A 5 template_config
"template_config": [
{
"error_on_missing_key": false,
"exit_on_retry_failure": false
}
],
/ $
Logs:
2022-08-02T08:11:43.370Z [WARN] (view) vault.read(secrets/dev/test-secret2): no secret exists at secrets/dev/test-secret2 (retry attempt 5 after "4s")
2022-08-02T08:11:47.371Z [INFO] cache: received request: method=GET path=/v1/secrets/dev/test-secret2
2022-08-02T08:11:47.371Z [INFO] cache: received request: method=GET path=/v1/secrets/dev/test-secret
2022-08-02T08:11:47.371Z [INFO] cache.apiproxy: forwarding request: method=GET path=/v1/secrets/dev/test-secret2
2022-08-02T08:11:47.371Z [INFO] cache.apiproxy: forwarding request: method=GET path=/v1/secrets/dev/test-secret
2022-08-02T08:11:47.376Z [WARN] (view) vault.read(secrets/dev/test-secret2): no secret exists at secrets/dev/test-secret2 (retry attempt 6 after "8s")
2022-08-02T08:11:47.376Z [WARN] (view) vault.read(secrets/dev/test-secret): no secret exists at secrets/dev/test-secret (retry attempt 6 after "8s")
2022-08-02T08:11:55.377Z [INFO] cache: received request: method=GET path=/v1/secrets/dev/test-secret2
2022-08-02T08:11:55.377Z [INFO] cache: received request: method=GET path=/v1/secrets/dev/test-secret
2022-08-02T08:11:55.377Z [INFO] cache.apiproxy: forwarding request: method=GET path=/v1/secrets/dev/test-secret2
2022-08-02T08:11:55.377Z [INFO] cache.apiproxy: forwarding request: method=GET path=/v1/secrets/dev/test-secret
2022-08-02T08:11:55.383Z [WARN] (view) vault.read(secrets/dev/test-secret2): no secret exists at secrets/dev/test-secret2 (retry attempt 7 after "16s")
2022-08-02T08:11:55.383Z [WARN] (view) vault.read(secrets/dev/test-secret): no secret exists at secrets/dev/test-secret (retry attempt 7 after "16s")
2022-08-02T08:12:11.384Z [INFO] cache: received request: method=GET path=/v1/secrets/dev/test-secret
2022-08-02T08:12:11.384Z [INFO] cache: received request: method=GET path=/v1/secrets/dev/test-secret2
2022-08-02T08:12:11.384Z [INFO] cache.apiproxy: forwarding request: method=GET path=/v1/secrets/dev/test-secret
2022-08-02T08:12:11.384Z [INFO] cache.apiproxy: forwarding request: method=GET path=/v1/secrets/dev/test-secret2
2022-08-02T08:12:11.390Z [WARN] (view) vault.read(secrets/dev/test-secret): no secret exists at secrets/dev/test-secret (retry attempt 8 after "32s")
2022-08-02T08:12:11.390Z [WARN] (view) vault.read(secrets/dev/test-secret2): no secret exists at secrets/dev/test-secret2 (retry attempt 8 after "32s")
2022-08-02T08:12:43.391Z [INFO] cache: received request: method=GET path=/v1/secrets/dev/test-secret2
2022-08-02T08:12:43.391Z [INFO] cache: received request: method=GET path=/v1/secrets/dev/test-secret
2022-08-02T08:12:43.391Z [INFO] cache.apiproxy: forwarding request: method=GET path=/v1/secrets/dev/test-secret2
2022-08-02T08:12:43.391Z [INFO] cache.apiproxy: forwarding request: method=GET path=/v1/secrets/dev/test-secret
2022-08-02T08:12:43.396Z [WARN] (view) vault.read(secrets/dev/test-secret2): no secret exists at secrets/dev/test-secret2 (retry attempt 9 after "1m0s")
2022-08-02T08:12:43.396Z [WARN] (view) vault.read(secrets/dev/test-secret): no secret exists at secrets/dev/test-secret (retry attempt 9 after "1m0s")
2022-08-02T08:13:43.397Z [INFO] cache: received request: method=GET path=/v1/secrets/dev/test-secret
2022-08-02T08:13:43.397Z [INFO] cache: received request: method=GET path=/v1/secrets/dev/test-secret2
2022-08-02T08:13:43.397Z [INFO] cache.apiproxy: forwarding request: method=GET path=/v1/secrets/dev/test-secret2
2022-08-02T08:13:43.397Z [INFO] cache.apiproxy: forwarding request: method=GET path=/v1/secrets/dev/test-secret
2022-08-02T08:13:43.405Z [WARN] (view) vault.read(secrets/dev/test-secret2): no secret exists at secrets/dev/test-secret2 (retry attempt 10 after "1m0s")
2022-08-02T08:13:43.405Z [WARN] (view) vault.read(secrets/dev/test-secret): no secret exists at secrets/dev/test-secret (retry attempt 10 after "1m0s")
I will take a closer look, but unfortunately the retry logic is complicated due to the interaction of sub systems in agent as per the documentation: https://www.vaultproject.io/docs/agent#retry-stanza
I did find this note in the code for template: https://github.com/hashicorp/vault/blob/637d4bdc43204cd970a6a549483991183ceff5da/command/agent/template/template.go#L267.
Hi there! I'm pretty sure my PR https://github.com/hashicorp/vault/pull/16970 will fix this issue.
To describe the current behaviour: the issue was that when caching was enabled, configured retries were not respected. If template_config
was present (like here), it would ignore the set max_retries
value and set retries to the default, otherwise. If template_config
is not present, it would ignore the set max_retries
value and set retries to 0 (essentially creating an infinite loop of instant retries).
This issue should be resolved soon and fixed in 1.12.0. Thanks for the report!
Hi there! I'm going to close this issue as I just merged https://github.com/hashicorp/vault/pull/16970 which should fix the issue identified here. It should now respect the number of retries in all cases, regardless of if caching is enabled. This should release in 1.12.
Thanks for the bug report!
Describe the bug
Looks like the Vault agent doesn’t respect the number of retries.
I also tried setting the
VAULT_MAX_RETRIES
ENV variable.To Reproduce Steps to reproduce the behavior:
Please see the configuration in the environment section below.
Expected behavior
According to the docs, I expect that the Vault agent won’t exit on an error and that the number of retries will be three. This is what I’m getting:
I tried to set the VAULT_MAX_RETRIES ENV variable but no luck.
There is an option to pass the Consul template retry config but the problem is that I don’t understand how to pass it from the Vault config.
This is the Consul template config for the Vault config shown below:
I can tell that the config is being parsed properly, because if I pass two values in the retry stanza I got an error that only one is allowed.
Environment:
vault status
):1.10.1
vault version
):1.10.3
Vault agent configuration file(s):
Additional context Add any other context about the problem here.