Repository navigation
Preserve outbound cache tags and borrowed readiness - #460
ChristianPavilonis wants to merge 14 commits into
Conversation
|
CREATOR: From the server-side identity plan (IABTechLab/trusted-server#1559, Part of #488 |
Brings #275 at e9ffaa8 and the refreshed heads of #499, #460, #406, #407, #409, #414, #422 and #439. Each PR merged the one below it, so this merge has no conflicts. Two edits fit #469 to #275, as #469's open review asks: - #469's ingress JA4 test calls into_core_request with one argument. #275 now passes the Axum outbound executor through that function, so the test gets an executor handle the way the other ingress tests do. - The Axum guide names EdgeZeroAxumService, which #275 removes and check_outbound_legacy_api.sh rejects. The guide now names only AxumDevServer::with_trusted_ja4_header.
The surrogate-key filter comment and the proxying guide's surrogate key and Image Optimizer notes name the SDK release they describe. SDK 0.13.3 leaves the surrogate key setter and the cache override handling unchanged from 0.13.1, and a service with Image Optimizer enabled still reaches the same optimizer send call, so the notes hold for the pinned 0.13.3.
|
For the identity integration branch (#495), I pushed
|
prk-Jr
left a comment
There was a problem hiding this comment.
Reviewed at cdd7c568 against base 27901990.
The borrowed readiness path (poll_ready, collect reusing it, HttpClient::time) looks correct. The Fastly SDK mapping matches fastly 0.13.3: set_surrogate_key switches the override from Pass to Override, and the guest-cache candidate converts the whole value with HeaderValue::to_str, so per-key filtering is what preserves valid neighbouring keys. Redirect replay and the Image Optimizer preflight both keep the tag correctly.
Blocking: a tag that can't be honoured is silently dropped rather than rejected.
The comment opening this PR (13 Nov) asked to validate tags (printable ASCII, non-empty) and to make Cloudflare reject tags instead of silently using the default. The later fix commit c191a9c5 does the opposite, and the PR does not say why:
- Fastly (
build_fastly_request/filter_surrogate_keys): keys outside 0x21..=0x7e are discarded with no error and no log. A value whose keys are all invalid becomes anOverridewith an empty key list. The request still dispatches and the response can still be cached, but it carries none of the caller's purge keys. - Cloudflare (
build_worker_request, andtagged_default_is_an_accepted_cache_noop): the tag is accepted and ignored. Workers Fetch keeps its default caching, so the response can be cached without the purge identity the caller asked for.
Consequence: a later purge by that key misses these objects, and stale content is served until normal expiry. The guide asks callers whose purge contract requires a tag to fail closed if HeaderValue conversion fails. Callers can't do that here, because conversion succeeds and the loss happens inside the adapter with no signal. Axum and Spin have no intermediary cache, so a no-op there is semantically fine. Cloudflare and partially-invalid Fastly values are different.
Minimal correction, matching the existing preflight pattern that already rejects tagged and Image Optimizer requests before I/O:
- Validate
PlatformDefaultWithSurrogateKeyinvalidate_for_dispatch. Returnbad_requestwhen the value contains a byte outside space or 0x21..=0x7e, or has no non-empty key. The Fastly filter then becomes unnecessary, or a debug assertion. - Make Cloudflare's
validate_supported_optionsreject the tagged variant, as it already does for Image Optimizer.
If the maintainers deliberately chose filter-and-ignore over that request, please record the decision in the PR and the guide instead. Then this becomes non-blocking.
Verification
cargo +1.98.1 test -p edgezero-core --all-targetspasses locally.- Two broken-code checks on core both failed as expected: replacing the replayed policy with
PlatformDefaultin redirect replay, and loosening the optimizer guard to reject onlyBypass. With the code restored, the tests pass again. - Hosted CI at this head is green except
cache-restore-seed, which is a compiler-cache publication failure unrelated to this change. The Fastly and Cloudflare evidence artifacts show the new tests passing on the repaired Viceroy and the Workers runner:tagged_cache_metadata_*,surrogate_key_filter_*,captured_begun_*andtagged_default_*. - I could not run the Fastly wasm tests locally, because the local Viceroy is too old. Hosted cache fill and purge remain out of scope, as the description says.
| OutboundCachePolicy::Bypass => request.set_pass(true), | ||
| OutboundCachePolicy::PlatformDefault => {} | ||
| OutboundCachePolicy::PlatformDefaultWithSurrogateKey(value) => { | ||
| request.set_surrogate_key(filter_surrogate_keys(value)); |
There was a problem hiding this comment.
Blocking (see the review summary): invalid keys are dropped here with no error or log. A value whose keys are all invalid still dispatches as a cacheable request with no purge keys. Validating the value in validate_for_dispatch (space or 0x21..=0x7e only, at least one non-empty key) would turn this silent loss into a pre-I/O bad_request.
| .with_method(worker_method(method)) | ||
| .with_redirect(RequestRedirect::Manual); | ||
| if cache_policy == OutboundCachePolicy::Bypass { | ||
| if matches!(cache_policy, OutboundCachePolicy::Bypass) { |
There was a problem hiding this comment.
Blocking (see the review summary): the tagged variant falls through to default Fetch caching, so the response can be cached without the purge identity the caller asked for. The 13 Nov requirement on this PR asked for Cloudflare to reject tags. validate_supported_options already rejects Image Optimizer the same way.
| keys without making private/no-store responses cacheable. The typed enum cannot also select | ||
| Bypass, whose pass mode would be cleared by Fastly's tag setter. Space-separated keys are | ||
| permitted; the Fastly adapter discards invalid individual space-delimited keys outside | ||
| printable ASCII 0x21..=0x7e before calling SDK 0.13.1, whose whole-value text conversion |
There was a problem hiding this comment.
Nit (non-blocking): this new paragraph names SDK 0.13.1, but the lockfile pins fastly 0.13.3, and e8e1d9cb updated the guide and code comment to 0.13.3. Please align this line too.
Summary
Depends on #275. Production changes are separate commits
251974d4anddc296073; publication head also enables ordinary CI for stacked bases and updates its exact trigger regression.Changes
Closes
Closes #459
Test plan
Production-source checks at exact
dc296073, with clean before/after fingerprints:cargo test --workspace --all-targets, default parallel: 2711 passed, one existing generated-workspace test ignored.cargo clippy --workspace --all-targets --all-features -- -D warnings.cargo fmt --all -- --check.cargo check --workspace --all-targets --features "fastly cloudflare spin".A separate adjacent all-feature parallel Axum sample failed the unchanged pending_chunked_forward timing bound at 205.459963 ms against 200 ms +5 ms. The default primary pass does not clear or establish the cause of that miss. No threshold or assertion changed.
Workers SDK cache-mode test code compiled for its real target but was not browser-executed. Fastly SDK object checks prove metadata mapping, not hosted purge, private-response caching or Image Optimizer acceptance. Tagged optimizer requests reject before I/O because that SDK path replaces custom cache metadata. Other adapters retain their existing platform-default/no-op behavior.
The application owns its timer-first cutoff: borrow readiness before expiry, stop driving when the timer wins, then use the existing non-driving snapshot/collection rules. This PR does not change that policy.
Checklist
Draft while fresh hosted checks and combined application acceptance run. No deployment or merge into main is part of this PR publication.