Repository navigation
Conversation
|
@aram356 this PR covers the A3 part of #1575: after-response work on Axum is drained on SIGTERM, and Fastly keeps its post-send path. I've asked on #1575 to narrow its checklist:
After that, this PR can close #1575. The EdgeZero pin is now R2 ( |
Brings #1635, which now carries the identity integration chain (dhruv8sh's spine with the core identity app, the protected native Geo from #1532, the identity conformance suite from #1613, the certificate-check statement from #1616, the health and startup-failure contract from #1617 applied to the native production runner, and the creative-proxy identity disclosure policy from #1615), into the after-response task drain on SIGTERM. Docs: the production startup guide keeps the base's boundary, where a store the selected provider cannot prepare stops the process before it listens and a missing or invalid config value or secret leaves only the probes answering, and adds the PR's shared shutdown grace for in-flight requests and registered after-response tasks, its whole-task identity budget and its A2/A8 activation note. Tests: the PR's Axum after-response fixtures build GeoInfo with the base's optional city, continent, coordinates and metro code. The values are unchanged. Code merges without conflict: the PR's Axum fallback scheduling, its shared core runner and its Fastly post-delivery changes compile on the base's identity app, conformance hook and failure router. Cargo.lock is the base's plus the PR's trusted-server-identity-providers dev-dependency edge for the Axum crate.
Brings in, through #1636 (cf1102c): - dhruv8sh's spine on #1489: #1639 (738ba34), #1640 (46530d8), #1612 (36e35f8), #1628 (384a481) and #1623 (6fd236e). - #1531 (47411de) and #1532 (4d17086, which renames the native Geo profile variable to TRUSTED_SERVER__NATIVE_GEO_PROFILE_FILE). - #1613 (2415b7d), then #1616 (c142e87), #1617 (b91770e) and #1615 (255c390), restacked on #1613. - #1635 (06b4044), restacked on #1615, and #1636 (cf1102c). Each conflict was resolved in the PR that sits higher. This merge is clean.
|
For the identity integration branch (#1608), I pushed |
Adopt #1646's shared after-response runner and drop this PR's duplicate: core ec::after_response's AfterResponseLookups and run, and Axum's schedule_lookups and prepare_after_response_lookups. schedule_after_response now checks the follow-up permit before registering and returns whether it registered, so a skipped navigation never holds the shutdown drain. Port the SIGTERM drain and registration tests to that runner, deriving the re-executed child test name from the module path.
#1636 stays on #1646 and keeps #1646's shared after-response runner, as 5514190 adopts it. This merge brings #1646's chain head (b5a5f62), which merges #1642's chain head (f654f67) and, through it, the identity chain below: #1506's repin of EdgeZero to rc/identity at d063a8e7 and main's Fastly SDK 0.13.3 upgrade (#1671), #1488's hashed-email intake and owned request signals, #1489's mirrored UID expiry and request time, the identity spine, the Axum serving line (#1613, #1616, #1617, #1615, #1635, #1637 and #1627, with #1627's merge of #1625) and the held line from #1533 to #1642. The merge had no textual conflicts. #1646's chain head gives its AfterResponseLookups #1488's Referer and Accept-Language, which prepare_after_response_lookups copies and run_after_response_lookups passes to providers, so this PR's drain-test helper lookups_for, which copies the request signals the shared runner hands to providers, copies those two headers as well. The chain's #1489 also passes finalize a FinalizeRequest, so the drain tests' two ec_finalize_response calls pass one with the current request time, which the navigation's page-load write needs before it issues the follow-up permit the tests drive.
This brings in 1f054c6 from #1488, which forwards ortb2.user.ext.eids from the Prebid config into the auction EIDs, and a99dd66, a62601b, d1eb75f and 394892b from #1489, which cap mirrored UID expiry at 30 days from the UTC day start and pass the request time into finalize. They arrive through the chain's merges into #1639, #1640, #1612, #1628, #1623, #1531, #1532, #1533, #1534, #1536, #1535, #1537, #1539, #1538, #1540, #1566, #1624, #1641, #1642 and #1646, with #1646's move of the request time into IdentityApp::finalize. It also brings d5276ee, which publishes the native AWS runtime files without GNU mv -T, and Christian's merge 5597d3e of #1538 into #1540, through #1566's merge. The base now also carries the Axum serving line (#1613, #1616, #1617, #1615, #1635, #1637 and #1627), which #1533 merged, and #1627's b958107, which decodes the Spin discovery document with Response::json, and #1627's merge of #1625 (006b45e), which pins Wrangler for the Cloudflare smoke and CI. This PR already carries #1646's head 461aa0d, so the merge adds only #1646's new merge 166944769 of #1642 and the chain below it, including the identity conformance check that now strips the mirrored UID's exp. It also brings b2d4bfd from #1488, which records the known UID hashes on lookup results with a setter, so the provider IDs the write planner logs are not derived from them. Restacking on the Axum serving line conflicts in the Axum startup tests, where #1617 waits for /ready, since liveness stays up after a caught initialization failure, and this PR rewrites the wait to retry a port collision and to require the child's own ready lifecycle event. Axum startup tests: wait_ready keeps this PR's collision retry and lifecycle check, then probes #1617's /ready and returns the /health response once the child is ready. The fixture drains each child's output through this PR's log readers, so #1617's assert_serves_failure_router reaps the stopped child and reads those captured logs instead of collecting the pipes, which the readers already own. The base now also carries #1506's repin of EdgeZero to rc/identity at d063a8e7 and its merge of main's Fastly SDK 0.13.3 upgrade (#1671): fastly 0.13.3, url 2.5.9 and Viceroy 0.22.0. This PR now stacks on #1661 instead of #1646, so rc/identity can take both as plain merges. #1661 sits on #1656 and #1626, which sit on #1646, so the merge also brings #1626 (provider opt-outs and legacy EID expiry on Fastly and Axum), #1656 (the configurable Edge Cookie browser gate) and #1661 (refusing EC creation when a trusted JA4 contradicts the User-Agent). Fastly identity conformance fixture: #1661 records each scenario's runtime TLS JA4 through a RuntimeTlsJa4 middleware in place of derived device signals, takes the User-Agent from the scenario and drops the browser flag. This PR adds geo consent requests with their own trusted client IP settings and no browser device signals. The merge assembles the conformance app with #1661's middleware and keeps this PR's geo_configured flag and producer_settings. It sends the scenario's User-Agent unless the API request supplies one, and inserts the scenario's JA4 only for requests without a geo consent exchange, because this PR derived device signals only for those. The base now also carries #1627's 4d0c1a2, which renames the generic runtime KV store to trusted_server_runtime_kv, #1488's a610152 and 9104fd3, which add hashed-email intake for the LiveRamp and ID5 identity providers, #1646's aa31559, which gates identity writes for rejected clients, and #1626's d07f789, which withholds a mirrored UID while another source owner is opted out. Fastly conformance JA4: the rebuilt #1661 merge supplies a trusted Python JA4 behind the Chrome User-Agent for #1646's known non-browser API requests, and this PR inserts the scenario's JA4 only without a geo consent exchange, with its producer_settings. The merge keeps both: a known non-browser request gets the Python JA4, any other request the scenario's JA4 unless it is a geo consent exchange. This PR's head moves to e8015ca, its clean merge of #1646's aa31559, which the base already carries, so it adds no change beyond the base. Axum lib.rs: the base now carries #1636, through #1626's merge of it, whose after_response_drain_tests module sits where this PR adds its geo_conformance module. The crate keeps both test modules.
…1622 into rc/identity #1622 (244ca26) now carries the whole chain, each PR merging the one below it: - #1506 (c197404) repins EdgeZero to rc/identity at d063a8e7, which carries EdgeZero main's Fastly SDK 0.13.3 upgrade through every EdgeZero PR here, and merges Trusted Server main's upgrade (#1671): fastly 0.13.3, url 2.5.9 and Viceroy 0.22.0. - #1614, #1525, #1526, #1487 and #1488 take it in turn. #1488 also adds b2d4bfd, which records known UID hashes with a setter. - #1489, the identity spine (#1639, #1640, #1612, #1628 and #1623), #1531 and #1532. - The Axum serving line: #1613, #1616, #1617, #1615, #1635, #1637 and #1627, chained, with #1627's b958107 decoding the Spin discovery document with Response::json and #1627's merge of #1625, which brings #1625's Wrangler pin into the chain. - The held line on #1627: #1533, #1534, #1536, #1535, #1537, #1539, #1538, #1540, #1566, #1624, #1641, #1642 and #1646. #1646 keeps its own shared after-response runner in ec::app::lookups. - #1636 (72096cd) on #1646 (b5a5f62), draining Axum after-response identity tasks on SIGTERM through #1646's shared runner. - The EC route line on #1636: #1626 (067531e), which merges #1636, the draft #1656, #1661, #1662 and #1622, and through #1622's merge of it, #1620's round-6 head. Each conflict was resolved in the PR that sits higher. This merge is clean. Since the last update the chain also takes #1488's hashed-email intake (a610152 and 9104fd3) and its POST, body and header options for the status call (f063a76), #1627's split of the generic runtime KV store into trusted_server_runtime_kv (4d0c1a2), #1646's gate on identity writes for rejected clients (aa31559) its native container test of the failure router (4f4c036) and that test's header check on an ordinary route (71a573a), #1626's withholding of a mirrored UID while another source owner is opted out (d07f789), and #1617's description of the Axum startup failure router (6d174a8) and of the startup failures that still exit before listening (4c07cad). #1636 no longer sits in the Axum serving line; it arrives through #1626, which merges it on top of #1646. Its new head adopts #1646's after-response runner in place of the one rc/identity took with cf1102c. Cloudflare guide: #1627's merge of #1625 now keeps both #1625's tool version clause and #1627's TRUSTED_SERVER_RUNTIME_KV binding in the smoke paragraph, and fixes #1625's smoke script test for #1617's Python floor and Worker build, and #1537's merge fixes its ts stub for #1537's storage template step, so this merge needs no resolution.
|
For the identity integration branch (#1608), I pushed The merge had no textual conflicts. Two test edits in
In rc/identity this PR now arrives through #1626, which merges it, and rc/identity now uses #1646's after-response runner in place of the one it took with |
|
For the identity integration branch (#1608), I pushed #1660 now sits above this PR and sends its follow-up write through |
|
For the identity integration branch (#1608), I pushed |
dhruv8sh
left a comment
There was a problem hiding this comment.
Summary
This PR changes IdentityApp::schedule_after_response in three ways. It checks for a follow-up permit before registering work, it returns whether a task was registered, and that return value is now #[must_use]. It also adds a has_after_response_permit check that doesn't use up the permit, and it removes the unused _settings parameter from Fastly's run_after_response_lookups. Finally, it adds subprocess SIGTERM drain tests for Axum, plus some documentation. Nothing here blocks merging. The one concern is that the new subprocess tests might be flaky.
Non-blocking
🤔 thinking
- Subprocess drain tests rely on tight wall-clock margins — see inline at
crates/trusted-server-adapter-axum/src/after_response_drain_tests.rs:691
Cross-cutting / body-level findings
- 👍 The permit check matches the shared runner and fixes a drain stall — The new permit check does the same thing as the shared runner in
lookups.rs:307, which skips work when there is no permit. So the only change in behaviour is that skipped navigations no longer register a task that would do nothing. Those empty tasks can no longer hold up the shutdown drain, which is correct. The call sites in the Axum and Fastly adapters are updated consistently.
CI Status
- release scripts: PASS
- integration tests: PASS
- CLAUDE.md symlink guard: PASS
- format-docs: PASS
- integration tests (Fastly EC lifecycle): PASS
- health-startup (cloudflare): PASS
- health-startup (spin): PASS
- browser integration tests: PASS
- health-startup (axum): PASS
- format-typescript: PASS
- worker-deadlines (spin): PASS
- Native provider acceptance script: PASS
- trace runtime and browser acceptance: PASS
- vitest: PASS
- worker-deadlines (cloudflare): PASS
- cargo test (axum native): PASS
- cargo test (cross-adapter parity): PASS
- cargo test (ts CLI, native) (ubuntu-latest): PASS
- docs-proposal scripts: PASS
- record-provider-image: PASS
- cargo test: PASS
- cargo fmt: PASS
- HTML EOF runtime (Fastly): PASS
- cargo check/build/test (spin native + wasm32-wasip1): PASS
- CI Node pin guard: PASS
- ts dev lint domains (changed lines): PASS
- Fastly response diff script: PASS
- stock-celld-records: PASS
- health-startup (fastly): PASS
- prepare integration artifacts: PASS
- cargo test (ts CLI, native) (macos-latest): PASS
- cargo check (cloudflare native + wasm32-unknown-unknown): PASS
- local-provider-image: PASS
| app.wait_marker("registered"); | ||
| let start = app.terminate(); | ||
| thread::sleep(Duration::from_millis(450)); | ||
| app.release(); |
There was a problem hiding this comment.
🤔 thinking — Subprocess drain tests rely on tight wall-clock margins
This test, like the other subprocess tests, depends on tight wall-clock timing. The grace period is 1 s, the parent sleeps 450 ms, the task delay is 850 ms, and exited allows only 300 ms of slack. On a loaded CI runner, a slow child start or slow scheduling could change which happens first: the grace period running out or the task finishing.
Running::start also has a small race. It reserves a port, drops the listener, and only after that does the child bind to the port.
Consider widening the margins. Or gate each stage with marker files, as hold-write does, instead of relying on the delays alone. Either way, whether the test passes would no longer depend on how fast the runner is.
|
For the identity integration branch (#1608), I pushed Takes #1646's new head 6b4a5fd, which carries #1506's repin of EdgeZero to rc/identity at 1619078a (8edc50e), a revert that removes IABTechLab/edgezero#522 (portable Fastly record providers) and IABTechLab/edgezero#524 (outbound mTLS client identities). The merge is clean. |
ChristianPavilonis
left a comment
There was a problem hiding this comment.
Reviewed against #1646 at 6b4a5fdc0. The permit gate preserves the shared runner and I found no production regression in this diff. I ran cargo test-axum --offline --locked --lib after_response_drain_tests on the exact PR head: 10 passed, with the subprocess entry point intentionally ignored by the parent test run. The inline comments cover places where the tests can pass without proving the stated contract, stale design docs, and optional cleanup. The fixture proves a guarded write can complete on SIGTERM; the production binary and record-provider check remains separate in #1654.
| } | ||
| fs::write(root.join("registered"), b"request-held") | ||
| .expect("should expose request stage"); | ||
| while !root.join("release").exists() { |
There was a problem hiding this comment.
R1. Check task start while the response body is still pending
This gate holds the handler, not the body. After it opens, the handler returns a complete string body, and the parent independently blocks the write until it reads the response. A task that starts at handler return, before Hyper releases the body, could pass both assertions. Could the fixture return a streaming body with the final frame held? Read the first frame, assert no task-start marker while the final frame is pending, then release it and retain the lookup and write checks.
| app.release(); | ||
| complete_response(&mut stream); | ||
| app.wait_marker("writing"); | ||
| thread::sleep(Duration::from_millis(180)); |
There was a problem hiding this comment.
R2. Observe the task timeout before sending SIGTERM
The assertions only observe a clean exit and no completed write after SIGTERM. I exercised the same fixture child with a deliberately wrong 500 ms budget: the assertions still held, even though cancellation happened after SIGTERM. With the intended 100 ms budget, EdgeZero logged cancellation before the signal. Wait for that 100 ms diagnostic or a fixture cancellation marker while the child is still running, then send SIGTERM.
| app.release(); | ||
| complete_response(&mut stream); | ||
| assert!( | ||
| !app.exited(start, Duration::from_secs(1)), |
There was a problem hiding this comment.
R3. Require grace exhaustion, not just an unsuccessful exit
The normal fixture hit grace_exhausted at about 1,008 ms. As a control, a second SIGTERM after the write started caused forced_stop at about 463 ms and satisfied the same assertions. Check reason=grace_exhausted in the captured log so an early failure cannot count as hitting the shared deadline. Returning ExitStatus from the wait helper would also make the current success check explicit.
| ) | ||
| .expect("should build fixture identity"); | ||
| assert!( | ||
| !identity.schedule_after_response( |
There was a problem hiding this comment.
R4. Isolate the no-work guard
This passes even if work.is_none() is removed: the default context has no permit, and there's no scheduler to count any attempt. Use the permit-bearing registration fixture, pass None for work and supply the counting scheduler. Assert that it receives zero calls.
| ## Dependency and rollout | ||
|
|
||
| All six EdgeZero crates use `rc/identity` revision | ||
| `9d02d7b3185b49e81d9ac972ca3feef932ed848a`, matching #1635 and the rest of the |
There was a problem hiding this comment.
R5. Put the current stack and implementation first
The spec and companion plan describe the old #1635 base and a runner this PR no longer adds. The reconciliation notes correct some of that, but both docs still say 9d02d7b3 matches the base. The live #1646 base and this head both pin 1619078a. Lead with the current #1646 design, link to the workspace pin, and label any retained #1635 material as historical. No dependency change is needed.
| /// response has been sent. On Axum this also bounds the complete registered | ||
| /// task, including row reads and the guarded follow-up write. Shutdown may | ||
| /// cancel it sooner when the shared grace expires. |
There was a problem hiding this comment.
R6. Clarify when the Axum task timer starts
The preceding sentence describes the lookup clock. Axum's whole-task timer starts earlier, at body release, before the live-row read.
| /// response has been sent. On Axum this also bounds the complete registered | |
| /// task, including row reads and the guarded follow-up write. Shutdown may | |
| /// cancel it sooner when the shared grace expires. | |
| /// response has been sent. On Axum, the same value also limits the full | |
| /// task from response-body release, including row reads and the guarded | |
| /// follow-up write. The shared shutdown grace may cancel the task sooner. |
| /// | ||
| /// Returns whether a task was registered. A missing scheduler or a rejected | ||
| /// registration is logged and drops the work without running it. | ||
| #[must_use = "returns whether follow-up work was registered; failures are already logged"] |
There was a problem hiding this comment.
R7. Optional: keep the registration outcome internal
Both production callers discard the new #[must_use] result; only the tests observe it. The flag is useful for synchronous test assertions. If you prefer to keep the existing API, the tests can instead assert scheduler calls and task effects, and this method can still log registration failures and return ().
| trusted_server_identity_providers::partner_registry(&settings.ec) | ||
| .expect("should build partners"), | ||
| ); | ||
| let coordinator = Arc::new( |
There was a problem hiding this comment.
R8. Optional: share the eligible identity setup
The runtime fixture and registration_case build the same partner, coordinator, consented row, and finalize inputs. A shared setup helper would keep their eligibility assumptions in sync. Keep each scenario's client, timing, and choice to finalize visible at the call site.
| } | ||
|
|
||
| impl Running { | ||
| fn start(delay: u64, budget: u64, enabled: bool, grace: u64) -> Self { |
There was a problem hiding this comment.
R9. Optional: make the fixture's timing units explicit
delay and budget are milliseconds; grace is seconds. All are positional u64s, and callers restate the grace when they check exit. Named Duration fields would prevent swapping the units and let the exit check reuse the grace used to launch the child.
Summary
IdentityApp::schedule_after_response/run_after_response_lookups) instead of a second runner of this PR's own.schedule_after_responsechecks the permit with the newEcContext::has_after_response_permit()and returns whether it registered; the runner still takes the permit itself.Part of #1575.
Stack: merges #1646 (
feat/1574-axum-shared-identity) at000e6f694, which already contains the current #1635 and #1637 heads. Proposed base:feat/1574-axum-shared-identity.Dependency: EdgeZero
rc/identity9d02d7b3185b49e81d9ac972ca3feef932ed848a(R2, IABTechLab/edgezero#490), unchanged and identical to #1646.Reconciliation with #1646
#1646 and this PR both added a core
AfterResponseLookupsand runner. #1646's survives, because it already serves Fastly post-delivery, the Axum publisher path and the shared EC route.ec/after_response.rsAfterResponseLookups,capture,runec/app/lookups.rsAfterResponseLookups,IdentityApp::run_after_response_lookupsafter_response::schedule_lookupsandprepare_after_response_lookups(dispatch_fallback)IdentityApp::schedule_after_response, called from Axumdispatch_ec_routeand coreec_routeschedule_lookupsreturningErr(EdgeError)without a schedulerschedule_after_responsereturnsfalseand logs the error.with_proxy_marker(false)on the Axum task clientrequest_outbound_client(platform.rs:110, asserted at:185)Exactly one
AfterResponseLookupstype remains.PENDING_LIFECYCLE_MOVEstays&[].Changes
crates/trusted-server-core/src/ec/mod.rshas_after_response_permit(): a check that leaves the permit in placecrates/trusted-server-core/src/ec/app/lifecycle.rsschedule_after_responseskips registration without work or permit and returns whether it registered (#[must_use])crates/trusted-server-core/src/ec/app/route.rs,crates/trusted-server-adapter-axum/src/app.rscrates/trusted-server-core/src/settings.rscrates/trusted-server-adapter-fastly/src/post_delivery.rs,src/app.rscrates/trusted-server-adapter-axum/src/after_response_drain_tests.rs,src/lib.rsdocs/guide/native-rc-demo.mdRequirements status (#1575)
Part of #1575, not
Closes.sigterm_drains_the_registered_lookup_and_guarded_write_after_response)/healthanswers200, and/readyand every other route answer503. Only EdgeZero provider-preparation failures exit before listeningwaitUntil)Spec
Design · Plan. Both end with a reconciliation note for the runner change.
Test plan
Local results on
551419068(Rust 1.98.1, isolated Viceroy 0.21.0):after_response_drain_tests), run 3 timescargo test-axumec::testsadapter_identity_guardcargo clippy-axum,cargo clippy-fastly, Rust and docs formattingschedule_after_responsework_without_a_permit_registers_nothingandcloning_a_context_does_not_duplicate_a_follow_up_permitfail; restored551419068.The registered-task fixture proves the response completes before the guarded write and the process exits within its grace. The disabled-registration control shows response drain without the lookup or write. A 450 ms held response plus an 850 ms task under a 1 s shared grace cancels the write rather than granting a second grace. The task budget cancels independently of shutdown, and a client disconnect still releases registered work.
Checklist
unwrap(); useslogmacros