Repository navigation
Extract admitted-error finalization from demo RC - #464
ChristianPavilonis wants to merge 12 commits into
Conversation
|
CREATOR: From the server-side identity plan (IABTechLab/trusted-server#1559, |
prk-Jr
left a comment
There was a problem hiding this comment.
Approving. The finalizer is a narrow, default-off addition. It runs only on rendered admitted dispatch errors, gets the adapter-owned GeoOutcome captured before handlers can mutate extensions, and afterwards restores the rendered status, the required protocol headers (Allow, Retry-After) and the body-overflow marker. The egress framing layer independently reapplies required headers and overflow Retry-After suppression, so the in-app restoration is defense in depth. With no finalizer installed, the code path is unchanged.
Verification at 3b0d6606:
cargo test -p edgezero-core --libpasses 1188 tests, including the 4 finalizer tests.cargo clippy -p edgezero-core --all-targets --all-features -D warningsandcargo fmt --checkare clean, on the pinned 1.98.1 toolchain.- Broken-code checks, each run against the finalizer tests:
- Dropping the status restore fails 3 tests.
- Dropping the overflow-marker reinsert fails the overflow test.
- Dropping the required-header restore and reinsert fails 2 tests.
- The branch merges cleanly with the current
feature/kv-geoiptip (7580806a). There, the Fastly and Cloudflare request paths calldispatch_admitted_with_geo, so the finalizer will receive their platform geo outcome as intended.
Non-blocking:
- Hosted CI is red at this head.
axum testsfailed intests/production_hosting.rs(native_ids_remain_private_under_mutation_and_concurrent_hosting_requests). The host stopped withrunner_failedbefore readiness, andcargo testonly reports that failure. This looks like the fixture port-reservation race fixed on the base by38cf420b(respawn a production hosting fixture that loses its port), which isn't merged into this branch yet. Nothing in this PR touches that path, and no finalizer is installed there. Please merge the base forward, rerun, and refresh the test plan. It currently cites an all-green run atdfec0db3, which is no longer the head. - A test assertion can't fail (inline).
| assert_eq!(response.status(), StatusCode::SERVICE_UNAVAILABLE); | ||
| assert_eq!(response.headers()["retry-after"], "60"); | ||
| assert_eq!(response.headers()["x-geo-finalized"], "yes"); | ||
| assert_eq!(provider_calls.load(Ordering::SeqCst), 1); |
There was a problem hiding this comment.
Nit (non-blocking): the only call to CountingGeoProvider is the test's own provider.resolve(...) a few lines above. The provider is never given to the App or the router, so this assertion is always 1. It can't catch a finalizer path that resolves geography again. The handler-side mutation checks (forged cloudfront-viewer-country header, an inserted GeoOutcome::NoSelection) are what actually prove the finalizer sees the original outcome. Consider dropping the counter, or renaming the test to describe what it does check, e.g. admitted_error_finalizer_receives_dispatch_geo_despite_handler_mutation.
Summary
App::set_admitted_error_response_finalizer, an optional synchronous callback that runs once on each rendered admitted dispatch error, after the configured error renderer. It receives the request's existingGeoOutcomeand&mut Response, so an application can add the headers its middleware adds toOkresponses.89c279b59b75eb33b96eb30a35f78bf933762f34. It doesn't redesign response ownership or Geo policy, and adds no body carrier, transport, timer policy or production Geo provider.Changes
crates/edgezero-core/src/app.rsdispatch_admitted_with_geocalls it after rendering an admitted error and restores status and required headers. Three regression tests.docs/guide/native-geo.mdCloses
Closes #518
Refs #461. Integration RC #462 includes this PR at
96c21d731501370044f11ca5832e85701e79a421.Stack
Based on #517 (
feat/portable-client-info). GitHub stack #539 orders this PR before #524. The finalizer runs in the shared admitted-dispatch path used by both Geo and ClientInfo.The server-side identity plan (IABTechLab/trusted-server#1559, Part A and Part C) still says to drop #454's prototype commits and base this PR on #439's branch. That conflicts with #510 and is still open.
Head is
dfec0db36401831188ee15db8f17e40084b23827. The commits after96c21d73are merges of the parent branches. The PR's changed lines are identical to89c279b5.feature/kv-geoiphas since moved ahead by eight commits that aren't merged here yet, including2c41968b(Fastly and Cloudflare Geo throughctx.geo()) and7ef4766d(Axum Geo from the manifest).Test plan
All four
admitted_error_finalizer_tests passed after merging #517.dfec0db3: all 29 checks pass, including workspace tests, Axum, Fastly, Cloudflare and Spin tests and clippy,cargo fmtand docs formatting.cargo test -p edgezero-core --lib admitted_error_finalizeratdfec0db3: 3 passed.96c21d73): Core 1,174 default-parallel tests, Axum 488 and production-hosting 36 serial cases, scoped Clippy and formatting. These results are tied to that revision.Earlier local runs saw native parallel timing failures that nobody has classified. This PR doesn't relax their assertions or claim to fix them.
Not covered: ALB credential validation, cloud ingress, browser behavior and deployment.
Ready for review. It merges with the stack above, not directly into main.