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
Fix nil function in buildContext return values #610
Fix nil function in buildContext return values #610
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: komish The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @komish. Thanks for your PR. I'm waiting for a operator-framework member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Signed-off-by: Jose R. Gonzalez <josegonzalez89@gmail.com>
1296d93
to
4f320cd
Compare
Codecov Report
@@ Coverage Diff @@
## master #610 +/- ##
==========================================
+ Coverage 48.80% 51.53% +2.73%
==========================================
Files 90 122 +32
Lines 6276 10542 +4266
==========================================
+ Hits 3063 5433 +2370
- Misses 2528 4097 +1569
- Partials 685 1012 +327
Continue to review full report at Codecov.
|
I don't believe similar PR #583 addresses this issue (though it addresses another that I ran into as well, so that's awesome). |
fwiw, I tested your change @komish and is showing a more clear error message:
Thanks! |
/ok-to-test |
LGTM, thanks komish ! |
@ylamgarchal I think there are some places where you can specify the destination dir (see: Either way, might make sense to request the option as a new issue as there are probably multiple throughout the code base where tmp location to store files could be used. Maintainers can probably comment further. |
/lgtm Would it be possible to add a unit test to cover this case to prevent regressions? |
@joelanford sure thing. I'm targeting I'll push a commit shortly. |
Signed-off-by: Jose R. Gonzalez <josegonzalez89@gmail.com>
Done. Added some basic testing for In hindsight, I probably should have added these as a separate PR to prevent the need for re-reviewing. My apologies. |
/lgtm |
Hi komish, this temporary directory is used "internally" by the function and cleaned before the command ends. I don't think it makes sense to have such option explicitly from the command line. Maybe a solution would be from the ioutil.TempDir documentation:
wdyt |
Just noticing this still hasn't merge. Is there anything needed on my end with regards to this PR? @joelanford @timflannagan |
@komish Neither Joe or I have approval permissions for this repository - you can find the list of people that do in the root OWNERS file. In the meantime, maybe @kevinrizza or @njhale might be able to take a look when they have a chance? |
Understood, my apologies - pinged you both because of the listed Assignees. Thanks for looping in the right folks! |
(Hopefully removing some of the expired context's) /test all |
@timflannagan: No presubmit jobs available for operator-framework/operator-registry@master In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/approve |
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.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: awgreene, dinhxuanvu, komish The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Description of the change:
The change sets a return value for
cleanup
(typefunc()
) to a no-op at the top of the function logic. This helps prevent a situation where returning before setting that function inbuildContext()
can cause a<nil>
to be returned for that value which throws an error at runtime when called.Concrete Context
During an
opm index prune
-In pkg/lib/indexer/indexer.go:
If the user has not passed
--generate
toopm index prune
AND they cannot write to the underlying directory,buildContext(...)
runs into an error trying toTempDir(...)
:Up until that point
cleanup
hasn't been defined, so it's<nil>
. Then,buildContext
completes and the next line ofPruneFromIndex
callsdefer cleanup()
(i.e.defer <nil>()
) which causes the panic.Motivation for the change:
https://bugzilla.redhat.com/show_bug.cgi?id=1943284 - While needing write permissions is fair, other commands return a permission denied (bubbling up from
ioutil.TempDir
). I think that was probably the intention for this command as well.Reviewer Checklist
/docs