Skip to content

Add an http::errors::layer to translate errors #222

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

Merged
merged 1 commit into from
Mar 26, 2019
Merged

Conversation

seanmonstar
Copy link
Contributor

This is just the beginning of it, to be used by other pieces later.

@seanmonstar
Copy link
Contributor Author

Hmmm, should this be part of app instead? Seems like a similar role to app::classify...

@olix0r
Copy link
Member

olix0r commented Mar 26, 2019

@seanmonstar wdyt about moving map_err_to_5xx to app and making the layer take a ToStatus (or something) generic argument -- or even just a pure fn if that works out?

@seanmonstar
Copy link
Contributor Author

I've been planning as well to add support to create an appropriate h2 reason if the request was h2 (like refused).

Signed-off-by: Sean McArthur <sean@buoyant.io>
@seanmonstar
Copy link
Contributor Author

For now, I've just moved it entire to app::errors.

Copy link
Member

@olix0r olix0r left a comment

Choose a reason for hiding this comment

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

thanks!

@seanmonstar seanmonstar merged commit 5f58883 into master Mar 26, 2019
@seanmonstar seanmonstar deleted the http-errors branch March 26, 2019 21:15
cratelyn added a commit that referenced this pull request Feb 13, 2025
`linkerd-app-core` includes an error recovery body middleware. this middleware will gracefully catch and report errors encountered when polling an inner body, and via an `R`-typed recovery strategy provided by the caller, will attempt to map the error to a gRPC status code denoting an error.

before we upgrade to hyper 1.0 in service of linkerd/linkerd2#8733, we add some test coverage to ensure that we preserve the behavior of this middleware.

see:
* linkerd/linkerd2#8733
* #3614.

for historical context on this tower layer, see:
* #222
* #1246
* #1282

---

* refactor(http/retry): outline `ForwardCompatibleBody<B>`

in #3559 (4b53081), we introduced a backported `Frame<T>` type, and a
`ForwardCompatibleBody<B>` type that allows us to interact with a
`http_body::Body` circa 0.4.6 in terms of frame-based interfaces that
match those of the 1.0 interface.

see linkerd/linkerd2#8733 for more information on upgrading hyper.

in #3559, we narrowly added this as an internal submodule of the
`linkerd-http-retry` library. these facilities however, would have
utility in other places such as `linkerd-app-core`.

this commit pulls these compatibility shims out into a
`linkerd-http-body-compat` library so that they can be imported and
reused elsewhere.

Signed-off-by: katelyn martin <kate@buoyant.io>

* nit(http/body-compat): tidy `combinators` imports

Signed-off-by: katelyn martin <kate@buoyant.io>

* refactor(app/core): hoist `errors::code_header` helper

Signed-off-by: katelyn martin <kate@buoyant.io>

* refactor(app/core): `l5d-*` constants are headers

these are header values. `http::HeaderName` has a const fn constructor,
so let's use that.

Signed-off-by: katelyn martin <kate@buoyant.io>

* refactor(app/core): grpc constants are headers

Signed-off-by: katelyn martin <kate@buoyant.io>

* refactor(app/core): hoist `l5d-` and `grpc-` constants

Signed-off-by: katelyn martin <kate@buoyant.io>

* refactor(app/core): outline `ResponseBody` middleware

we'll add a few tests for this middleware shortly.

this commit moves this middleware out into its own submodule.

Signed-off-by: katelyn martin <kate@buoyant.io>

* refactor(app/core): encapsulate `ResponseBody` enum

for other body middleware, we hide inner enum variants and their
constituent members by using the "inner" pattern.

this commit tweaks `ResponseBody` to follow suit, such that it now holds
an `Inner`, but does not expose its passthrough and rescue variants to
callers.

Signed-off-by: katelyn martin <kate@buoyant.io>

* docs(app/core): document `ResponseBody<R, B>`

this adds a small documentation comment describing what this type does.

Signed-off-by: katelyn martin <kate@buoyant.io>

* refactor(app/core): a unit test suite for rescue body

this commit introduces a test suite for our error recovery middleware.

this body middleware provides a mechanism to "rescue" errors, gracefully
mapping an error encountered when polling a gRPC body into e.g. trailers
with a gRPC status code.

before we upgrade this middleware in service of linkerd/linkerd2#8733,
we add some test coverage to ensure that we preserve this middleware.

Signed-off-by: katelyn martin <kate@buoyant.io>

---------

Signed-off-by: katelyn martin <kate@buoyant.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants