-
Notifications
You must be signed in to change notification settings - Fork 38
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
Implement default cache with a minimal set of package-level functions. #192
Conversation
22ada99
to
c7d4144
Compare
c7d4144
to
8b0f137
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.
Question about the default-cache package-level api: should it expose all methods of Cache
as package level functions? If not, should it match the current registry API, then?
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.
Thanks @klihub.
I have left some comments. I think we can already remove some of the "extra" registry functions from the Registry
interface -- or at least mark these as deprecated.
On your testing question: What are we trying to test by also testing the default functions? Should the tests for the default cache be a separate set of test cases anyway?
Based on our last community meeting chat my understanding was that the preference would be to only expose a minimal set of functions at this point, and this set would be limited to cache refreshing, device injection and error introspection/query. And the reasoning was that this would allow us to replace the current usage of the registry in cri-o and containerd with the package-level functions, which would be the next step we'd like to take. |
Yes, that's what I'm also pondering now. If the cache implementation works then as longer as the getter works correctly and the straightforward package-level oneliner functions are not broken, then the default cache should work as well. However, I'm a pessimist-realist so I think we should get these exercised anyway, if for nothing else then for coverage %.
Yes, I think that ideally there should at least be separate top-level test cases (Test$CASE t* testing.T) for the default cache functions. But it should be fine for those to be totally minimalistic wrt. the corresponding functions testing the cache (even as simple as simply checking only for successful injection without verifying the correctness of the result which we already do separately for the Cache tests). |
383cd76
to
2985980
Compare
2985980
to
370e48b
Compare
I created dedicated tests for the default cache. |
370e48b
to
858150c
Compare
The default cache is always available and implicitly created the first time it is referenced. It is created with the default cache options but can then be reconfigured explicitly if necessary. Aso add package level variants of the most commonly used cache functions, Refresh(), InjectDevices, and GetErrors(). These all use the default cache. Signed-off-by: Krisztian Litkey <[email protected]>
Signed-off-by: Krisztian Litkey <[email protected]>
Make the registry use the default cache. Add a documentation note about future plans to obsolete and eventually remove the registry interface. Don't mark the registry obsoleted yet. Signed-off-by: Krisztian Litkey <[email protected]>
Signed-off-by: Krisztian Litkey <[email protected]>
Signed-off-by: Krisztian Litkey <[email protected]>
858150c
to
07fed87
Compare
@elezar I updated the PR according to your suggestion/our earlier discussion. Another change I made is to remove the returned error from the package-level |
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.
Thanks @klihub. I think this looks good now.
As discussed, let's mark the Registry
interfaces and the GetRegistry
function as deprecated as a follow-up.
Users should use the top-level functions in most cases, and call Configure()
or GetRegistry
depending on whether they want to initialize or configure the cache.
This patch set
Configure()
,Refresh()
,InjectDevices()
,GetErrors()
) which use the default cacheGetDefaultCache()
getter to allow other cache functions to be explicitly called on the default cachecdi
test utility to use the default cache