-
Notifications
You must be signed in to change notification settings - Fork 271
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
Set grpc-status headers on dispatch errors #416
Conversation
When the proxy encounters errors, it sets the HTTP response code. However, gRPC applications do not honor HTTP response codes and, instead, rely on the `grpc-status` response header to be set. Since the proxy has specialized gRPC support in some other places (namely metrics/classification), we should attempt to behave well with gRPC applications. This change extracts the `errors` module from app-core into a new `error-respond` crate, which exposes a simplified trait interface. `app::core::errors` now provides an implementation for these traits that is able to translate proxy-internal errors to gRPC status codes and messages. Fixes linkerd/linkerd2#3493
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 — i don't think any of the minor nits i commented on are critical
linkerd/error-respond/src/lib.rs
Outdated
@@ -0,0 +1,89 @@ | |||
//! Layer to map service errors into responss |
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.
typo: responses
); | ||
code | ||
} else if error.is::<IdentityRequired>() { | ||
let code = Code::FailedPrecondition; |
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.
I don't think anything relied on the Forbidden
status code, but is this changing the error type for required tap identity? Before in require_identity_on_endpoint
, if the condition failed we returned an error::StatusError
with a Status = Forbidden
. Now it's a gRPC status code FailedPrecondition
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.
It's still a FORBIDDEN
for HTTP requests; but is now a FailedPrecondition
for gRPC requests.. reading through the descriptions i thought this was the closest ft.
This release fixes a bug in the proxy's logging subsystem that could cause the proxy to consume memory until the process is OOMKilled, especially when the proxy was configured to log diagnostic information. The proxy also now properly emits `grpc-status` headers when signaling proxy errors to gRPC clients. This release upgrades the proxy's Rust version, the `http` crate dependency to address RUSTSEC-2019-0033 and RUSTSEC-2019-0034, and the `prost` crate dependency has been patched to address RUSTSEC-2020-02. --- * internal: Introduce a locking middleware (linkerd/linkerd2-proxy#408) * Update to Rust 1.40 with new Cargo.lock format (linkerd/linkerd2-proxy#410) * Update http to v0.1.21 (linkerd/linkerd2-proxy#412) * internal: Split retry, http-classify, and http-metrics (linkerd/linkerd2-proxy#409) * Actually update http to v0.1.21 (linkerd/linkerd2-proxy#413) * patch `prost` 0.5 to pick up security fix (linkerd/linkerd2-proxy#414) * metrics: Make Counter & Gauge atomic (linkerd/linkerd2-proxy#415) * Set grpc-status headers on dispatch errors (linkerd/linkerd2-proxy#416) * trace: update `tracing-subscriber` to 0.2.0-alpha.4 (linkerd/linkerd2-proxy#418) * discover: Warn on discovery error (linkerd/linkerd2-proxy#422) * router: Avoid large up-front allocations (linkerd/linkerd2-proxy#421) * errors: Set correct HTTP version on responses (linkerd/linkerd2-proxy#424) * app: initialize tracing prior to parsing env vars (linkerd/linkerd2-proxy#425) * trace: update tracing-subscriber to 0.2.0-alpha.6 (linkerd/linkerd2-proxy#423)
This release fixes a bug in the proxy's logging subsystem that could cause the proxy to consume memory until the process is OOMKilled, especially when the proxy was configured to log diagnostic information. The proxy also now properly emits `grpc-status` headers when signaling proxy errors to gRPC clients. This release upgrades the proxy's Rust version, the `http` crate dependency to address RUSTSEC-2019-0033 and RUSTSEC-2019-0034, and the `prost` crate dependency has been patched to address RUSTSEC-2020-02. --- * internal: Introduce a locking middleware (linkerd/linkerd2-proxy#408) * Update to Rust 1.40 with new Cargo.lock format (linkerd/linkerd2-proxy#410) * Update http to v0.1.21 (linkerd/linkerd2-proxy#412) * internal: Split retry, http-classify, and http-metrics (linkerd/linkerd2-proxy#409) * Actually update http to v0.1.21 (linkerd/linkerd2-proxy#413) * patch `prost` 0.5 to pick up security fix (linkerd/linkerd2-proxy#414) * metrics: Make Counter & Gauge atomic (linkerd/linkerd2-proxy#415) * Set grpc-status headers on dispatch errors (linkerd/linkerd2-proxy#416) * trace: update `tracing-subscriber` to 0.2.0-alpha.4 (linkerd/linkerd2-proxy#418) * discover: Warn on discovery error (linkerd/linkerd2-proxy#422) * router: Avoid large up-front allocations (linkerd/linkerd2-proxy#421) * errors: Set correct HTTP version on responses (linkerd/linkerd2-proxy#424) * app: initialize tracing prior to parsing env vars (linkerd/linkerd2-proxy#425) * trace: update tracing-subscriber to 0.2.0-alpha.6 (linkerd/linkerd2-proxy#423)
When the proxy encounters errors, it sets the HTTP response code.
However, gRPC applications do not honor HTTP response codes and,
instead, rely on the
grpc-status
response header to be set. Since theproxy has specialized gRPC support in some other places (namely
metrics/classification), we should attempt to behave well with gRPC
applications.
This change extracts the
errors
module from app-core into a newerror-respond
crate, which exposes a simplified trait interface.app::core::errors
now provides an implementation for these traits thatis able to translate proxy-internal errors to gRPC status codes and
messages.
Fixes linkerd/linkerd2#3493