-
Notifications
You must be signed in to change notification settings - Fork 1.1k
ResourceStore: fix segfault and update tests #4530
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
ResourceStore: fix segfault and update tests #4530
Conversation
| } | ||
| // make sure the resource hasn't already been added to the store | ||
| if r.resource != nil || r.cleanupFuncs != nil { | ||
| if r.wasPut() { |
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.
Looks like this code would benefit from
| if r.wasPut() { | |
| if ok && r.wasPut() { |
Or something similar (as there's no need to check wasPut if we just created a new empty resource.
Codecov Report
@@ Coverage Diff @@
## master #4530 +/- ##
==========================================
+ Coverage 40.21% 40.39% +0.18%
==========================================
Files 115 115
Lines 9360 9374 +14
==========================================
+ Hits 3764 3787 +23
+ Misses 5173 5163 -10
- Partials 423 424 +1 |
|
Nit: looks like // WatcherForResource looks up a Resource by name, and gives it a watcher if it's found.but in fact it gives a resource a watcher even if the lookup result is negative (by creating an uninitialized resource). |
fixed! |
|
I would also reorder commits to put the fix before the test -- otherwise if someone uses git-bisect, they find that the test commit breaks things. Overall LGTM except a few nits above. |
3b101f4 to
c58c4a6
Compare
kolyshkin
left a comment
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
QiWang19
left a comment
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
|
/lgtm |
saschagrunert
left a comment
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: haircommander, kolyshkin, saschagrunert The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
|
||
| func (rc *ResourceStore) Close() { | ||
| rc.closeChan <- struct{}{} | ||
| } |
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.
should it also do close(rc.closeChan)?
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.
good point, it should actually only close methinks, as the receiever will still get a value out of it and know it's time to return
c785146 to
7c07f59
Compare
|
/retest |
before, it was possible to segfault when a WatcherForResource was called followed by a Get as we didn't check that the resource was actually put. Fix this Signed-off-by: Peter Hunt <[email protected]>
Signed-off-by: Peter Hunt <[email protected]>
We need to specifically register "Describe" functions, but ginkgo doesn't allow us to register multiple ones. Wrap different functionality in different Contexts so they all run. Signed-off-by: Peter Hunt <[email protected]>
Signed-off-by: Peter Hunt <[email protected]>
69ddaef to
f307f68
Compare
Signed-off-by: Peter Hunt <[email protected]>
f307f68 to
584f175
Compare
|
/retest |
|
LGTM, and it does address all the comments raised, based on that ... |
|
/retest |
|
@haircommander: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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. I understand the commands that are listed here. |
|
/test integration_crun |
What type of PR is this?
What this PR does / why we need it:
There is a chance that a WatcherForResource() followed by a Get() would cause cri-o to segfault. Fix this
also extend the test suite to add a test for this and another situation, as well as move around the tests so they're all run
Which issue(s) this PR fixes:
Special notes for your reviewer:
Does this PR introduce a user-facing change?