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
MGMT-16157 Remove recover usage from DB transactions #5795
Conversation
I didn't removed all the old transaction style code because this is not the purpose of this PR, i will do it in another ticket. |
An example of a code that can create strange issues package main
import (
"fmt"
)
func Foo() (*int, error) {
i := 5
var b *int
defer func() {
if r := recover(); r != nil {
fmt.Println("foo recover")
}
}()
fmt.Println("create a panic", *b)
return &i, nil
}
func main() {
i, err := Foo()
if err != nil {
panic("had an error")
}
fmt.Println(*i)
} |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #5795 +/- ##
==========================================
+ Coverage 67.88% 68.06% +0.17%
==========================================
Files 235 235
Lines 34552 34414 -138
==========================================
- Hits 23456 23424 -32
+ Misses 9009 8928 -81
+ Partials 2087 2062 -25
|
/retest |
The downside of recover is that it may hide bugs like accessing nil pointer and can create a situation where a function panic and instead of returning an error it will return nil, in some cases it cause a hot loop in our controllers, or just move a bug to an upper later. To avoid those situations we decided to remove the recover function usage in the transaction code and move to a new transaction style that will make scope of the trnasaction and handling of errors clearer. Fix unit tests Remove CancelInstallCommitFailedEvent event, it doesn't help the user in any way
0f1ae27
to
8aea285
Compare
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.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: carbonin, filanov 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 |
@filanov: all tests passed! Full PR test history. Your PR dashboard. 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. I understand the commands that are listed here. |
[ART PR BUILD NOTIFIER] This PR has been included in build ose-agent-installer-api-server-container-v4.16.0-202312121444.p0.g005ba71.assembly.stream for distgit ose-agent-installer-api-server. |
The downside of recover is that it may hide bugs like accessing nil pointer and can create a situation where a function panic and instead of returning an error it will return nil, in some cases it cause a hot loop in our controllers, or just move a bug to an upper later.
To avoid those situations we decided to remove the recover function usage in the transaction code and move to a new transaction style that will make scope of the transaction and handling of errors clearer.
List all the issues related to this PR
What environments does this code impact?
How was this code tested?
Checklist
docs
, README, etc)Reviewers Checklist