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

🌱 Part 5: Reduce number of variable sources. Final cleanup #501

Merged
merged 2 commits into from
Nov 10, 2023

Conversation

m1kola
Copy link
Member

@m1kola m1kola commented Oct 31, 2023

Description

Spliting #460 into smaller chunks.

In this PR I replace controller variable source with an implementation containing a bunch of function calls (from parts 1-4). I also remove old variable sources and related tests

Closes #437

Reviewer Checklist

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

@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 Oct 31, 2023
Copy link

codecov bot commented Oct 31, 2023

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (7e321b4) 85.30% compared to head (c73b5a6) 83.69%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #501      +/-   ##
==========================================
- Coverage   85.30%   83.69%   -1.61%     
==========================================
  Files          23       20       -3     
  Lines         898      822      -76     
==========================================
- Hits          766      688      -78     
- Misses         91       92       +1     
- Partials       41       42       +1     
Flag Coverage Δ
e2e 63.86% <80.00%> (-2.17%) ⬇️
unit 78.59% <80.00%> (-1.46%) ⬇️

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

Files Coverage Δ
internal/resolution/variablesources/bundle.go 100.00% <ø> (ø)
...al/resolution/variablesources/bundle_uniqueness.go 100.00% <ø> (ø)
internal/controllers/variable_source.go 68.75% <80.00%> (-3.98%) ⬇️

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

@m1kola m1kola changed the title Part 5: Reduce number of variable sources Part 5: Reduce number of variable sources. Final cleanup Oct 31, 2023
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 2, 2023
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 3, 2023
@m1kola m1kola force-pushed the shrink_variable_sources_p5 branch 2 times, most recently from 8e17e8e to 94024b3 Compare November 3, 2023 16:44
@ncdc ncdc changed the title Part 5: Reduce number of variable sources. Final cleanup 🌱 Part 5: Reduce number of variable sources. Final cleanup Nov 6, 2023
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 6, 2023
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 7, 2023
@m1kola m1kola force-pushed the shrink_variable_sources_p5 branch 3 times, most recently from 81ea29a to 420d35a Compare November 8, 2023 09:51
@m1kola m1kola mentioned this pull request Nov 8, 2023
8 tasks
@m1kola m1kola marked this pull request as ready for review November 10, 2023 16:19
@m1kola m1kola requested a review from a team as a code owner November 10, 2023 16:19
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 10, 2023
Signed-off-by: Mikalai Radchuk <mradchuk@redhat.com>
Signed-off-by: Mikalai Radchuk <mradchuk@redhat.com>
@awgreene awgreene added this pull request to the merge queue Nov 10, 2023

bundleUniqueness := variablesources.MakeBundleUniquenessVariables(bundles)

result := []deppy.Variable{}
Copy link
Member

Choose a reason for hiding this comment

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

Maybe take a look at https://freshman.tech/snippets/go/concatenate-slices/, specifically the section "Concatenating multiple slices at once", as a way to do this more efficiently?

Copy link
Member Author

Choose a reason for hiding this comment

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

@ncdc the above works when we want to concatenate slices of the same type. Here we have slices of multiple different types all of which implement deppy.Variable interface and we need to create a slice of deppy.Variables. I don't think it will work here.

I considered doing pre-allocation like this:

result := make([]deppy.Variable, 0, len(requiredPackages)+len(installedPackages)+len(bundles)+len(bundleUniqueness))

But decided not to go with it. It still requires a loop with an append. Also It seems brittle: I can definitely see myself not updating the make call with a new variable when adding another loop. But it avoids extra allocations.

Merged via the queue into operator-framework:main with commit 6222ad1 Nov 10, 2023
13 of 15 checks passed
@m1kola m1kola deleted the shrink_variable_sources_p5 branch November 10, 2023 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reduce number of variable sources involved in resolution process
4 participants