-
Notifications
You must be signed in to change notification settings - Fork 600
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
Add health endpoint to event_display server #5608
Conversation
Skipping CI for Draft Pull Request. |
Codecov Report
@@ Coverage Diff @@
## main #5608 +/- ##
==========================================
- Coverage 82.79% 82.73% -0.07%
==========================================
Files 199 200 +1
Lines 6230 6243 +13
==========================================
+ Hits 5158 5165 +7
- Misses 744 748 +4
- Partials 328 330 +2
Continue to review full report at Codecov.
|
Demo: $ curl -D- http://localhost:8080/ -H "Ce-Specversion: 1.0" -H "Ce-Id: 0001" -H "Ce-Type: greeting" -H "Ce-Source: curl" -H "Content-Type: application/json" -d '{"msg":"Hello, World!"}
HTTP/1.1 200 OK
Date: Sat, 24 Jul 2021 14:33:09 GMT
Content-Length: 0 $ curl -D- http://localhost:8080/healthz
HTTP/1.1 204 No Content
Date: Sat, 24 Jul 2021 14:31:48 GMT |
The following is the coverage report on the affected files.
|
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: antoineco, 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:
Approvers can indicate their approval by writing |
c, err := cloudevents.NewClientHTTP( | ||
cehttp.WithMiddleware(healthzMiddleware()), | ||
) |
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.
@n3wscott I needed something quick so I used a Middleware
for the time being, but this feels clumsy to me (see the implementation of healthzMiddleware()
below which is especially hacky).
Since I'm going to refactor this for testability, I thought now was a good time to ask for your expertise :)
Proposed Changes
event_display
on the/healthz
endpoint.This handler responds with "204 No Content" to any request, regardless of the HTTP method. It is meant to be used for probing liveness/readiness.
Background: I observed race conditions on several occasions downstream, in e2e tests that rely on event_display. E.g. an event is sent as soon as the Pod starts, but the CE client isn't started yet 🤷.
I purposely avoided using something from k8s/knative to avoid large imports ("fat binary").
Pre-review Checklist
event_display
didn't have unit tests prior to this PR. I'll add more tests in a subsequent refactoring.)Release Note
Docs