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

✨ remove unnecessary flag, optimize catalog watch handler, stop watching non-existent unpack pods #941

Merged
merged 1 commit into from
Jun 17, 2024

Conversation

joelanford
Copy link
Member

Description

Reviewer Checklist

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

@joelanford joelanford requested a review from a team as a code owner June 14, 2024 18:57
Copy link

netlify bot commented Jun 14, 2024

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit 3b172c3
🔍 Latest deploy log https://app.netlify.com/sites/olmv1/deploys/666d9ade619dfe000826edff
😎 Deploy Preview https://deploy-preview-941--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.

Copy link

codecov bot commented Jun 14, 2024

Codecov Report

Attention: Patch coverage is 81.48148% with 10 lines in your changes missing coverage. Please review.

Project coverage is 80.41%. Comparing base (f301f55) to head (3b172c3).

Files Patch % Lines
...nternal/controllers/clusterextension_controller.go 62.50% 5 Missing and 1 partial ⚠️
cmd/manager/main.go 89.47% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #941      +/-   ##
==========================================
+ Coverage   79.34%   80.41%   +1.06%     
==========================================
  Files          16       16              
  Lines        1104     1103       -1     
==========================================
+ Hits          876      887      +11     
+ Misses        158      150       -8     
+ Partials       70       66       -4     
Flag Coverage Δ
e2e 59.20% <81.48%> (+1.05%) ⬆️
unit 53.85% <1.85%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -574,7 +572,6 @@ func (r *ClusterExtensionReconciler) SetupWithManager(mgr ctrl.Manager) error {
return true
},
}).
Watches(&corev1.Pod{}, mapOwneeToOwnerHandler(mgr.GetClient(), mgr.GetLogger(), &ocv1alpha1.ClusterExtension{})).
Copy link
Member

@varshaprasad96 varshaprasad96 Jun 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're on it - we should also be able to remove the rbac to watch pods:

//+kubebuilder:rbac:groups=core,resources=pods,verbs=list;watch;create;delete
//+kubebuilder:rbac:groups=core,resources=configmaps,verbs=list;watch
//+kubebuilder:rbac:groups=core,resources=pods/log,verbs=get
.

If not in this PR, it can be done in follow up too

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do it now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed a change. I removed the pods stuff, and changed the configmaps RBAC (what was that for?) to secrets since the helm stuff needs to manage release secrets.

It's all sorta moot though because:

  • We give ourselves */*/* in the next line.
  • We'll eventually drop the secrets permission here because we'll expect the SA to have the necessary permission to handle their own release secret.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and changed the configmaps RBAC (what was that for?)

I think it may have gotten ported over from Extension, where Kapp needed CRUD permissions for configmaps.

@joelanford joelanford force-pushed the random-cleanup branch 2 times, most recently from 186c4ce to 64420af Compare June 14, 2024 19:39
varshaprasad96
varshaprasad96 previously approved these changes Jun 14, 2024
Copy link
Member

@varshaprasad96 varshaprasad96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 14, 2024
@tmshort
Copy link
Contributor

tmshort commented Jun 14, 2024

Looks like 'make verify' or equivalent is needed.
/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 14, 2024
@joelanford
Copy link
Member Author

Oops forgot to re-gen RBAC. Will do!

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Jun 14, 2024
@joelanford
Copy link
Member Author

/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 14, 2024
@joelanford joelanford force-pushed the random-cleanup branch 2 times, most recently from e437d99 to 1749fb1 Compare June 15, 2024 13:28
- remove unnecessary flag
- optimize catalog watch handler
- fix finalizers (also stop using rukpak-based finalizers and keys)
- Add some reminder TODO comments about more improvements (need to
  convert to issues)

Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
@@ -116,6 +117,7 @@ func TestClusterExtensionRegistryV1DisallowDependencies(t *testing.T) {
ActionClientGetter: helmClientGetter,
Unpacker: unpacker,
InstalledBundleGetter: mockInstalledBundleGetter,
Finalizers: crfinalizer.NewFinalizers(),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit disconcerting to me that so much of the ClusterExtensionReconciler can be constructed so differently than the real one can. We should discuss further, but off the top of my head, I wonder if we can use the exact same reconciler as is configured in main.go.

  1. For catalogd we can use httptest to setup a mock catalogd server and use the real ClusterExtension http client.
  2. An image registry is an http server. I wonder if there is an in-process implementation that would be easy to run for test purposes.
  3. Use t.TempDir() subdirectories for any necessary local storage and caching that happens during reconcile.
  4. For the kubernetes cluster, we use envtest.

If we had that setup, we wouldn't actually need to configure the ClusterExtension reconciler any differently.

Copy link
Member Author

@joelanford joelanford Jun 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More immediately, we should have unit tests that make sure finalizers are actually being handled properly during reconcile.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit disconcerting to me that so much of the ClusterExtensionReconciler can be constructed so differently than the real one can.

This is definitely up for discussion and needs separate set of effort. The whole point of these unit tests is to make sure that the reconciler code path traversed during various instances is as expected. Which is why we ensure that the mock unpacker returns quickly as expected. The code coverage for unpacking and storage has separate unit tests (currently in rukpak).

I'm not sure if we immediately need to focus on this - rather if possible try finishing up #879 as immediately as possible (even if it requires us to mock some of the components) to ensure we don't skip any nuances in the reconciler code.

Copy link
Member

@varshaprasad96 varshaprasad96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@@ -116,6 +117,7 @@ func TestClusterExtensionRegistryV1DisallowDependencies(t *testing.T) {
ActionClientGetter: helmClientGetter,
Unpacker: unpacker,
InstalledBundleGetter: mockInstalledBundleGetter,
Finalizers: crfinalizer.NewFinalizers(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit disconcerting to me that so much of the ClusterExtensionReconciler can be constructed so differently than the real one can.

This is definitely up for discussion and needs separate set of effort. The whole point of these unit tests is to make sure that the reconciler code path traversed during various instances is as expected. Which is why we ensure that the mock unpacker returns quickly as expected. The code coverage for unpacking and storage has separate unit tests (currently in rukpak).

I'm not sure if we immediately need to focus on this - rather if possible try finishing up #879 as immediately as possible (even if it requires us to mock some of the components) to ensure we don't skip any nuances in the reconciler code.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 17, 2024
@tmshort tmshort added this pull request to the merge queue Jun 17, 2024
Merged via the queue into operator-framework:main with commit b4c928c Jun 17, 2024
17 checks passed
@joelanford joelanford deleted the random-cleanup branch June 18, 2024 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants