-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(vault): secret is temporarily empty after changed vault config #14209
base: master
Are you sure you want to change the base?
Conversation
When vault config is changed, in the worker event we first flush the LRU cache, then start to update the secrets from vault provider. There’s a period of time in between that the cache is empty. The `kong.vault.update()` function only lookups cache and will update the secret to an empty string when cache is empty. This can cause plugins to throw nil errors. This commit changed `kong.vault.update()` function to not touch it if not found in the cache.
When vault config is changed, in the worker event we first flush the LRU cache, then start to update the secrets from vault provider. There’s a period of time in between that the cache is empty. The `kong.vault.update()` function only lookups cache and will update the secret to an empty string when cache is empty. This can cause plugins to throw nil errors. This commit changed the worker event callback to not flush the LRU cache. The cache will be updated when the secrets are fetched from vault prodiver.
Pushed a new commit to fix the issue in another way: instead of not touching input table in the pdk update function, in this new commit I completely removed the LRU:flush_all() line in the worker event. The LRU capacity is fixed and the keys has ttls, so there likely won’t be memory leaks. |
What about the configuration stickyness issue (just double checking that stickyness is not back with this change)? |
@@ -1429,8 +1429,6 @@ local function new(self) | |||
end | |||
end | |||
|
|||
LRU:flush_all() | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The LuaDoc
has:
---
-- Flushes LRU caches and forcibly rotates the secrets.
--
-- This is only ever executed on traditional nodes.
I guess this may need to be changed. Also should it be executed with incremental too?
Summary
When vault config is changed, in the worker event we first flush the LRU cache, then start to update the secrets from vault provider. There’s a period of time in between that the cache is empty.
The
kong.vault.update()
function only lookups cache and will update the secret to an empty string when cache is empty. This can cause plugins to throw nil errors.This commit changed
kong.vault.update()
function to not touch it if not found in the cache.Checklist
changelog/unreleased/kong
orskip-changelog
label added on PR if changelog is unnecessary. README.mdIssue reference
FTI-5936