Skip to content
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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

everettraven
Copy link
Contributor

Description

  • Adds a new internal package internal/contentmanager that has an implementation of a dynamic caching layer for managing watches on content managed by a ClusterExtension

Fixes #974

Reviewer Checklist

  • API Go Documentation
  • Tests: Unit Tests (and E2E Tests, if appropriate)
  • Comprehensive Commit Messages
  • Links to related GitHub Issue(s)

everettraven and others added 4 commits June 28, 2024 13:11
Signed-off-by: everettraven <everettraven@gmail.com>
Signed-off-by: Edmund Ochieng <ochienged@gmail.com>
Signed-off-by: Edmund Ochieng <ochienged@gmail.com>
feat: implement the setting up of the scheme with managed contents
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 1, 2024
Copy link

netlify bot commented Jul 1, 2024

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit 90e32b2
🔍 Latest deploy log https://app.netlify.com/sites/olmv1/deploys/668305bbdde0020008442fc1
😎 Deploy Preview https://deploy-preview-1001--olmv1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Comment on lines +63 to +65
// 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
Copy link
Contributor Author

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()
Copy link
Contributor Author

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,
Copy link
Contributor Author

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.

Comment on lines +122 to +131
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,
}
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement a dynamic caching layer that establishes watches utilizing a ServiceAccount
2 participants