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

Reduce variable count #453

Merged
merged 1 commit into from
Oct 12, 2023
Merged

Conversation

m1kola
Copy link
Member

@m1kola m1kola commented Oct 11, 2023

Description

After this commit we will be creating one bundle per package. Previously we we creating one variable per bundle occurance in a channel which is currently unnecessary.

Closes #414

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 11, 2023
After this commit we will be creating one bundle per package.
Previously we we creating one variable per bundle occurance in a channel
which is currently unnecessary.

Signed-off-by: Mikalai Radchuk <mradchuk@redhat.com>
@codecov
Copy link

codecov bot commented Oct 11, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (205a487) 83.86% compared to head (497d929) 83.80%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #453      +/-   ##
==========================================
- Coverage   83.86%   83.80%   -0.06%     
==========================================
  Files          23       23              
  Lines         849      846       -3     
==========================================
- Hits          712      709       -3     
  Misses         94       94              
  Partials       43       43              
Flag Coverage Δ
e2e 65.95% <75.00%> (-0.13%) ⬇️
unit 76.58% <92.85%> (-0.09%) ⬇️

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

Files Coverage Δ
internal/resolution/variables/bundle.go 100.00% <100.00%> (ø)
internal/resolution/variables/installed_package.go 100.00% <100.00%> (ø)
internal/resolution/variables/required_package.go 100.00% <100.00%> (ø)
...lution/variablesources/bundles_and_dependencies.go 96.00% <100.00%> (ø)
...rnal/resolution/variablesources/crd_constraints.go 100.00% <100.00%> (ø)

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

@m1kola m1kola marked this pull request as ready for review October 11, 2023 10:15
@m1kola m1kola requested a review from a team as a code owner October 11, 2023 10:15
@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 Oct 11, 2023
if _, ok := visited[id]; ok {
continue
}
visited[id] = struct{}{}
Copy link
Member

Choose a reason for hiding this comment

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

Can we use sets.New[deppy.Identifier]() for clearer semantics on visited and added?

Copy link
Member Author

@m1kola m1kola Oct 11, 2023

Choose a reason for hiding this comment

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

AFAIK Go doesn't have sets in standard library and as a result using maps for sets is pretty common.

But we can do that. However I do not see any sets package in our codebase. What package is it?

Edit: is it k8s.io/apimachinery/pkg/util/sets?

Copy link
Member Author

Choose a reason for hiding this comment

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

Anyway I think it should not be in this PR. Could you please create an issue or PR for this suggesting a pacakge to use?

Copy link
Member

Choose a reason for hiding this comment

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

The k8s API machinery sets package is the one - we use it in basically every other package. Feel free to create the issue if you don't think you can do it here.

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'm a fan of small PRs serve one porpuse. Don't want to mix different efforts into this PR.

Created #454 for this.

Copy link
Contributor

@everettraven everettraven left a comment

Choose a reason for hiding this comment

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

These changes seem reasonable and look good to me, nice job on the variable reduction!

I'm approving, but would prefer waiting to merge on a second approval from someone who has better insight into the variable(sources) and resolution process as a whole to verify this doesn't have any cascading impacts.

func NewBundleVariable(id deppy.Identifier, bundle *catalogmetadata.Bundle, dependencies []*catalogmetadata.Bundle) *BundleVariable {
var dependencyIDs []deppy.Identifier
func NewBundleVariable(bundle *catalogmetadata.Bundle, dependencies []*catalogmetadata.Bundle) *BundleVariable {
dependencyIDs := make([]deppy.Identifier, 0, len(dependencies))
for _, bundle := range dependencies {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: unrelated to this PR, but we can we change the loop variable to be called dependency instead of bundle so that it doesn't shadow the bundle variable passed in as a parameter?

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'll submit a follow up PR straight after merging this one.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

@joelanford joelanford left a comment

Choose a reason for hiding this comment

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

LGTM. I left a nit about a semi-unrelated fix. We can address it now or later.

@m1kola
Copy link
Member Author

m1kola commented Oct 12, 2023

I experimented with t8c operator from https://operatorhub.io/: when installing without specifying version it currently creates 87 variables. With changes in this PR it creates 21 variables.

I haven't mesured the preformance (with a naked eye it is unnoticable), but at least it will give a shorter error message in case of resolution failure.

@m1kola m1kola added this pull request to the merge queue Oct 12, 2023
Merged via the queue into operator-framework:main with commit c24fdbc Oct 12, 2023
12 checks passed
@m1kola m1kola deleted the reduce_variable_count branch October 12, 2023 08:46
@m1kola m1kola mentioned this pull request Oct 12, 2023
4 tasks
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 resolution variables to one per bundle
4 participants