envoyproxy/envoy

[Feature Request] Support adding response flags and response code details in custom response headers

Open

#11,648 创建于 2020年6月18日

在 GitHub 查看
 (11 评论) (2 反应) (1 负责人)C++ (5,373 fork)batch import
area/httpenhancementhelp wanted

仓库指标

Star
 (27,997 star)
PR 合并指标
 (平均合并 8天) (30 天内合并 378 个 PR)

描述

Description: Envoy supports adding a set of custom request/response headers and also dynamic values in those headers. By adding headers with RESPONSE_CODE_DETAILS and RESPONSE_FLAGS, we provide additional context to clients whether the response code has come from Envoy or the upstream backend, as well as why the request has failed.

Envoy currently has some support for RESPONSE_CODE_DETAILS and RESPONSE_FLAGS as custom headers, but we observed that in cases where the Envoy sidecar sends a local 503 response, for example, when there are no healthy upstreams, custom headers are not getting added to the responses. Investigating the issue, we noticed that finalizeResponseHeaders are not called when the Envoy Router sendLocalReply.

callbacks_->sendLocalReply(Http::Code::ServiceUnavailable, "no healthy upstream", modify_headers_, absl::nullopt, StreamInfo::ResponseCodeDetails::get().NoHealthyUpstream);

A possible solution might be to call finalizeResponseHeaders in modify_headers_ for cases that Envoy sends a local reply.

[optional Relevant Links:] Custom request/response header Envoy doc: https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_conn_man/headers#custom-request-response-headers https://www.envoyproxy.io/docs/envoy/latest/configuration/observability/access_log/usage#config-access-log-format-response-flags

贡献者指南