Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cshuaimin
Copy link

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

  • The Pull Request has tests
  • A changelog file has been created under changelog/unreleased/kong or skip-changelog label added on PR if changelog is unnecessary. README.md
  • There is a user-facing docs PR against https://github.com/Kong/docs.konghq.com - PUT DOCS PR HERE

Issue reference

FTI-5936

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.
@github-actions github-actions bot added core/pdk cherry-pick kong-ee schedule this PR for cherry-picking to kong/kong-ee labels Jan 21, 2025
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.
@cshuaimin
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick kong-ee schedule this PR for cherry-picking to kong/kong-ee core/pdk size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant