fix(proxy): return 504 for upstream timeouts in fail_to_proxy per RFC 9110 - #996
Open
Aditya-9-6 wants to merge 2 commits into
Open
fix(proxy): return 504 for upstream timeouts in fail_to_proxy per RFC 9110#996Aditya-9-6 wants to merge 2 commits into
Aditya-9-6 wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #980
Problem
In
pingora-proxy/src/proxy_trait.rs,fail_to_proxycurrently maps all upstream-sourced errors to502 Bad Gateway:Consequently, upstream deadline expiries (
ConnectTimedout,TLSHandshakeTimedout,ReadTimedout,WriteTimedout) surface to downstream clients as502 Bad Gateway.Per RFC 9110 §15.6.6:
Both NGINX and Envoy map upstream connection, read, and write deadline expiries to 504. In Pingora, returning 502 prevents monitoring and clients from distinguishing between slow/hung upstreams and broken/refused upstreams.
Solution
default_fail_to_proxy_status(e: &Error) -> u16:Extracts the default status mapping into a public helper function so custom proxy implementations can reuse the standard mapping without copying the whole match structure.
ConnectTimedout,TLSHandshakeTimedout,ReadTimedout,WriteTimedout) now map to504 Gateway Timeout.502 Bad Gateway.Added unit tests in
proxy_trait.rscovering all upstream timeout branches, non-timeout upstream failures, downstream disconnections (status 0), and explicit HTTPStatus preservation.