-
Notifications
You must be signed in to change notification settings - Fork 68
✨ refactor ClusterExtensionReconciler.reconcile() #1068
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
✨ refactor ClusterExtensionReconciler.reconcile() #1068
Conversation
✅ Deploy Preview for olmv1 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
|
Nice! I like this idea. I'll take a closer look at this tomorrow, but one thing I would suggest off the bat is talking to @thetechnick about the |
|
I do have a very rough first PoC here: |
|
@joelanford Sounds good. Are you thinking to utilize the I'd be a bit hesitant to move back to an approach where we are creating an underlying resource like the |
9afedde to
9fe7cf0
Compare
| Preflights []Preflight | ||
| } | ||
|
|
||
| func (h *Helm) Apply(ctx context.Context, contentFS fs.FS, ext *ocv1alpha1.ClusterExtension, labels map[string]string) ([]client.Object, string, error) { |
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.
Ideally we make this function more easily unit testable and add explicit unit tests for this function and the individual components but I would put that out of scope of the intention of this PR.
| installedBundleVersion, err := mmsemver.NewVersion(installedBundle.Version) | ||
| if err != nil { | ||
| return nil, err | ||
| return nil, fmt.Errorf("parsing installed bundle version %q: %w | installedBundle %v", installedBundle.Version, err, installedBundle) |
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.
| return nil, fmt.Errorf("parsing installed bundle version %q: %w | installedBundle %v", installedBundle.Version, err, installedBundle) | |
| return nil, fmt.Errorf("parsing installed bundle %q version %q: %w | installedBundle %v", installedBundle.Name, installedBundle.Version, err) |
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.
Ah shoot, some of that is still debugging changes I didn't rollback - thanks for catching that!
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.
should be updated in 8c12758
|
I will squash commits after reviews are fully addressed |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1068 +/- ##
==========================================
- Coverage 75.65% 75.28% -0.38%
==========================================
Files 31 33 +2
Lines 1902 1861 -41
==========================================
- Hits 1439 1401 -38
- Misses 320 321 +1
+ Partials 143 139 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
Looks reasonable to me, but needs a rebase. |
…testing by moving bundle validation logic to the resolver, moving installation of content behind a new Applier interface, and using the new contentmanager.Watcher interface for watching managed objects Signed-off-by: everettraven <[email protected]>
Signed-off-by: everettraven <[email protected]>
Signed-off-by: everettraven <[email protected]>
Signed-off-by: everettraven <[email protected]>
Signed-off-by: everettraven <[email protected]>
Signed-off-by: everettraven <[email protected]>
Signed-off-by: everettraven <[email protected]>
Signed-off-by: everettraven <[email protected]>
8c12758 to
dcd37f0
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
…#1068) * update reconciler with logical interface abstractions to simply unit testing by moving bundle validation logic to the resolver, moving installation of content behind a new Applier interface, and using the new contentmanager.Watcher interface for watching managed objects Signed-off-by: everettraven <[email protected]> * update testing Signed-off-by: everettraven <[email protected]> * update testing Signed-off-by: everettraven <[email protected]> * remove bundle validation unit tests from controller package Signed-off-by: everettraven <[email protected]> * make linter happy Signed-off-by: everettraven <[email protected]> * remove postrenderer, replace with map[string]string for labels Signed-off-by: everettraven <[email protected]> * update debugging error string Signed-off-by: everettraven <[email protected]> * rebase fixes Signed-off-by: everettraven <[email protected]> --------- Signed-off-by: everettraven <[email protected]>
…#1068) * update reconciler with logical interface abstractions to simply unit testing by moving bundle validation logic to the resolver, moving installation of content behind a new Applier interface, and using the new contentmanager.Watcher interface for watching managed objects Signed-off-by: everettraven <[email protected]> * update testing Signed-off-by: everettraven <[email protected]> * update testing Signed-off-by: everettraven <[email protected]> * remove bundle validation unit tests from controller package Signed-off-by: everettraven <[email protected]> * make linter happy Signed-off-by: everettraven <[email protected]> * remove postrenderer, replace with map[string]string for labels Signed-off-by: everettraven <[email protected]> * update debugging error string Signed-off-by: everettraven <[email protected]> * rebase fixes Signed-off-by: everettraven <[email protected]> --------- Signed-off-by: everettraven <[email protected]>
Description
Makes the
reconcilemethod on theClusterExtensionReconcilereasier to unit test by encapsulating distinct operations as interfaces that can be mocked:Resolverinterface.Resolver. The reasoning behind this is that it reduces the complexity of thereconcilemethod by making the assumption that the configuredResolverwill always return a valid bundle. Validation unit tests that existed in theinternal/controllerpackage have been moved and updated in theinternal/resolvepackageApplierinterface. This makes it easier to, in the future, swap out the underlying installation method by implementing a newApplierinterface and swapping it out for the existing one. The existing Helm-based installation logic was moved to an implementation of this interface.Watcherinterface that was implemented as part of the provided service account work. This was going to be a change that took place in the near future. From a functionality perspective, nothing should have changed.ClusterExtensionReconciler.reconcile()methodReviewer Checklist