Vault agent max TTL exceeded warning

Hi,

We are using dynamic secrets for database credentials, which the vault agent should and seems to fully manage correctly.
However, the vault agent logs the following warning every once in a while:

2022-03-17T06:52:00.645Z [WARN] vault.read(database/creds/profileservice): TTL of "24h" exceeded the effective max_ttl of "3h49m49s"; TTL value is capped accordingly
2022-03-17T06:52:00.645Z [WARN] vault.read(database/creds/profileservice): renewer done (maybe the lease expired)
2022-03-17T06:52:10.802Z [INFO] (runner) rendered "(dynamic)" => "/vault/secrets/mysql.conf"

As far as I understand, the vault agent should renew its lease on the database secret every once in a while (based on default TTL), but at some point the default TTL of 24h would exceed the max TTL of the issued credentials and then this warning occurs. The vault agent seems to handle this fine and request a new set of credentials. However, since this is a warning I was wondering if this is something I can fix, and how to fix it. I can’t seem to find anything about this warning in the docs.

Thanks in advance!

Are the TTLs set correctly on the role itself within Vault?

Sounds like default_ttl might be set to 24h and max_ttl set to 4h.

Otherwise the global max_lease_ttl might be conflicting.

The default and max TTL seem to be fine.
From the database secret role in the vault UI:

image

We also do not set the global setting, so that should default to 768h I believe?
However, if I navigate to the configuration of the database secret engine I do see the following TTL:

I’m not sure if that’s correct.

My understanding is that if the Default/Max lease TTL is set to 0 it’ll use the next higher level’s TTL. So if a role doesn’t have TTLs defined it’ll use the secret engine config configured TTLs. If the secret engine config doesn’t have TTLs specified it’ll use the global.

With that said, secret leases are also, generally, dependent on your auth token’s TTL - when your auth TTL expires your secret lease will be revoked. What are your auth role TTL settings?

The configuration of the Kubernetes auth method which we use has both Default Lease TTL and Max Lease TTL set to 0.

Under a specific role within that auth method, the Generated Token’s Explicit Maximum TTL, Maximum Uses of Generated Tokens, Generated Token’s Period and Generated Token’s Initial TTL are all set to 0. Only the Generated Token’s Maximum TTL is set to 1800000.

Interesting. I’m not sure then, unless there is something in the agent config or its own code. Perhaps someone most familiar with the agent could offer some insight.

We are seeing the same thing, in our case, it is the “GCP” Secrets engine. We have seen problems where the application team says the token is expired, so we created an “excessively” low TTL/Max to test…

[tmcneely@local ~]$ vault read cwow/test-denodo-ttl/np/gcp/config
Key        Value
---        -----
max_ttl    1h
ttl        15m

We are seeing that the Vault agent just seems to blindly refresh the lease, it doesn’t seem to pay much heed to “max_ttl”. This happens every hour (max_ttl), where it is like “OMG, the lease is gone!? Get a new one!?” This is not the expected behavior. It should be renewing the lease at like 80-90% of its life, and when it reaches max_ttl, it should get a new lease, right?

Apr 07 06:16:10 sea1l5ddvsa29.example.com vault[21958]: 2022-04-07T06:16:10.817-0700 [INFO]  cache: received request: method=PUT path=/v1/sys/leases/renew
Apr 07 06:16:10 sea1l5ddvsa29.example.com vault[21958]: 2022-04-07T06:16:10.817-0700 [INFO]  cache.apiproxy: forwarding request: method=PUT path=/v1/sys/leases/renew
Apr 07 06:16:10 sea1l5ddvsa29.example.com vault[21958]: 2022-04-07T06:16:10.972-0700 [WARN] vault.read(cwow/test-denodo-ttl/np/gcp/key/denodo-spanner-sa-test-denodo-ttl-6208): failed to renew: Error making API request.
Apr 07 06:16:10 sea1l5ddvsa29.example.com vault[21958]: URL: PUT http://127.0.0.1:8200/v1/sys/leases/renew
Apr 07 06:16:10 sea1l5ddvsa29.example.com vault[21958]: Code: 400. Errors:
Apr 07 06:16:10 sea1l5ddvsa29.example.com vault[21958]: * lease not found
Apr 07 06:16:10 sea1l5ddvsa29.example.com vault[21958]: 2022-04-07T06:16:10.972-0700 [WARN] vault.read(cwow/test-denodo-ttl/np/gcp/key/denodo-spanner-sa-test-denodo-ttl-6208): renewer done (maybe the lease expired)
Apr 07 06:16:10 sea1l5ddvsa29.example.com vault[21958]: 2022-04-07T06:16:10.972-0700 [INFO]  cache: received request: method=GET path=/v1/cwow/test-denodo-ttl/np/gcp/key/denodo-spanner-sa-test-denodo-ttl-6208
Apr 07 06:16:10 sea1l5ddvsa29.example.com vault[21958]: 2022-04-07T06:16:10.972-0700 [INFO]  cache.apiproxy: forwarding request: method=GET path=/v1/cwow/test-denodo-ttl/np/gcp/key/denodo-spanner-sa-test-denodo-ttl-6208
Apr 07 06:16:11 sea1l5ddvsa29.example.com vault[21958]: 2022-04-07T06:16:11.446-0700 [INFO]  cache: received request: method=PUT path=/v1/sys/leases/renew
Apr 07 06:16:11 sea1l5ddvsa29.example.com vault[21958]: 2022-04-07T06:16:11.446-0700 [INFO]  cache.apiproxy: forwarding request: method=PUT path=/v1/sys/leases/renew
Apr 07 06:16:11 sea1l5ddvsa29.example.com vault[21958]: 2022-04-07T06:16:11.447-0700 [INFO] (runner) rendered "/var/lib/vault/template.ctmpl" => "/var/lib/vault/vault_agent.json"
Apr 07 06:16:11 sea1l5ddvsa29.example.com vault[21958]: 2022-04-07T06:16:11.447-0700 [INFO] (runner) executing command "/var/lib/vault/write_secret.sh" from "/var/lib/vault/template.ctmpl" => "/var/lib/vault/vault_agent.json"
Apr 07 06:16:11 sea1l5ddvsa29.example.com vault[21958]: 2022-04-07T06:16:11.447-0700 [INFO] (child) spawning: /var/lib/vault/write_secret.sh
Apr 07 06:16:11 sea1l5ddvsa29.example.com vault[21958]: 2022-04-07T06:16:11.482-0700 [INFO]  cache: received request: method=GET path=/v1/sys/internal/ui/mounts/cwow/np/secret/denodo/denodo-spanner-sa-test-denodo-ttl-6208-b
Apr 07 06:16:11 sea1l5ddvsa29.example.com vault[21958]: 2022-04-07T06:16:11.482-0700 [INFO]  cache.apiproxy: forwarding request: method=GET path=/v1/sys/internal/ui/mounts/cwow/np/secret/denodo/denodo-spanner-sa-test-denodo-ttl-6208-b
Apr 07 06:16:11 sea1l5ddvsa29.example.com vault[21958]: 2022-04-07T06:16:11.611-0700 [INFO]  cache: received request: method=PUT path=/v1/cwow/np/secret/data/denodo/denodo-spanner-sa-test-denodo-ttl-6208-b
Apr 07 06:16:11 sea1l5ddvsa29.example.com vault[21958]: 2022-04-07T06:16:11.611-0700 [INFO]  cache.apiproxy: forwarding request: method=PUT path=/v1/cwow/np/secret/data/denodo/denodo-spanner-sa-test-denodo-ttl-6208-b
Apr 07 06:26:50 sea1l5ddvsa29.example.com vault[21958]: 2022-04-07T06:26:50.427-0700 [INFO]  cache: received request: method=PUT path=/v1/sys/leases/renew
Apr 07 06:37:29 sea1l5ddvsa29.example.com vault[21958]: 2022-04-07T06:37:29.095-0700 [INFO]  cache: received request: method=PUT path=/v1/sys/leases/renew
Apr 07 06:48:07 sea1l5ddvsa29.example.com vault[21958]: 2022-04-07T06:48:07.762-0700 [INFO]  cache: received request: method=PUT path=/v1/sys/leases/renew
Apr 07 06:58:46 sea1l5ddvsa29.example.com vault[21958]: 2022-04-07T06:58:46.427-0700 [INFO]  cache: received request: method=PUT path=/v1/sys/leases/renew
Apr 07 07:09:25 sea1l5ddvsa29.example.com vault[21958]: 2022-04-07T07:09:25.093-0700 [INFO]  cache: received request: method=PUT path=/v1/sys/leases/renew
Apr 07 07:20:03 sea1l5ddvsa29.example.com vault[21958]: 2022-04-07T07:20:03.761-0700 [INFO]  cache: received request: method=PUT path=/v1/sys/leases/renew
Apr 07 07:20:03 sea1l5ddvsa29.example.com vault[21958]: 2022-04-07T07:20:03.761-0700 [INFO]  cache.apiproxy: forwarding request: method=PUT path=/v1/sys/leases/renew
Apr 07 07:20:03 sea1l5ddvsa29.example.com vault[21958]: 2022-04-07T07:20:03.908-0700 [WARN] vault.read(cwow/test-denodo-ttl/np/gcp/key/denodo-spanner-sa-test-denodo-ttl-6208): failed to renew: Error making API request.
Apr 07 07:20:03 sea1l5ddvsa29.example.com vault[21958]: URL: PUT http://127.0.0.1:8200/v1/sys/leases/renew
Apr 07 07:20:03 sea1l5ddvsa29.example.com vault[21958]: Code: 400. Errors:
Apr 07 07:20:03 sea1l5ddvsa29.example.com vault[21958]: * lease not found
Apr 07 07:20:03 sea1l5ddvsa29.example.com vault[21958]: 2022-04-07T07:20:03.908-0700 [WARN] vault.read(cwow/test-denodo-ttl/np/gcp/key/denodo-spanner-sa-test-denodo-ttl-6208): renewer done (maybe the lease expired)
Apr 07 07:20:03 sea1l5ddvsa29.example.com vault[21958]: 2022-04-07T07:20:03.908-0700 [INFO]  cache: received request: method=GET path=/v1/cwow/test-denodo-ttl/np/gcp/key/denodo-spanner-sa-test-denodo-ttl-6208

Interesting… while looking at this, it mostly follows the pattern above, but every once in a while it does this:

… YIKES!

  • It does seem to be “aware” that there is a max_ttl
  • It beats the heck out of the vault server (retry over and over and over) instead of having a retry loop (this is a common vault agent issue)
  • It appears to have gotten a new lease before it expired (which is desirable) … but only this one time