-
Notifications
You must be signed in to change notification settings - Fork 47
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
✨ WIP: Create a Go pkg with a managed content caching layer #1001
base: main
Are you sure you want to change the base?
✨ WIP: Create a Go pkg with a managed content caching layer #1001
Conversation
Signed-off-by: everettraven <everettraven@gmail.com>
Signed-off-by: Edmund Ochieng <ochienged@gmail.com>
feat: implement the setting up of the scheme with managed contents
✅ Deploy Preview for olmv1 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
// TODO: add a http.RoundTripper to the config to ensure it is always using an up | ||
// to date authentication token for the ServiceAccount token provided in the ClusterExtension. | ||
// Maybe this should be handled by the RestConfigMapper |
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.
We are thinking this should indeed be done as part of the RestConfigMapper implementation so that everything utilizing it can take advantage of automated token rotation
|
||
// Assumptions: all objects received by the function will have the Object metadata specfically, | ||
// ApiVersion and Kind set. Failure to which the code will panic when adding the types to the scheme | ||
scheme := runtime.NewScheme() |
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.
When I was playing around with integrating this logic into the controller, I ran into an issue that it couldn't properly configure a handler for the ClusterExtension resource as an owner because the API didn't exist in the scheme. I had to add the following code:
err = v1alpha1.AddToScheme(scheme)
if err != nil {
return fmt.Errorf("adding ClusterExtension APIs to scheme: %w", err)
}
i.mapper, | ||
ce, | ||
), | ||
nil, |
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 nil
being passed in here results in a nil pointer dereference. I don't recall why it was put there but it isn't needed and should be removed.
if data, ok := i.extensionCaches[ce.GetName()]; ok { | ||
data.Cancel() | ||
} | ||
|
||
ctx, cancel := context.WithCancel(ctx) | ||
go c.Start(ctx) | ||
i.extensionCaches[ce.Name] = extensionCacheData{ | ||
Cache: c, | ||
Cancel: cancel, | ||
} |
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.
As an initial pass, we are thinking to just blow away and recreate a new cache every time this is called. This is definitely not ideal but gives us a starting point for integration and making sure the core logic functions appropriately. We will create a follow up issue to track optimizing the implementation such that the same cache is used to add and remove informers as necessary based on changes to the set of resources managed.
Description
internal/contentmanager
that has an implementation of a dynamic caching layer for managing watches on content managed by aClusterExtension
Fixes #974
Reviewer Checklist