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

Enable OPTIONS and CloudEvent Webhook headers #5542

Merged

Conversation

evankanderson
Copy link
Member

@evankanderson evankanderson commented Jun 22, 2021

Fixes #3092

I'm still working on e2e testing / getting the e2e tests to run at all in my environment, but I wanted to put this out there.

Proposed Changes

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

/hold work-in-progress

Release Note

Adds support for HTTP OPTIONS and CloudEvents Webhook preflight

Docs

Should not have user-visible impact. Does have specs-visible impact, aligns with knative/specs#25

@knative-prow-robot knative-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 22, 2021
@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label Jun 22, 2021
@knative-prow-robot knative-prow-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jun 22, 2021
@codecov
Copy link

codecov bot commented Jun 22, 2021

Codecov Report

Merging #5542 (c58bf70) into main (dcbb9af) will increase coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5542      +/-   ##
==========================================
+ Coverage   82.73%   82.76%   +0.03%     
==========================================
  Files         200      200              
  Lines        6243     6256      +13     
==========================================
+ Hits         5165     5178      +13     
  Misses        748      748              
  Partials      330      330              
Impacted Files Coverage Δ
pkg/broker/filter/filter_handler.go 80.53% <100.00%> (+0.13%) ⬆️
pkg/broker/ingress/ingress_handler.go 75.92% <100.00%> (+1.41%) ⬆️
pkg/channel/message_receiver.go 70.51% <100.00%> (+2.45%) ⬆️

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 dcbb9af...c58bf70. Read the comment docs.

@evankanderson
Copy link
Member Author

It looks like I'm going to need to do some surgery on test/lib/send_event.go to be able to send an OPTIONS request; might get to this later tonight.

@knative-prow-robot knative-prow-robot added the area/test-and-release Test infrastructure, tests or release label Jun 23, 2021
@evankanderson
Copy link
Member Author

/hold cancel

@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 23, 2021
@@ -101,7 +101,14 @@ func (h *Handler) Start(ctx context.Context) error {
}

func (h *Handler) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
writer.Header().Set("Allow", "POST, OPTIONS")
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

http://github.com/knative/specs/pull/25, data-plane.md, line 88.

Copy link
Member Author

Choose a reason for hiding this comment

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

(I started working ahead of that commit landing)

@@ -136,6 +136,13 @@ func (r *MessageReceiver) Start(ctx context.Context) error {
}

func (r *MessageReceiver) ServeHTTP(response nethttp.ResponseWriter, request *nethttp.Request) {
response.Header().Set("Allow", "POST")
Copy link
Member

Choose a reason for hiding this comment

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

	Header().Set("Allow", "POST, OPTIONS")

? or why is that different here

Copy link
Member Author

Choose a reason for hiding this comment

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

Because I'm an idiot.

Thanks!

(And, if I'd gotten all my e2e testing working, I'd have noticed this.

Copy link
Member Author

Choose a reason for hiding this comment

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

It actually turns out that my tests are all wrong, because receiverFunc is not called at all for OPTIONS requests.

Fixed.

@benmoss
Copy link
Member

benmoss commented Jun 30, 2021

Looks like you need the latest go-licenses to fix the filemode changes

@matzew
Copy link
Member

matzew commented Jul 22, 2021

@evankanderson any updates on this PR ?

@evankanderson
Copy link
Member Author

Fixed the formatting bugs; not sure how they got in there.

@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.5% 88.5% 0.1
pkg/broker/ingress/ingress_handler.go 84.4% 85.4% 1.0
pkg/channel/message_receiver.go 75.0% 77.3% 2.3

Copy link
Member

@matzew matzew left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: evankanderson, matzew

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:
  • OWNERS [evankanderson,matzew]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

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. area/test-and-release Test infrastructure, tests or release 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.

Adding support for CloudEvents WebHook Spec
5 participants