-
Notifications
You must be signed in to change notification settings - Fork 62
✨ Modify ClusterExtension to use Helm under the hood to apply contents into the cluster #846
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
Conversation
✅ Deploy Preview for olmv1 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #846 +/- ##
==========================================
- Coverage 83.18% 75.38% -7.80%
==========================================
Files 15 18 +3
Lines 874 1170 +296
==========================================
+ Hits 727 882 +155
- Misses 102 208 +106
- Partials 45 80 +35
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@tmshort thanks for deconflicting main.go 👍 |
6b26fd0
to
30df23b
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.
I haven't reviewed the controller itself properly and some other bits. Some comments so far.
I think this PR too big to be adequately reviewed. Is there a way we can split this into multiple smaller PRs? I might be missing something, but it looks like unpacker is fairly independent and can be a separate PR. Then changes to goreleaser to make it buildable can be a separate PR. A bunch of helper functions can be moved into a separate PR, I think.
internal/controllers/clusterextension_registryv1_validation_test.go
Outdated
Show resolved
Hide resolved
Signed-off-by: Varsha Prasad Narsing <[email protected]>
It's agreed that this makes debugging and reasoning about log messages and runtime errors much harder. Signed-off-by: Brett Tofel <[email protected]>
Fixes the e2e tests in helm-poc branch and restores feature-gate switching. Signed-off-by: dtfranz <[email protected]>
Fixes the defer location to make sure that all resources are cleaned up properly. Signed-off-by: dtfranz <[email protected]>
When tests fail, gatherArtifacts is run to collect cluster state. This PR removes gathering of BundleDeployments since we don't use them anymore and it's generating additional misleading error messages. Signed-off-by: dtfranz <[email protected]>
Signed-off-by: Varsha Prasad Narsing <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #846 +/- ##
==========================================
- Coverage 83.18% 77.21% -5.97%
==========================================
Files 15 17 +2
Lines 874 1176 +302
==========================================
+ Hits 727 908 +181
- Misses 102 189 +87
- Partials 45 79 +34
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
* Proposed way to unskip some tests TestClusterExtensionChannelVersionExists mostly restored here Signed-off-by: Brett Tofel <[email protected]> * Refactors global variable names Signed-off-by: Brett Tofel <[email protected]> * Removes BundleDeployment related checking In just one test, for now. Signed-off-by: Brett Tofel <[email protected]> * fix unit test - TestClusterExtensionChannelVersionExists * Unskip all - failing tests (up|down)grade should err Unskips all in clusterextension_controller_test.go Signed-off-by: Brett Tofel <[email protected]> * Unskip all clusterextension_registryv1_validation_test.go Still failing tests (up|down)grade should err b/c we don't have an installedBundle to check against Signed-off-by: Brett Tofel <[email protected]> * debugging Signed-off-by: Varsha Prasad Narsing <[email protected]> * Fixes and additions pending & unpack path Signed-off-by: Brett Tofel <[email protected]> * Fix linter, remove debug logs and extraneous file Signed-off-by: dtfranz <[email protected]> * Fix e2e failure due to race condition Signed-off-by: dtfranz <[email protected]> --------- Signed-off-by: Brett Tofel <[email protected]> Signed-off-by: Varsha Prasad Narsing <[email protected]> Signed-off-by: dtfranz <[email protected]> Co-authored-by: Varsha Prasad Narsing <[email protected]> Co-authored-by: dtfranz <[email protected]>
@everettraven @m1kola @acornett21 PTAL |
Signed-off-by: Brett Tofel <[email protected]>
return currentRelease, stateUnchanged, nil | ||
} | ||
|
||
var GetInstalledbundle = func(ctx context.Context, acg helmclient.ActionClientGetter, allBundles []*catalogmetadata.Bundle, ext *ocv1alpha1.ClusterExtension) (*catalogmetadata.Bundle, 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.
Why did this go from a method to a global variable (package scoped)? Doing this opens us up to bugs if this variable is somehow overwritten. I would highly recommend avoiding this.
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.
Instead of using a global variable, I would recommend creating a new interface like:
type InstalledBundleGetter interface {
GetInstalledBundle(...) (...)
}
and make use of it via a field in the reconciler like:
type Reconciler struct {
...
InstalledBundleGetter InstalledBundleGetter
...
}
func (r *Reconciler) reconcile(...) (...) {
...
installedBundle, err := r.InstalledBundleGetter.GetInstalledBundle(...)
...
}
This has the ability to be mocked for testing while also preventing potential issues with using global variables
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.
The reason for not creating an interface was GetInstalledBundle need not be exposed to the user in any way, it’s just for mocking purposes that we need to do this. If we are exposing it, then we may also have to expose the resolver logic and make it a separate interface.
Both of them were too much of a change, and since the var is inside an internal pkg, the chances of external users changing it are super minimal.
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.
Coming back around to this, something like:
type Reconciler struct {
GetInstalledBundleFunc func(...)(...)
}
might be even better due to it being an explicit type that I don't believe would be allowed to be set as nil
, alleviating the need to do a potential validation check for a nil reference
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.
Though not the best design for now, since it's internal and has no chances of external users breaking it - I'd suggest to do it in a follow up. Especially because it'll require a lot more bits of controller to be changed. An even better way would be for us to instead modify the way we have designed unit tests to mock better.
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.
And I think ^ would result in less work to change while getting the benefits of no longer using a global variable
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.
If you really prefer this being done in a follow up I won't stop this from going in, but this is something that I would think we want fixed very quickly. I don't think this is a good practice, even if it is in an internal package.
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.
well I'm part-way through with the swap out to interface, just doing the mocks needed in the tests now. If you are okay with it in a soon to be added PR, can we can get an approve on this PR and merge?
internal/controllers/clusterextension_registryv1_validation_test.go
Outdated
Show resolved
Hide resolved
Signed-off-by: Brett Tofel <[email protected]>
Signed-off-by: Brett Tofel <[email protected]>
Description
ClusterExtension reconciler needs to perform the following actions:
[See this doc for more detail if possible.]
Based on the cluster Extension spec, get the list of bundles from the catalog and perform resolution.
Unpack the contents of the resolved bundle. For this iteration we can cover only registryV1 bundles from an image source.
Conversion of registryV1 to plain bundle.
Creating a Helm chart from the resources present in plain bundle.
Installing helm chart onto the cluster.
Reviewer Checklist