Skip to content
This repository was archived by the owner on Jun 26, 2024. It is now read-only.

Conversation

sadlerap
Copy link
Contributor

Motivation

If a service has an invalid service binding annotation set, we shouldn't attempt to bind the service. However, current behavior catches most cases (such as an invalid path), but errors currently are ignored, and when either elementType or objectType isn't valid, we panic. This could cause issues for users.

Changes

Rather than panicking, we should fail the binding request and report any errors that are thrown.

Testing

Attempting to bind against a service with an garbage annotation should now fail and report errors in the binding status. For example, service.binding/credentials: path={.status.dbCredentials},elementType=asdf should fail. This currently implements unit and acceptance tests for both elementType and objectType errors. It also adds an acceptance test for invalid paths for the sake of regression testing.

@openshift-ci openshift-ci bot requested review from baijum and pedjak September 16, 2021 20:31
@codecov
Copy link

codecov bot commented Sep 16, 2021

Codecov Report

Merging #1023 (620899b) into master (4944c7b) will increase coverage by 0.31%.
The diff coverage is 100.00%.

❗ Current head 620899b differs from pull request most recent head a27aa03. Consider uploading reports for the commit a27aa03 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1023      +/-   ##
==========================================
+ Coverage   56.66%   56.97%   +0.31%     
==========================================
  Files          28       28              
  Lines        1560     1569       +9     
==========================================
+ Hits          884      894      +10     
+ Misses        559      558       -1     
  Partials      117      117              
Impacted Files Coverage Δ
pkg/binding/annotationmapper.go 87.17% <100.00%> (+2.67%) ⬆️
pkg/reconcile/pipeline/handler/collect/impl.go 82.71% <100.00%> (+0.21%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4944c7b...a27aa03. Read the comment docs.

Copy link
Contributor

@pedjak pedjak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall looks good, a few things to improve only.

@sadlerap sadlerap force-pushed the dont-panic branch 2 times, most recently from 957d3ce to 1cc7977 Compare September 21, 2021 21:42
@sadlerap
Copy link
Contributor Author

/retest

@pedjak pedjak added this to the GA milestone Sep 23, 2021
In a service binding annotation on a service, elementType and objectType
could be garbage (i.e. elementType=asdf), and SBO would panic.  We
should instead do the following:

1. Throw an error instead of panicking when either of these two are
   invalid.
2. Fail the binding if those errors are thrown.

Signed-off-by: Andy Sadler <[email protected]>
@pedjak
Copy link
Contributor

pedjak commented Sep 26, 2021

/lgtm
/approve

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 26, 2021

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 2c4d36b into redhat-developer:master Sep 26, 2021
@pedjak pedjak modified the milestones: GA, 0.11 Sep 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants