Skip to content

chore(clippy): use as_chunks for fixed-size chunking in tests - #1808

Merged
FlorentinDUBOIS merged 2 commits into
mainfrom
chore/clippy-as-chunks
Oct 2, 2026
Merged

FlorentinDUBOIS merged 2 commits into
mainfrom
chore/clippy-as-chunks

Conversation

@FlorentinDUBOIS

@FlorentinDUBOIS FlorentinDUBOIS commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Clippy 1.98 and newer (clippy::chunks_exact_to_as_chunks) reject chunks_exact with a constant chunk size. cargo +1.99.0 clippy --all-features --all-targets -- -D warnings reported three hits on origin/main (8205812):

  • lib/src/protocol/mux/h2.rs: the drain_window_updates_into unit test, chunks_exact(13)
  • e2e/src/mock/raw_h2_response_backend.rs: the mock's SETTINGS parser, chunks_exact(6)
  • e2e/src/tests/h2_window_update_tests.rs: the test peer's SETTINGS parser, chunks_exact(6)

Each now iterates as_chunks::<N>().0. slice::as_chunks is stable since Rust 1.88, below the 1.93.1 MSRV and pinned toolchain. It drops the remainder just as chunks_exact does, so the behaviour is the same. Only test and mock code changes. CHANGELOG entry added under Unreleased / Fixed, following the earlier chore(clippy) entry (#1663).

Validation

  • cargo +nightly fmt --all --check: passes
  • cargo +1.99.0 clippy --all-features --all-targets -- -D warnings: passes (it failed with the 3 hits above before)
  • cargo +1.93.1 clippy --all-features --all-targets --locked -- -D warnings: passes
  • cargo +1.93.1 test -p sozu-lib --lib --all-features --locked: 1568 passed
  • cargo +1.93.1 test -p sozu-e2e --features opentelemetry,splice,simd --locked -- tests::h2_security_header_injection tests::h2_priority_rearm_tests tests::h2_window_update_tests: 27 passed

Clippy 1.98 and newer (`clippy::chunks_exact_to_as_chunks`) reject
`chunks_exact` with a constant chunk size, so
`cargo clippy --all-features --all-targets -- -D warnings` failed on
1.99.0 with three hits:

- lib/src/protocol/mux/h2.rs: the `drain_window_updates_into` unit test
  splitting WINDOW_UPDATE frames with `chunks_exact(13)`;
- e2e/src/mock/raw_h2_response_backend.rs: the mock's SETTINGS parser,
  `chunks_exact(6)`;
- e2e/src/tests/h2_window_update_tests.rs: the test peer's SETTINGS
  parser, `chunks_exact(6)`.

Each now iterates `as_chunks::<N>().0`. `slice::as_chunks` is stable
since Rust 1.88, below the 1.93.1 MSRV and pinned toolchain. Like
`chunks_exact`, the remainder is ignored, so the semantics are
identical. Test and mock code only, no behaviour change.

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS merged commit 1656cac into main Oct 2, 2026
15 of 25 checks passed
FlorentinDUBOIS added a commit that referenced this pull request Oct 3, 2026
…1809)

Audit of the docs, `bin/config.toml` and `os-build/config.toml` against everything merged on `main` from 2026-10-01 to 2026-10-03 (43 commits, #1724 through #1808). Most of the new keys were already documented by their own PRs (`max_connection_attempts`, `h2_stream_refusal_percent`, health check `mode`/`accepted_statuses`, the raised flood defaults, the 16 MiB connection window). This PR fixes what was still stale.

| Area | Where | Was | Now |
|---|---|---|---|
| #1806 | `bin/config.toml`, `os-build/config.toml` answer comments | 503 only for "no backend available"; "504 means the backend timed out" | 503 also when every attempt failed; 504 = connected backend silent or frontend timeout while waiting; connect timeout fails over |
| #1806 | `bin/config.toml` `max_connection_attempts` | connect timeout always fails over | a TCP session whose connect times out is closed |
| #1806 | `doc/debugging_strategies.md` | 503 after a circuit breaker of 3 failed connections; ERROR log lines, one that no longer exists | `max_connection_attempts` (default 5), `backend.connect.retries_exhausted`, real TCP log levels and text |
| #1806 | `doc/configure.md` `front_timeout` / `connect_timeout` rows | "inactivity for a request to connect" | time to establish a backend connection; HTTP fails over, TCP closes; H1 failover bound by `front_timeout` |
| #1806 | `doc/configure.md` `client_timeout_during_response`, `backend_timeout`, `http.503.errors` | "connection-level slowness", "circuit breaker" | failover case included; established connection only; attempt budget |
| #1806 | `LIFECYCLE.md` backend timer | 504 for any linked stream | established connection only |
| #1806 | `cli.rs` help, `doc/configure_cli.md` | "answered 503" | "or a TCP session is closed" |
| #1756 | `doc/configure.md` flood metrics | RST lifetime rows described as absolute ceilings; no `window_update_stream0_window` row | floor-and-ratio semantics; row added |
| #1756/#1798 | `doc/architecture.md`, `doc/h2_mux_internals.md` | 6 / 13 `H2FloodConfig` thresholds | 14, with `h2_stream_refusal_percent` |
| #1756 | `doc/configure_admin_ops.md` | "halve" example 50/25 (old defaults); H2 knobs HTTPS only | 1000/500; HTTP and HTTPS; `h2.flood.stream_refused` |
| #1752 | `doc/configure.md` glitch tuning | "1 MiB window ... about 64" frames | 64 KiB stream window, about four |
| #1805 | `doc/health_checks.md` | `remove` resets backends to healthy; DOWN logs an error; `load_balancing.rs::BackendList::healthy` | backends keep their last state (see note); warning; `BackendList::select_tiers` in `backends.rs` |
| #1805 | `doc/metrics.md` | health-check counters "per cluster" | unlabelled |
| #1805 | `doc/configure_cli.md` | no health-check section | short section, `--mode`, `--probe-timeout` vs global `--timeout` |
| #1746 | `cli.rs` `--load-balancing-policy`, `bin/config.toml`, proto comment | HRW/MAGLEV key = UDP flow key | UDP affinity key (source IP, or IP and port) |
| UDP | `doc/configure.md` | hot upgrade drains flows bounded by idle timeout; `udp.flows.evicted` reasons | soft-stop closes flows at once; listener removal/soft-stop/abort added |
| #1770 | `doc/udp_simulation.md` | no per-source limits | in reconfig storms and the invariant list |
| #1743 | `doc/lifetime_of_a_session.md` | keep-alive backend always reused | unless its backend was removed |
| older | `command.proto` update messages | `h2_stream_shrink_ratio >= 1` | `>= 2`, as validated in `state.rs` |
| #1806 | e2e shuffle-sharding doc comment | "three connection attempts" | `max_connection_attempts` (5 by default) |

Reported here, not changed in this PR:
- `sozu cluster health-check remove` does not reset backends a probe marked DOWN (`remove_health_check_state` skips the reset that `set_health_check_config(None)` does), so they stay out of rotation until the cluster is added again. The doc now describes this. It looks like a code bug.
- `sozu top`'s H2 pane reads `h2.flood.violation.{rapid_reset,made_you_reset,ping,settings,priority,continuation}`, which the detector never emits (it emits `rst_stream_pre_response_lifetime`, `ping_window`, ...). Only `glitch_window` matches, and `h2.flood.stream_refused` is not shown.
- `h2_flood_detector.rs` comments still refer to a 1 MiB connection window, and the `h2_stream_idle_timeout_seconds` proto comment says "Default: 30" where the value inherits `back_timeout`.
- `connections.rejected_per_cluster_ip` is documented as also counting TCP rejections; only the HTTP 429 path increments it.

Validation:
- `sozu config check` passes on `bin/config.toml`, on a copy with every commented key under review uncommented (global and cluster `max_connection_attempts`, the H2 block, the health check block), and on `os-build/config.toml` with local state/socket paths. Negative controls (`max_connection_attempts = 0`; `expected_status = 200` next to `accepted_statuses`) are rejected.
- `cargo +1.93.1 test -p sozu-command-lib --all-features --locked`: 235 passed.
- `cargo +1.93.1 test -p sozu --bin sozu --locked`: 124 passed (including the `--load-balancing-policy` help tests).
- `cargo +nightly fmt --all --check` and `python3 .github/scripts/check_doc_citations.py --root . --base origin/main` are clean.



Signed-off-by: Florentin Dubois <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant