gateway-api icon indicating copy to clipboard operation
gateway-api copied to clipboard

Support a ResponseBodyModifier filter

Open arkodg opened this issue 2 years ago • 10 comments

What would you like to be added: A filter within HTTPRoute to allow the user to specify the configuration to return a custom response body based on the status code of the response

Why this is needed: To return a more informative and visually pleasing response whenever errors such as 404 or 5XX are encountered in the data plane or backend

NGINX supports this https://www.jajaldoang.com/post/nginx-custom-error-response/ Emissary (based on Envoy) supports this https://www.getambassador.io/docs/emissary/latest/topics/running/custom-error-responses HAProxy supports this https://www.haproxy.com/blog/serve-dynamic-custom-error-pages-with-haproxy/

arkodg avatar May 05 '23 18:05 arkodg

Do we really need it based on the response? And not just a static response based on request?

We are pretty quickly going to divulge into needing to do the ~full HTTPRoute matching on the response IMO, which is not great.

Even serving a static response is tricky. We don't want folks putting 10MB pages into YAML for example

howardjohn avatar May 05 '23 18:05 howardjohn

@howardjohn this is specific to return a custom response based on bad statuses (like 5XX) linking some open issues from users in other implementations

  • Istio - https://github.com/istio/istio/issues/10543
  • Contour - https://github.com/projectcontour/contour/issues/320

arkodg avatar May 05 '23 19:05 arkodg

Both of those issues are actually about customizing response codes return from the proxy for various things. The issue sounds like its asking to look at the backend's response to determine the response though?

Big difference, IMO, between customizing filter-driven responses and backend responses.

howardjohn avatar May 05 '23 19:05 howardjohn

sure we can help the author, filter based on local reply or response from backend

some more error pages on the web to highlight the use case

  • when I pass a bad path to Docker Hub - https://hub.docker.com/blah
  • when I pass a bad path to Google - https://google.com/blah

arkodg avatar May 05 '23 19:05 arkodg

Not necessarily saying we shouldn't do this, but as some more data points: the 404 case can be done today by providing a "match anything" ('default backend' in Ingress terms) that does whatever you want (in this case, return a 404 page)

On Fri, May 5, 2023 at 12:44 PM Arko Dasgupta @.***> wrote:

sure we can help the author, filter based on local reply or response from backend

some more error pages on the web to highlight the use case

  • when I pass a bad path to Docker Hub - https://hub.docker.com/blah
  • when I pass a bad path to Google - https://google.com/blah

— Reply to this email directly, view it on GitHub https://github.com/kubernetes-sigs/gateway-api/issues/1998#issuecomment-1536699806, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEYGXI7LQJP4DNKRWVULODXEVKBTANCNFSM6AAAAAAXXPALH4 . You are receiving this because you were mentioned.Message ID: @.***>

howardjohn avatar May 05 '23 19:05 howardjohn

the default backend approach can handle these cases

  • route/rule to backend not found

but cannot handle these cases

  • backend responded with 5XX probably because an internal method/API call timed out
  • backend responded with a 404 because the resource wasn't found

arkodg avatar May 05 '23 20:05 arkodg

the default backend approach can handle these cases

  • route/rule to backend not found

but cannot handle these cases

  • backend responded with 5XX probably because an internal method/API call timed out
  • backend responded with a 404 because the resource wasn't found

and more case:

  • Response body needs to be encrypted
  • Response body needs to be compress

RWDai avatar May 09 '23 07:05 RWDai

Sounds good, should be proposed as a GEP.

/triage accepted /kind gep

However we're currently focused on getting our GA release completed (see milestone v1.0.0) and this would not seem to be something that would need to block the release, so we're not ready to prioritize this and we would ask that v1.0.0 milestone issues get priority so we can focus there, and come back to this after the release.

shaneutt avatar Jul 03 '23 19:07 shaneutt

This issue has not been updated in over 1 year, and should be re-triaged.

You can:

  • Confirm that this issue is still relevant with /triage accepted (org members only)
  • Close this issue with /close

For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/

/remove-triage accepted

k8s-triage-robot avatar Jul 02 '24 20:07 k8s-triage-robot

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Sep 30 '24 21:09 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle rotten
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar Oct 30 '24 21:10 k8s-triage-robot

Envoy Gateway just added support for this in v1.2, here's an example

arkodg avatar Nov 11 '24 22:11 arkodg

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

k8s-triage-robot avatar Dec 11 '24 23:12 k8s-triage-robot

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

k8s-ci-robot avatar Dec 11 '24 23:12 k8s-ci-robot