-
Notifications
You must be signed in to change notification settings - Fork 386
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
Add API function TryUpdatingCache
#630
Conversation
This seems redundant to invalidating the cache and then calling GetRegistries() (minus the error case). Is there a concrete use case for that? I prefer keeping the API small but if there's a non-hypothetical use case, I would not block. |
My use case is that I only want to override the cache on successful parsing of the configuration, not in every case. |
|
||
// GetRegistriesUncached loads the registries from the provided `SystemContext` | ||
// without using the internal cache. On success, the found registries will be | ||
// memoized into the internal registry cache. |
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.
nit; s/memoized/memorized/ or perhaps "added"
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.
https://en.wikipedia.org/wiki/Memoization ; though maybe that indicates that using simpler words would be easier to understand.
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.
Yes, that's what I meant, but I changed to to added
.
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.
LGTM, will let @vrothberg and @mtrmac decide if the function should be added or not.
Who would be the consumer of the API? |
The CRI-O live config reload feature. The thing is that I don't want to destroy the cache unless the config is valid. |
Thinking about it, I guess you're pointing to CRI-O's reload function where it could make sense. If @mtrmac is on board, I would prefer to add a parameter to |
... [to be broken], so we could add the parameter. |
Neither of the two APIs match how I imagine the callers work (nor how I see CRI-O working today). Most callers should never call For a daemon, I imagine there’s a SIGHUP or similar mechanism to reload configuration (or, perhaps, “reload before starting to process every request, but not every single time while processing it); in that case “reload” is what the caller wants, “reload and return the results” seems like pointless extra return value. Alternatively, I could imagine a “never cache, reload all the time if the file is valid” configuration — besides being a bit risky, that looks like an extra bit in What precisely is the caller doing and what does it want? |
This API would be for the configuration reload of
The caller mainly wants to recreate the registries cache, but only on successful parsing of |
That's pretty much how the API is intended to be used.
That is the key difference to the current API but the question remains why that is needed instead of using the current API? Could an empty cache lead to issues? In case of CRI-O, I can imagine that the SIGHUP reload aims at try-reload semantics, meaning that the data will only be updated if it's valid and without error to avoid race-conditions. |
Yes, I think so. Lets imagine the following scenario:
Yes, that's exactly the case. I really want to be sure that everything works before changing the internal application state. For the log_level it works the same way right now: |
So, maybe: On success, the code can optionally call [1] This is not something an external caller can quite trivially do, because adding an extra member to a structure does not break the API/ABI, but it can invalidate external code which tries to compare two |
A further thought — do we even want I can see an argument for actually strictly&reliably failing if the configuration is currently invalid, instead of continuing to use some hard-to-describe old configuration and hiding the problem. It’s not very strong, though. I suppose keeping |
1a0beca
to
1685261
Compare
Yeah, that's what the current implementaion already does, right? Or should I remove the
I agree and would not remove it. |
I'd go with a I also agree with keeping |
1685261
to
b4577af
Compare
Renamed the function according to your suggestion. |
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.
LGTM but needs a rebase
b4577af
to
caf8da6
Compare
Rebased on top of the latest master branch. |
@saschagrunert Are you still interested in this, can you rebase? |
caf8da6
to
af79703
Compare
Yes, rebased on top of the latest master branch |
GetRegistriesUncached
TryReloadConfiguration
@mtrmac @vrothberg PTAL |
TryReloadConfiguration
TryUpdatingCache
af79703
to
d901352
Compare
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.
LGTM
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 on the API (though note the V2RegistriesConf
comment); I’m afraid the implementation needs more updates for the interim code changes.
d901352
to
7d3f091
Compare
7d3f091
to
d2870db
Compare
The CI needs #670 to succeed. |
The function can be used to reload the registries without harming the cache if it fails. On success, the cache will be updated as intended. This function can be reused by the current `GetRegistries` API. Signed-off-by: Sascha Grunert <[email protected]>
d2870db
to
09d8ac0
Compare
Rebased. |
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.
LGTM, let's get this into the v3.0.0
release.
Green, pulling the trigger. Thanks @saschagrunert 👍 |
The function can be used to reload the registries without harming the
cache on failure. On success, the cache will be updated as intended.
This function can be reused by the current
GetRegistries
API.