Repository navigation
fix(traffic-split): apply tls and keepalive_pool of the inline upstream - #14054
Merged
nic-6443 merged 5 commits intoOct 26, 2026
Merged
Conversation
traffic-split dropped `tls` when building the upstream from weighted_upstreams[].upstream, and set_by_route returned before applying the TLS settings to an upstream set by traffic-split. tls.client_cert_id was also resolved from the route's upstream only. As a result client certificates, tls.verify and tls.ca_certs of an inline upstream were ignored.
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
3 open issues
What changed in this PR
Fixes traffic-split so TLS settings on inline weighted_upstreams[].upstream are actually applied (mTLS client certs, verify, ca_certs, and client_cert_id), and adds docs + tests to prevent regressions.
Changes:
- Propagates
tlsfrom inline upstream definitions and applies TLS options even whentraffic-splitpre-setsapi_ctx.upstream_conf. - Resolves
tls.client_cert_idagainst the upstream actually selected (including inline upstreams). - Adds documentation and new regression tests covering inline-upstream TLS behaviors.
| File | Description |
|---|---|
| t/plugin/traffic-split5.t | Adds regression tests for inline-upstream TLS (mTLS + verify/CA). |
| docs/zh/latest/plugins/traffic-split.md | Documents tls as a supported inline-upstream field. |
| docs/en/latest/plugins/traffic-split.md | Documents tls as a supported inline-upstream field. |
| apisix/upstream.lua | Refactors/apply TLS setup via shared helper, including traffic-split path. |
| apisix/plugins/traffic-split.lua | Ensures inline upstream tls is carried into the built upstream config. |
| apisix/init.lua | Resolves client_cert_id from selected upstream (upstream_conf or matched). |
Review effort: Lite
Copilot stopped reviewing on behalf of
nic-6443 due to an error
October 20, 2026 11:25
AlinsRan
previously approved these changes
Oct 21, 2026
shreemaan-abhishek
previously approved these changes
Oct 21, 2026
nic-6443
dismissed stale reviews from membphis, shreemaan-abhishek, and AlinsRan
via
October 22, 2026 01:44
d39533e
…nline-upstream-tls
AlinsRan
approved these changes
Oct 26, 2026
shreemaan-abhishek
approved these changes
Oct 26, 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.


Description
The
tlsandkeepalive_poolsettings of an inlineweighted_upstreams[].upstreamintraffic-splitare ignored. Fortls, a client certificate is never sent andtls.verify/tls.ca_certshave no effect. Forkeepalive_pool, the connection pool to the upstream always uses the globalnginx_config.http.upstreamkeepalive settings instead.set_upstreamintraffic-splitbuilds the upstream from a fixed field list that included neither field. Forkeepalive_poolthat is the whole story: the balancer readskeepalive_poolstraight fromctx.upstream_confinset_current_peer, so carrying the field over is enough.For
tlsthere were two more gaps:set_by_routereturns early when traffic-split has already setupstream_conf, so the code that appliestls.verify,tls.ca_certsand the client certificate never ran for that upstream. That code is now a local function used by both paths.tls.client_cert_idwas always resolved from the route's upstream (matched_upstream), not from the inline upstream traffic-split picked.The docs now list
tlsandkeepalive_poolas supported fields of the inline upstream.New tests in
t/plugin/traffic-split5.tcoverclient_cert/client_key,client_cert_id,verify+ca_certs(both an unrelated CA and the CA that issued the upstream certificate) andkeepalive_poolon an inline upstream. Without the fix the first two get a 400 from the upstream (no client certificate), the unrelated CA gets a 200 instead of a verification failure, and the keepalive pool is created with the default size of 320 and keeps reusing the connection past the configuredrequestslimit. The matching-CA case is the positive counterpart: there is no global trusted certificate in the test config, so it only returns 200 when the inlineca_certsis what the verification uses.Checklist