rundeck-plugins / vault-storage

Storage plugin for Rundeck for storing data in Vault
http://rundeck.org/plugins/vault/2017/11/25/vault-storage.html
MIT License
18 stars 11 forks source link

Fix forbidden errors when token is about to expire #38

Closed anrock-sc closed 2 years ago

anrock-sc commented 2 years ago

This fixes the edge case when the communication to vault is very slow and the passed token is about to expire, it can happen that the call to lookup self returns success but the following vault calls still run into an error as the token just expired.

This problem becomes more severe as vault communication sometimes can be quite slow.

This change will fix this edge by calculating the maximal time, a call to vault will take. That is:

(Read Timeout + Open Timeout + Retry Intervall in Milliseconds / 1000) * Max Retried

This is capped to 60 seconds as the documentation for the read and open timeout parameters were wrong. As the previous documentation stated that the timeout parameter are ms valued, they are actually seconds. See: openTimout and readTimeout

This could cause users to have high values in these parameters. To prevent continues token refreshing in that case, the maximal guaranteed token validity is capped to 60 seconds.

I couldn't test my PR with the docker images due to: https://github.com/rundeck-plugins/vault-storage/issues/37