-
Notifications
You must be signed in to change notification settings - Fork 9
Add periodic config/secrets reload #31
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
Merged
douglascamata
merged 5 commits into
rhobs:main
from
douglascamata:reload-secrets-and-config
Jan 8, 2024
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9593ecb
Add periodic config/secrets reload
douglascamata 5984f3a
Remove config reload mutex
douglascamata 4ac7900
Fix formatting
douglascamata a597284
Use non-zero config reload interval in test
douglascamata 4965a85
Readd tenants with changed OIDC params on config reload
douglascamata File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
Hmm, so generally this is good. But
InitOrReloadObsctlConfig(), attempts to read and load obsctl from the disk first, so it won't actually reload the secrets here I think.The reason we save it on disk and load if needed is so that we don't end up regularly calling SSO for new tokens, but that we can use the present one till full expiry (usually ~15m).
But to unblock, maybe we can add a bool param to the method to skip reading from disk step and call it with true here? :)
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.
Good catch!
IMHO, in all the cases where
InitOrReloadObsctlConfigis called, we want it to get new tenant credentials from the k8s API (even before talking to SSO to try to get a token), because they could have changed. Otherwise we are not truly reloading any configuration as everything that will be reloaded was already there and nothing "new" is detected or used unless someone's modifying theobsctlfiles in the filesystem.I added some small logic that will remove and re-add tenant in
obsctlonly if their OIDC credentials have changed (client id, secret, audience, issuer url, or offline access attributes).Now,
obsctl-reloadercreate clients a client for every single tenant discovered from secrets to confirm they are good (in theif !o.skipClientCheckblock). This means SSO is called for all of them anyway. The client creation only skips calling SSO if there's a non-expired token in it, which is never the case because we never update the secret with the access tokens.Considering that if the tenant test client creation fails we skip the error and keep loading other clients, I think we can remove that check from inside the configuration loading and let it happen when we call the Observatorium API. This way we can take advantage of the access token that is cached by
obsctl-reloaderfor existing tenants and should only fetch new tokens from SSO for the tenants that got reloaded. WDYT, @saswatamcode?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.
Ack, that makes sense! Let's test this out somehow (would need to update somebody's secret to a wrong thing and then a right thing). :)