Skip to content
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

Enhance Broker Filter to proxy Response Headers #5946

Conversation

travis-minke-sap
Copy link
Contributor

Fixes #5935

I'm new to the Broker / Trigger / Filter implementations (first PR) so someone with more familiarity should confirm whether the proposed changes are acceptable in the context of the larger ecosystem. I'm hoping this is an easy net-win, but don't know whether there could be downstream impacts on various channels. I've tested with the IMC to verify it's working as expected.

The fact that the Filter was not already returning the headers was surprising to me, as it is effectively placing limitations and assumptions on Channel implementations ability to consider headers in a non-broker use case. Seems very presumptuous to do so - unless it's somewhere in the Channel Spec that I've not seen? (something like - "...when you build a Channel you are not allowed to use the response headers or your channel will not be compatible with Brokers / Triggers...")

Proposed Changes

  • 🎁 Enhance the broker's filter_handler to proxy headers from subscriber response to backing channels.

Pre-review Checklist

  • At least 80% unit test coverage
  • E2E tests for any new behavior
  • Docs PR for any user-facing impact
  • Spec PR for any new API feature
  • Conformance test for any change to the spec

Release Note


Docs

@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label Dec 1, 2021
@knative-prow-robot knative-prow-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 1, 2021
@knative-metrics-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-knative-eventing-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/broker/filter/filter_handler.go 88.6% 89.1% 0.4

@codecov
Copy link

codecov bot commented Dec 1, 2021

Codecov Report

Merging #5946 (1e1623a) into main (24e133d) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #5946   +/-   ##
=======================================
  Coverage   82.23%   82.24%           
=======================================
  Files         220      220           
  Lines        7572     7575    +3     
=======================================
+ Hits         6227     6230    +3     
  Misses        911      911           
  Partials      434      434           
Impacted Files Coverage Δ
pkg/broker/filter/filter_handler.go 81.04% <100.00%> (+0.37%) ⬆️

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 24e133d...1e1623a. Read the comment docs.

@@ -274,6 +274,7 @@ func (h *Handler) writeResponse(ctx context.Context, writer http.ResponseWriter,
writer.WriteHeader(http.StatusBadGateway)
return http.StatusBadGateway, errors.New("received a non-empty response not recognized as CloudEvent. The response MUST be either empty or a valid CloudEvent")
}
proxyHeaders(resp.Header, writer) // Proxy original Response Headers for downstream use
Copy link
Member

Choose a reason for hiding this comment

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

I was wondering if we call this function once at line 262, so that we cover every error or success path.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I can certainly do that. I did consider it, and the reason I only changed the "success" paths is that I wasn't sure whether it made sense to return certain headers in cases where we are changing the response code. I still have "Retry-After" on my brain, and that header only "relates" to 429/503... so would it make sense to return with 500 or 502. I suppose in that example the header might not make sense but wouldn't cause a problem?

I will rework the PR (tests mostly) as suggested ; )

Copy link
Member

Choose a reason for hiding this comment

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

I see, thanks for the clarification!

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 2, 2021
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pierDipi, travis-minke-sap

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

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 2, 2021
@knative-prow-robot knative-prow-robot merged commit 7678268 into knative:main Dec 2, 2021
@travis-minke-sap travis-minke-sap deleted the broker-filter-proxy-response-headers branch December 2, 2021 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Retry After doesn't work for MT Channel Based Broker
4 participants