feat(upstream): support request-scoped custom HTTP retry statuses - #120
Merged
Merged
Conversation
Expose next_upstream masks for HTTP 400, 401 and 402 so that set_next_upstream() accepts these status codes, enabling failover on them (e.g. ai-proxy-advanced failover_criteria). Requires the matching nginx core flags NGX_HTTP_UPSTREAM_FT_HTTP_400/401/402. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
oowl
force-pushed
the
ai-proxy-advanced-fallback-401
branch
from
September 21, 2026 07:58
53267ff to
fb4fadc
Compare
fffonion
reviewed
Sep 23, 2026
| ngx_str_t grpc_authority; | ||
| ngx_http_log_handler_pt orig_log_handler; | ||
| ngx_uint_t next_upstream; | ||
| u_char next_upstream_statuses[25]; /* HTTP 400..599 */ |
Contributor
There was a problem hiding this comment.
this seems static memory footprint debt even for people that not using it (API GW for example), can we improve it?
fffonion
approved these changes
Sep 24, 2026
spacewander
approved these changes
Sep 24, 2026
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.
Summary
Allow
resty.kong.upstream.set_next_upstream()to accept custom HTTP error statuses fromhttp_400throughhttp_599, without adding a C constant for each new status. This enables the opt-in 400/401/402 failover in Kong/kong-ee#19297, targeting AIGW 2.2.Custom statuses are copied into a 25-byte bitmap owned by the request context. Later setter calls replace both the mask and bitmap, failed validation preserves the previous criteria, and
offoverrides all retry criteria. Existing native status masks retain their behavior. The old C setter remains available and clears any custom statuses.The matching nginx patch queries the bitmap and uses one generic custom-status flag. Custom 4xx statuses advance without marking the peer failed; custom 5xx statuses mark it failed. Real response status codes and nginx's retry limits, timeout, non-idempotent and body-buffering checks are preserved.
Dependency
Requires
nginx-1.27.1_26-upstream-next-dynamic-status.patchfrom Kong/kong-ee#19297. The patch and module must be built together. No per-statusHTTP_400/401/402constants are required.Validation
off, exhaustion, native 429 accounting, retry counts/timeouts, POST body replay and streamed bodies.