-
Notifications
You must be signed in to change notification settings - Fork 149
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
[release-1.7] Fix panic: "nil pointer dereference" #2012
[release-1.7] Fix panic: "nil pointer dereference" #2012
Conversation
Pull Request Test Coverage Report for Build 2524003115
💛 - Coveralls |
The software craches when updating a metric resource, because then we're trying to send the HyperConverged pointer to a function as an interface. The function does check for nil, but this is not working, because interface(nil) != nil. This PR fixes the bug by not sending the nil interface but an actual nil, and also changes the check to use reflection in order to make sure that the function parameter is nil. Signed-off-by: Nahshon Unna-Tsameret <nunnatsa@redhat.com>
ea6057d
to
5936d0c
Compare
Kudos, SonarCloud Quality Gate passed! |
hco-e2e-upgrade-prev-index-aws lane succeeded. |
@hco-bot: Overrode contexts on behalf of hco-bot: ci/prow/hco-e2e-image-index-sno-azure, ci/prow/hco-e2e-upgrade-prev-index-azure 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. |
/lgtm |
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.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: orenc1 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 |
if object != nil { | ||
// checking object != nil does not work because object is an interface, and nil interface instance is not nil. | ||
// We need to check that it's actually nil, using reflection. | ||
if t := reflect.ValueOf(object); t.Kind() != reflect.Ptr || !t.IsNil() { |
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.
not that it make a difference, but maybe use the exact same code as in main?
https://github.com/kubevirt/hyperconverged-cluster-operator/pull/2011/files#diff-04c60da2651653a56d9a3e11edaa1694261a63200172901315131ea465758747R44
(i.e. Pointer
vs. Ptr
)
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.
Couldn't do it before. Pointer added at go 1.18. This branch was compiled with 1.17. I just fixed it, but it wasn't ready on time.
@nunnatsa: The following tests failed, say
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. |
hco-e2e-upgrade-prev-index-sno-azure lane succeeded. |
@hco-bot: Overrode contexts on behalf of hco-bot: ci/prow/hco-e2e-upgrade-prev-index-sno-aws 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. |
The software craches when updating the prometheusRule, because then we're
trying to send a nil HyperConverged pointer to a function as an interface.
The function does check for nil, but this is not working, because
interface(nil) != nil
.This PR fixes the bug by not sending the nil interface but an actual
nil, and also changes the check to use reflection in order to make sure
that the function parameter is nil.
Reviewer Checklist
Release note: