Repository navigation
docs(mux): name the remaining L7Proxy::backends caller - #1693
Merged
Merged
Conversation
LIFECYCLE.md section 3.2 said `L7Proxy::backends` "has no caller left" and the CHANGELOG entry for the BackendDialer refactor said it "now has no caller". Both are wrong: `Mux::dial_backend` (lib/src/protocol/mux/mod.rs) still calls `proxy.borrow().backends()` to reach the `BackendMap` its `RegistryDialer` lends to `Router::backend_from_request`. The refactor moved that call out of router.rs; it did not remove it. Correct section 3.2, amend the sentence in the original entry, and add a correction note under Changed that names the caller. Documentation only. Refs #1684 Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
requested review from
Wonshtrum and
llenotre
as code owners
September 29, 2026 16:59
This was referenced Sep 29, 2026
FlorentinDUBOIS
added a commit
that referenced
this pull request
Sep 29, 2026
Refs #1684. This is the G1 = (a) step the maintainer chose in #1684 (comment). Based on `origin/main` `05ac4f9c`, which includes the merged #1693. This PR replaces #1693's §3.2 wording and its sentence in the #1550 CHANGELOG entry now that the method is gone. #1693's own correction entry stays as the record. The code is byte-identical to the tree validated below (`d9ce2a02` + this change): rebasing onto #1693 changed only `CHANGELOG.md` and `LIFECYCLE.md`. After the rebase I re-ran the four citation modes, the grep criterion and `cargo +nightly fmt --all -- --check`: citations exit 0, 0, 0 and 1 (the broken fixture), the grep exits 1, and fmt exits 0. ## What changes `L7Proxy::backends` had one production caller, `Mux::dial_backend`. On every dial it borrowed the proxy and cloned the `Rc<RefCell<BackendMap>>` to lend the map to `Router::backend_from_request`. - `Mux` gains `pub(crate) backends: Rc<RefCell<BackendMap>>`, filled at construction, and `Mux::dial_backend` takes `&RefCell<BackendMap>` from it. - `HttpSession::new` gains a `backends` parameter, and `HttpProxy::create_session` passes `Rc::clone(&self.backends)`. `create_session` runs under the proxy's `borrow_mut`, so the session cannot read the map through `proxy` at that point. - The expect-proxy upgrade (`HttpSession::upgrade_expect`) and the TLS upgrade (`HttpsSession::upgrade_handshake`) read `self.proxy.borrow().backends` once. `HttpProxy` and `HttpsProxy` set that field only in their constructors and never reassign it, so each session sees the same map as before. - Removed: the trait method (`lib/src/lib.rs`), its `HttpProxy` and `HttpsProxy` impls, and the `unreachable!` bodies in the `NoBackendProxy` and `RemoveOnlyProxy` test doubles (`mux/mod.rs`). - The routing fixture in `router.rs` keeps its own handle on the map: `RoutingFixture::backends`. - The 6 test `Mux` literals in `mux/mod.rs` and the one in `mux/h2.rs` get `backends: Rc::default()`. - Docs: `LIFECYCLE.md` §3.2, a new CHANGELOG ➖ Removed entry shaped like #1615's, and the #1550 entry's sentence is amended. No behaviour change and no new test: this moves a handle, and the existing dial tests cover the path. ## Measurements Measured with a throwaway probe, not committed. Before is `origin/main` `d9ce2a02`; after is this change on `d9ce2a02` (`e563388b`, identical code to the current head). | | before | after | |---|---|---| | `size_of::<MuxClear>()` | 4976 B | 4984 B | | `size_of::<MuxTls>()` | 6152 B | 6160 B | | heap allocations for one `Mux::dial_backend`, selection to linked stream (`test_allocations::allocations()` around the call in `a_dial_moves_the_planned_cluster_id_into_the_backend_connection`, 3 runs each) | 6, 6, 6 | 6, 6, 6 | Each dial now skips one `RefCell` borrow of the proxy and one `Rc` clone and drop. Each session pays one clone at construction. ## Validation All commands ran on the rebased head. Each exit code was checked directly, not through a pipe. - `git grep -qE 'fn backends|\.backends\(\)' -- lib/src/lib.rs lib/src/protocol/mux` -> exit 1, prints nothing - `cargo +nightly fmt --all -- --check` -> exit 0 - `cargo clippy --all-targets --locked -- -D warnings` -> exit 0 - `cargo clippy --all-targets --all-features --locked -- -D warnings` -> exit 0 - `RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features --locked` -> exit 0 - `cargo test --workspace --locked --exclude sozu-e2e` -> exit 0 (1820 passed, 0 failed, 17 ignored, all ignores already on main) - `RUSTFLAGS="--cfg tokio_unstable" cargo test -p sozu-sim --locked` -> exit 0 (31 passed) - `cargo test -p sozu-e2e --locked -- --skip tests::fuzz_tests::` -> exit 0 (502 passed) - `python3 .github/scripts/check_doc_citations.py` -> exit 0 - `python3 .github/scripts/check_doc_citations.py --base origin/main` -> exit 0 - `python3 .github/scripts/check_doc_citations.py --self-test` -> exit 0 - `python3 .github/scripts/check_doc_citations.py --root .github/scripts/testdata/citations` -> exit 1 (the broken fixture must fail) - `python3 .github/scripts/check_doc_citations.py --audit` -> output identical to the same run on an `origin/main` tree Reference sweep: `git grep -nE 'L7Proxy::backends|\.backends\(\)|fn backends\b' -- ':!CHANGELOG.md'` finds nothing left in code or docs. `bin/`, `e2e/` and `sim/` never implemented or called the method. Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
added a commit
that referenced
this pull request
Sep 29, 2026
…1694) ## Problem `UpdateHttpListenerConfig` / `UpdateHttpsListenerConfig` carry `elide_x_real_ip` and `send_x_real_ip`, and the workers apply them (`HttpListener::update_config` in `lib/src/http.rs`, and its HTTPS counterpart), but `ConfigState::update_http_listener` / `ConfigState::update_https_listener` (`command/src/state.rs`) never patched either field. On `origin/main` (`3ed6e8a6`; still true after #1686 re-keyed the listener maps): ``` $ git grep -n 'send_x_real_ip\|elide_x_real_ip' origin/main -- command/src/state.rs (no output) ``` So the main state kept the creation-time value: `sozu listener list` and `SaveState` showed it, and the state replayed to a new worker on upgrade/restart restored it, silently reverting the hot change. ## Fix Patch both flags in both functions, next to the other shared per-connection knobs (after `request_timeout`), with the same `if let Some(v)` form the worker uses. Absent fields preserve the recorded value. Control-plane only: no hot-path allocation or syscall. The insertion point is deliberately away from the tail of the two functions, where #1685 adds `forwarded_headers`, to keep rebasing trivial. ## Tests Rebased onto `05ac4f9c` (#1686 listener-by-interface, #1693). The field writes sit after `listener_key_for_update` resolves the listener, and the tests look listeners up by `ListenerKey::from(addr)`. RED/GREEN below re-run on the rebased tree. - `command/src/state.rs`: `update_http_listener_x_real_ip_patch_applied`, `update_http_listener_x_real_ip_absent_preserves_existing`, `update_https_listener_x_real_ip_patch_applied`, `update_https_listener_x_real_ip_absent_preserves_existing`, `update_listener_x_real_ip_survives_generate_requests_replay`. - `e2e/src/tests/tests.rs`: `test_x_real_ip_hot_update_survives_upgrade` — an HTTP listener starts with both flags off, a hot `UpdateHttpListener` turns both on, a spoofed `X-Real-IP: 1.2.3.4` request is checked on the old worker, then `Worker::upgrade` seeds a new worker from the harness's mirror `ConfigState` (the same `ConfigState::update_http_listener` the main process runs) and the same request is checked again. ### RED (fix reverted) ``` $ cargo test -p sozu-command-lib --locked x_real_ip test state::tests::update_https_listener_x_real_ip_patch_applied ... FAILED test state::tests::update_https_listener_x_real_ip_absent_preserves_existing ... FAILED test state::tests::update_http_listener_x_real_ip_absent_preserves_existing ... FAILED test state::tests::update_http_listener_x_real_ip_patch_applied ... FAILED test state::tests::update_listener_x_real_ip_survives_generate_requests_replay ... FAILED left: None right: Some(true) test result: FAILED. 0 passed; 5 failed; 0 ignored; 0 measured; 199 filtered out $ cargo test -p sozu-e2e --locked test_x_real_ip_hot_update_survives_upgrade test tests::tests::test_x_real_ip_hot_update_survives_upgrade ... FAILED after upgrade: spoofed X-Real-IP was not elided: left: Fail right: Success test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 506 filtered out ``` (The e2e "before upgrade" check passes on `main`: the worker applies the patch; only the upgraded worker reverts it.) ### GREEN ``` $ cargo test -p sozu-command-lib --locked x_real_ip test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 199 filtered out $ cargo test -p sozu-e2e --locked test_x_real_ip_hot_update_survives_upgrade test tests::tests::test_x_real_ip_hot_update_survives_upgrade ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 506 filtered out ``` ## Validation (each by its own exit code, all 0) - `cargo build --all-features` - `cargo clippy --all-features --all-targets -- -D warnings` - `cargo +nightly fmt --all -- --check` - `RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features --locked` - `cargo test -p sozu-command-lib` (204 passed), `cargo test -p sozu` (121 passed), `cargo test -p sozu-lib` (1358 passed) - e2e: `x_real_ip` (10 passed), `listener_update` (14 passed), `upgrade` (16 passed) - `check_doc_citations.py` `--self-test`, `--root .`, `--base origin/main`, `--audit --root .` ## Docs - `doc/configure.md`: the X-Real-IP section now states that the main state records the patch, so `listener list`, `SaveState` and upgrade replay carry it. - `CHANGELOG.md`: Unreleased / Fixed entry. ## Out of scope `sozu listener http|https update` exposes no CLI flag for either knob (only the protobuf patch does); unchanged here. Closes #1688 Signed-off-by: Florentin Dubois <[email protected]>
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.
Refs #1684 (step 1 of the
/goalprompt posted there: fix the record before the maintainer gate).What was wrong
lib/src/protocol/mux/LIFECYCLE.md§3.2 saidL7Proxy::backends"has no caller left", the CHANGELOG entry for theBackendDialerrefactor (#1340 Q12, second part) said it "now has no caller", and #1550's description counted.backends()inlib/+bin/as 2 → 0.Measured on
origin/mainat3ed6e8a6:Mux::dial_backendstill calls it to reach theBackendMapitsRegistryDialerlends toRouter::backend_from_request. The refactor moved the call out ofrouter.rs; it did not remove it. The claims that production references toL7ProxyandRc<RefCell<Backend>>inrouter.rswent to zero still hold.Change
LIFECYCLE.md§3.2 namesMux::dial_backendas the remaining production caller and points the removal question to h2 sans-io core perimeter: recap of Q6, Q7 and Q12 (from #1340) #1684.CHANGELOG.md: the sentence in the original entry is amended, and a correction note under 🔄 Changed names the caller and the measured count.Documentation only, no code change. Sweep:
git grep -n 'L7Proxy::backends' -- ':!CHANGELOG.md'hits only the corrected §3.2 line; no other copy of the claim indoc/or anyLIFECYCLE.md.doc/testing.mdis unaffected (no simulator change).Validation
git grep -q 'has no caller left' -- lib/src/protocol/mux/LIFECYCLE.md-> exit 1, prints nothingpython3 .github/scripts/check_doc_citations.py-> exit 0python3 .github/scripts/check_doc_citations.py --base origin/main-> exit 0python3 .github/scripts/check_doc_citations.py --self-test-> exit 0python3 .github/scripts/check_doc_citations.py --root .github/scripts/testdata/citations-> exit 1 (broken fixture fails, as required)python3 .github/scripts/check_doc_citations.py --audit-> exit 0; output byte-identical to the same run on anorigin/maintree (same 3 advisory findings, none added)