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
Make sure to return nil value when there was an error #1079
Make sure to return nil value when there was an error #1079
Conversation
4db3bd8
to
c49634e
Compare
Codecov Report
@@ Coverage Diff @@
## master #1079 +/- ##
==========================================
+ Coverage 58.87% 58.92% +0.04%
==========================================
Files 30 30
Lines 1668 1670 +2
==========================================
+ Hits 982 984 +2
Misses 560 560
Partials 126 126
Continue to review full report at Codecov.
|
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 good - we need just to tighten error assertion in the new test.
Expect(err).NotTo(HaveOccurred()) | ||
|
||
res, err := service.CustomResourceDefinition() | ||
Expect(err).To(HaveOccurred()) |
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.
the error should occur and should be the very same that gets returned in line 100.
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 please squash commits
When CrdReader fail and returns error other than NotFound service.CustomResourceDefinition should return 'nil' instead of CRD that might be invalid. Signed-off-by: Tomas Kral <tkral@redhat.com>
7228c97
to
fe89a3e
Compare
done. thx for review. |
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
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: pedjak 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 |
Motivation
Saving service crd (
s.crd
) when there was an error while retrieving it (s.CrdReader(s.groupVersionResource)
) can lead tonil
pointer problems.This was causing problem for odo when it tried to use SBO as a library.
Changes
Return error and don't save crd to
s.crd
.Testing
Added a test that covers this scenario.
For further more details refer the CONTRIBUTING.md
Release Notes
Before this update, when the Service Binding Operator was used as a library, there was an error while retrieving a service custom resource definition (CRD). This situation could lead to
nil
pointer problems and crash the Operator. With this update, the issue is resolved and the Operator is made more stable.