Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[Kubernetes secret provider] Add cache for the secrets #3822
[Kubernetes secret provider] Add cache for the secrets #3822
Changes from 16 commits
dadc79b
ea3a100
a71101b
125330f
09ba2b6
4908655
a291bae
9f5b92c
9d94859
6d30148
d7c8756
b3ba219
8913d04
0fcd65a
57ad12c
8533ec4
c65ae20
87f0453
f02823e
97d6c84
0f8d86a
70c16ca
7f40d9c
62862a3
7642f09
ab76805
4f3ab48
044e7d1
8b7da6c
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
This is another issue that I am seeing. The lock is being held when making API calls to fetch the secret. What is the worry that this blocks for a long time holding the lock and then causing the rendering of the policy to be blocked?
Is it possible to be multiple key values in a single API call? It might be better to change this to first get all the keys that new values are needed. Then make a single API call to get all the values (if possible), and then update the cache with the values.
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.
It is not possible. The only way to get multiple secrets at once is to use the list function instead of get here. However, the options to filter the secrets we return are these, and as we can see, there are none to filter by the name. So in the end we would be retrieving all the secrets from a namespace when there is no need.
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.
Dang. Okay, I am still worried about it holding the lock the entire time it is refreshing all the secrets.
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.
Does
fetchSecrets
have a timeout? What if you never get a response? What if you do get a response, but it takes one hour?Now that
cacheTmp
is being rebuilt is holding the lock for eachfetchSecret
call still necessary? CancacheTmp
be built and then assigned top.secretsCache
with only that one line holding the lock?Since we are iterating over secretsCache that would likely require duplicating the keys first.
What places more load on the k8s API? Returning a single response that is unnecessarily large or multiple small requests made rapidly one after another?
We should bias towards making sure the k8s api-server remains stable over optimizing the request size if possible.
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.
I added a timeout just now, so we will never be waiting for 1h.
I changed the implementation to this way:
Is this ok this way @cmacknz ?