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 4: Reduce number of variable sources. Required packages #500

Merged
merged 1 commit into from
Nov 10, 2023

Conversation

m1kola
Copy link
Member

@m1kola m1kola commented Oct 31, 2023

Description

Spliting #460 into smaller chunks. Related to #437

In this part I extract code related to creating required package variables from RequiredPackageVariableSource and OperatorVariableSource into a separate function.

RequiredPackageVariableSource gets removed in this PR. OperatorVariableSource will be removed later in #501

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
@m1kola m1kola changed the title Part 4: Reduce number of variable sources Part 4: Reduce number of variable sources. Required packages Oct 31, 2023
@m1kola m1kola force-pushed the shrink_variable_sources_p4 branch 3 times, most recently from 9e70605 to fb7fc7d Compare November 2, 2023 17:11
@m1kola m1kola force-pushed the shrink_variable_sources_p4 branch 3 times, most recently from 90de92a to dfee29b Compare November 3, 2023 16:44
@ncdc ncdc changed the title Part 4: Reduce number of variable sources. Required packages 🌱 Part 4: Reduce number of variable sources. Required packages 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
Copy link

codecov bot commented Nov 7, 2023

Codecov Report

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

Comparison is base (e9fd250) 84.45% compared to head (6585f6e) 85.21%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #500      +/-   ##
==========================================
+ Coverage   84.45%   85.21%   +0.76%     
==========================================
  Files          23       23              
  Lines         907      893      -14     
==========================================
- Hits          766      761       -5     
+ Misses         96       91       -5     
+ Partials       45       41       -4     
Flag Coverage Δ
e2e 65.62% <69.44%> (-0.32%) ⬇️
unit 80.16% <88.88%> (+0.73%) ⬆️

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

Files Coverage Δ
...nal/resolution/variablesources/required_package.go 100.00% <100.00%> (+27.50%) ⬆️
internal/resolution/variablesources/operator.go 87.50% <77.77%> (-1.39%) ⬇️

... and 1 file with indirect coverage changes

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

@m1kola m1kola force-pushed the shrink_variable_sources_p4 branch 2 times, most recently from 1e883c2 to 1a29986 Compare November 7, 2023 17:03
Signed-off-by: Mikalai Radchuk <mradchuk@redhat.com>
@@ -83,7 +83,7 @@ var _ = Describe("Operator Controller Test", func() {
By("running reconcile")
res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: opKey})
Expect(res).To(Equal(ctrl.Result{}))
Expect(err).To(MatchError(fmt.Sprintf("no package '%s' found", pkgName)))
Copy link
Member Author

Choose a reason for hiding this comment

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

Since I had similar comments on previous parts of this refactoring & most of our errors use double quotation marks I updated the format here.

I'm happy to revert this and move into a separate PR if this is too distracting

Copy link
Member

Choose a reason for hiding this comment

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

+1 on keeping this

@m1kola m1kola mentioned this pull request Nov 7, 2023
8 tasks
@m1kola m1kola marked this pull request as ready for review November 7, 2023 17:15
@m1kola m1kola requested a review from a team as a code owner November 7, 2023 17: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 Nov 7, 2023
Comment on lines +45 to +53
if versionRange != "" && channelName != "" {
return nil, fmt.Errorf("no package %q matching version %q found in channel %q", packageName, versionRange, channelName)
}
if versionRange != "" {
return nil, fmt.Errorf("no package %q matching version %q found", packageName, versionRange)
}
if channelName != "" {
return nil, fmt.Errorf("no package %q found in channel %q", packageName, channelName)
}
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about building up the error message as we're building the predicates (since we're already making the necessary conditional checks as we go)?

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 think I'm not in favour of this approach because:

  1. There are more combinations of errors than we have conditions for predicates. Unless I'm missing something, we will have to add more ifs under existing predicate ifs to get equivalent behaviour
  2. Might be just me, but when I debug an error or read code I appreicate when codebase has unique errors and it is clear which condition yields the error. I found it quite hard to follow what was going on with errors in this PoC which had similar approach.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with the emphasis on readability here.

Copy link
Member

@awgreene awgreene left a comment

Choose a reason for hiding this comment

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

Nice work @m1kola

@awgreene awgreene added this pull request to the merge queue Nov 10, 2023
@m1kola
Copy link
Member Author

m1kola commented Nov 10, 2023

For some reasons jobs in the merge queue did not get triggered. Probably will have to wait for it to timeout and requeue again.

@m1kola m1kola removed this pull request from the merge queue due to a manual request Nov 10, 2023
@m1kola m1kola added this pull request to the merge queue Nov 10, 2023
Merged via the queue into operator-framework:main with commit ec65861 Nov 10, 2023
16 checks passed
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.

None yet

5 participants