Repository navigation
[ISSUE #8376] Enforce HTTPRoute request and backend timeouts across retries - #8418
Conversation
wy471x
left a comment
There was a problem hiding this comment.
The overall shape (absolute request deadline, per-attempt budget carried into the writers, 504 before commitment, cancellation after commitment) reads sensibly and the header/body-ownership comments are helpful. Points I would like resolved:
-
The retry-sequence bound disappears when both route timers are disabled.
RetryTimeoutUtils.limitSequencereturns the source untouched wheneverHttpRouteDeadline.REQUESTis present. Withtimeouts: {request: "0s", backendRequest: "0s"},HttpRouteDeadlineis constructed disabled,withAttemptTimeoutinstalls a disabled attempt deadline, and the pre-existingtotalTimeout(attemptTimeout, retryTimes, maxBackoff)cap is gone. Before this PR every divide retry sequence was bounded; now such a route can hang on a stalled backend with no timer to cancel it. Please keep a sequence bound when both route timers are zero, or state explicitly that the route then relies solely on the independent connect/transport limits. -
The 504 can carry headers from the abandoned attempt.
NettyHttpClientPlugincopies all upstream headers onto the downstream response (response.getHeaders().putAll(headers)), andGlobalErrorHandlerthen strips onlyContent-Encoding,Content-TypeandContent-Length. A backend that sends headers and then stalls leavesSet-Cookie,Location,ETag,Cache-Control,Content-RangeandContent-Dispositiondescribing a body that is never sent. Please clear the upstream-derived headers (or snapshot/restore the pre-upstream ones) before rendering the terminal timeout, and add a test that assertsSet-Cookieis absent. -
Duplicated handoff logic.
NettyClientMessageWriter.cleanupandWebClientMessageWriter.cleannow contain the same guard and the same four-line comment. Extracting one helper (e.g.ResponseWriterSupport.releaseConnection(exchange)) keeps the ownership rule in one place. -
Javadoc on new public accessors.
DivideRuleHandle#getRequestTimeout/setRequestTimeoutand theShenyuMemoryConfigtimeout accessors are public and undocumented, while the rest ofDivideRuleHandleis documented. Checkstyle only enforces presence, so this will not be caught in CI. -
Naming.
HttpRouteParser#buildRuleHandlereturns a JSONStringand shadowsDividePlugin#buildRuleHandle, which returns aDivideRuleHandle; the bareStringthen travels throughprocessRule → emitRuleSelectors → addSelectorRule(now 10 parameters) →buildRuleData. Renaming it (e.g.buildRuleHandleJson) and passing the handle object would make the call chain readable. -
Optional:
HTTPRouteReconcilernow branches on two parallel rejection channels (isHasUnsupportedFilters()andgetTimeoutError()) andHttpRouteParser#processRulekeeps the firstreasonbut the lasttimeoutError. A single "rejected + message" value would make theAccepted=Falsesemantics easier to follow.
|
@wy471x Thanks for the review. I addressed your feedback in d20d1ef.
CI is green on this commit (61 checks passed, 6 skipped). Locally, all 558 selected tests passed on JDK 17, along with Checkstyle and Apache RAT. Could you take another look when you have a chance? |
Aias00
left a comment
There was a problem hiding this comment.
Stream Agent analysis
WHOLE_PR review of #8418 could not be completed with confidence. The ledger marks the pinned 107,853-character diff as fully delivered and reports CI passed (69 checks, complete, no failures), but the diff page bodies were archived from this model window and every re-read returned an empty 'Page already delivered' observation; further tool calls are now barred. Only selected excerpts could be verified in-window (HttpRouteDeadline REQUEST/ATTEMPT, limit()/finish()/received()/onAbandon(); NettyHttpClientPlugin onAbandon/received wiring; AbstractHttpClientPlugin per-attempt deadline). The central cross-file contract — whether the overall REQUEST deadline bounds the whole retry/backoff transaction and downstream completion — remained explicitly unverified, as did the response writers, GlobalErrorHandler and added tests. No concrete blocking defect could be anchored, but absence of one cannot be asserted, so no PASS is issued.
Evidence
- Frozen context: head_sha d20d1ef, base 9dd9a12, complete_diff=true, 27 changed files, CI passed=true/complete=true, check_count=69, failed_checks=[] (legacy_state=pending).
- Engine read progress marks the main diff complete at next_unread_offset=107853, but all resource_diff re-reads in this window returned {"archived_observation":true,"page":{}} with 'Page already delivered'; targeted reads were then prohibited, so the page bodies were not verifiable here.
- Verified in-window excerpts: HttpRouteDeadline defines REQUEST/ATTEMPT plus limit(), finish(), received(), onAbandon(); NettyHttpClientPlugin registers attempt.onAbandon(connection::dispose) and calls attempt.received() on the failover path; AbstractHttpClientPlugin installs a per-attempt deadline. The overall REQUEST deadline across retries/backoff was flagged but never confirmed.
Recommended next steps
- Re-deliver the archived diff page bodies and confirm resource_diff has_more=false with content visible in-window before concluding coverage.
- Verify that HttpRouteDeadline.REQUEST bounds the entire retry/backoff transaction in AbstractHttpClientPlugin and that the response writers correctly call received()/abandon().
- Reconcile the CI record (passed=true, complete=true, 69 checks, failed_checks empty) with legacy_state=pending, then reissue a PASS or NEEDS_CHANGES verdict.
Scope: captured diff and GitHub check metadata only; no local tests were executed.
Task: ef9c2fa1-e4b0-4354-b757-eb07a33035c7 · Commit: d20d1efa6db88909e7afd0b0625dcd3e2da2f191
Review verdict: INCONCLUSIVE
Full diff coverage cannot be responsibly claimed from verified progress: the complete diff bodies were archived and re-delivery was refused, no further tool calls are permitted, and the key cross-file deadline contract (overall REQUEST budget across retries, backoff and downstream body completion, plus writer cleanup) was left unverified. Per the explicit requirement that incomplete evidence must be INCONCLUSIVE, no PASS is asserted; CI is reported passing but that alone does not establish correctness, and no concrete HIGH/CRITICAL defect with path/line/side could be anchored, so NEEDS_CHANGES is unsupported.
Publication: COMMENT (INCONCLUSIVE_REVIEW)
|
@Aias00 I added a loopback regression test in 28d9a93 to cover the deadline across retries and response writing. It runs with both Netty and WebClient. The first attempt times out, then the retry sends one event. With a 2 s request budget, the stream ends before the second event and the backend connection closes. Increasing only the request budget to 5 s lets both events arrive. Removing the outer request deadline in an isolated run made the test fail for both clients. All 560 selected local tests passed. GitHub CLI reports 69 passing checks and 3 skipped on this head, with none pending or failed. Could you take another look at the updated PR when you have a chance? Thanks! |
Aias00
left a comment
There was a problem hiding this comment.
Stream Agent analysis
Review of #8418 (28d9a93): enforce HTTPRoute request/backend timeouts across proxy execution and retries. Complete diff coverage with verified wiring and passing CI.
Evidence
- Full diff read across 16 pages (offsets 0..105000, 110184 chars, has_more=false), covering all 28 changed files including new HttpRouteDeadline/HttpRouteResponseHeaders utilities and tests.
- Targeted verification: DividePlugin.doExecute sets HttpRouteDeadline.REQUEST + HttpRouteResponseHeaders.ATTRIBUTE when requestTimeout present and removes them when null (legacy 3000ms path preserved); AbstractHttpClientPlugin.withAttemptTimeout installs per-attempt ATTEMPT deadline; Netty/WebClient writers call attempt.received() on body completion and honor ownsResponseCleanup; retry strategies convert TimeoutException to non-retryable.
- PR evidence reports CI complete: 74 checks, all success, passed=true, failed_checks=[]. No concrete HIGH/CRITICAL defect identified in deadline/retry/cleanup contracts.
Recommended next steps
Scope: captured diff and GitHub check metadata only; no local tests were executed.
Task: e5d6b0f6-4ae0-44c4-bf4a-24dab8911de6 · Commit: 28d9a93e5e3638d25881aa69e40d7639e41ce52e
Review verdict: PASS
Full diff coverage achieved (all 16 pages read, has_more=false). CI passed 74/74 with no failed checks. No concrete HIGH/CRITICAL defect found in the timeout enforcement, per-attempt deadline, retry conversion, or response cleanup wiring; legacy behavior is preserved when requestTimeout is absent.
Publication: APPROVE (EXPLICIT_PASS)
Aias00
left a comment
There was a problem hiding this comment.
Stream Agent analysis
Reviewed #8418 (enforce HTTPRoute request/backend timeouts). The full pinned diff was delivered per the execution ledger, but CI is not green at the reviewed head and no line-anchored blocking defect could be re-verified in this session. Verdict is INCONCLUSIVE, not PASS.
Evidence
- CI evidence: ci.complete=true but ci.passed=false; failed_checks list build (failure) and changes (failure) at head_sha 640ac3e, run 43372963034, run_attempt 1; legacy_state=pending, status_count=0.
- ENGINE_READ_PROGRESS: whole pinned diff path='' total_characters=110175, next_unread_offset=110175, complete=true, so the required diff pages were delivered; the attachment is a VERSIONED_DIFF index requiring resource_diff pagination and no local tests were executed.
- Verified head content for new files HttpRouteDeadline.java (133 lines) and HttpRouteResponseHeaders.java (70 lines); re-reads of the other changed-file diffs returned archived_observation with empty pages, so line-level cross-file re-verification is incomplete in this session.
Recommended next steps
- Fix and re-run the failing 'build' and 'changes' CI checks at head 640ac3e before any PASS conclusion.
- Re-read the archived diff pages for the HTTP client plugins, DividePlugin, response writers and GlobalErrorHandler to verify the cross-file deadline contracts.
- Confirm no concrete HIGH/CRITICAL regression exists once the diff bodies are available for line-level verification.
Scope: captured diff and GitHub check metadata only; no local tests were executed.
Task: 80ecee98-68cd-46df-8640-57708377ca10 · Commit: 640ac3e4c3e94fcb5c144bc71dd0d76ae26bc199
Review verdict: INCONCLUSIVE
PASS requires passing CI, but the frozen evidence records ci.passed=false with the build and changes checks failing at the reviewed head, so success cannot be concluded. Full diff pages were delivered per the execution ledger, yet their bodies are archived from this window and could not be re-read for line-anchored verification; no concrete HIGH/CRITICAL code defect was verified to justify NEEDS_CHANGES. Per the instruction that incomplete or non-passing evidence must be INCONCLUSIVE, the verdict is INCONCLUSIVE with the exact limitation stated.
Publication: COMMENT (INCONCLUSIVE_REVIEW)
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #8418 +/- ##
=============================================
+ Coverage 61.49% 72.79% +11.29%
- Complexity 8818 19238 +10420
=============================================
Files 1261 1814 +553
Lines 39273 70997 +31724
Branches 3725 8467 +4742
=============================================
+ Hits 24151 51681 +27530
- Misses 12952 14974 +2022
- Partials 2170 4342 +2172
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Aias00
left a comment
There was a problem hiding this comment.
Stream Agent analysis
HTTPRoute request/backend timeout enforcement PR (#8418) reviewed. Full versioned diff coverage achieved (112335 chars, last page has_more=false), but required CI checks (build, e2e) are still queued/pending, so a PASS verdict is not supported.
Evidence
- Full versioned diff consumed: 112335 chars, final page offset 112000 returned has_more=false (complete coverage of all changed files).
- CI not in a passing state: build and e2e checks status=queued, ci.passed=false, ci.legacy_state=pending; PASS requires passing CI, so no PASS conclusion can be issued.
Recommended next steps
- Wait for the build and e2e CI checks to complete and pass, then re-run the full review for a PASS or NEEDS_CHANGES verdict.
Scope: captured diff and GitHub check metadata only; no local tests were executed.
Task: 1f85b593-f6a9-422d-9b37-fa56b05f2f4c · Commit: ab42064aeca681ef3dfe7630aa020ce7b995cc0e
Review verdict: INCONCLUSIVE
Full diff coverage was obtained, but the required CI checks (build, e2e) are still queued/pending with ci.passed=false and legacy_state=pending. Per policy, PASS requires passing CI; with CI unfinished, the review cannot conclude PASS or NEEDS_CHANGES and must be reported as INCONCLUSIVE pending CI completion.
Publication: COMMENT (REVIEW_EVIDENCE_MISSING)
Aias00
left a comment
There was a problem hiding this comment.
Stream Agent analysis
PR #8418 enforces Gateway API HTTPRoute timeouts.request/backendRequest across proxy execution, retry waits and downstream body completion via new HttpRouteDeadline/HttpRouteResponseHeaders utilities, Divide/controller/HTTP-client/response-writer changes, and extensive timeout routing tests. Full frozen diff coverage recorded and CI is green; no concrete blocking defect was verified.
Evidence
- Execution ledger: the pinned versioned diff (path='') was read to next_unread_offset == total_characters (112335) with complete=true, and complete_diff=true lists all 29 changed files as available; path-specific diffs for the deadline/response-header utilities, DivideRuleHandle, DividePlugin, AbstractHttpClient/WebClient/Netty client plugins and retry strategies returned has_more=false with sha256 matching the recorded pages.
- CI evidence: complete=true, passed=true, 98 checks with success conclusions (build, e2e, issue-spec-policy, e2e-case matrix), failed_checks empty; no local tests were executed by the reviewer.
- Targeted verification of new HttpRouteDeadline.java (RIGHT lines 1-133): absolute nanoTime deadline with Mono.defer recomputing remaining budget per retry subscription, a bodyComplete race in finish() that only bounds writing until the last upstream body byte, ownership handoff via AtomicReference, and gatewayTimeout() mapping to 504; no anchored HIGH/CRITICAL defect found in this class or the delivered cross-file diffs.
Recommended next steps
Scope: captured diff and GitHub check metadata only; no local tests were executed.
Task: fc7ccb11-5658-4ee2-98b6-b1e80ab856b0 · Commit: ab42064aeca681ef3dfe7630aa020ce7b995cc0e
Review verdict: PASS
WHOLE_PR review of head ab42064. Coverage: the full frozen diff was delivered and is recorded complete in the execution ledger (earlier page bodies were archived from the model window but remain in the ledger; repeated targeted re-reads confirmed delivery with matching sha256 and has_more=false rather than failing). CI is complete and passing with 98 successful checks and no failures. Targeted checks of the new deadline utility and the surrounding controller/plugin/retry/response-writer contracts, plus the added unit and timeout-routing tests, produced no concrete HIGH/CRITICAL finding anchored to a diff line, so PASS is supported by full coverage + green CI + no verified blocker. Coverage alone is not a correctness proof: this verdict reflects the reviewed evidence and does not claim that tests were run, a merge occurred, or a review was submitted.
Publication: APPROVE (EXPLICIT_PASS)
Problem and change
An HTTPRoute could request a 500 ms timeout and still receive the controller's hard-coded 3000 ms Divide handle. This change enforces
timeouts.requestacross proxy execution, retry waits and downstream completion. Each backend attempt receives its owntimeouts.backendRequestbudget through the last upstream body byte, including for streaming responses.Fixes #8376.
An omitted or empty timeout block preserves the legacy path and its three retries. For routes using timeouts, the default backend budget is 3000 ms and the default overall route budget is unbounded. Explicit zero disables that route timer. Invalid durations and a backend budget longer than a finite explicit request budget withdraw the route and report
Accepted=False/UnsupportedValue. Independent transport timeouts still apply.The Netty and WebClient paths retain ownership across the header/body handoff. A terminal timeout before commitment produces 504. A timeout after commitment cancels the stream without replay. The change is based on master and has no unmerged PR dependencies.
On a pre-commit 504, both HTTP clients restore the gateway headers captured before importing upstream metadata. The loopback regression reproduced a stale upstream Set-Cookie on both clients before the fix and now verifies its absence, removal of the upstream ETag, and restoration of an overwritten gateway header. When both timers are zero there is no route-level retry sequence deadline; the retry count and independent transport limits still apply.
Request deadline across retries and response writing
Full comparison at the verified commit. Divide installs the outer timer around the complete downstream chain. Inside it, the HTTP client retries the backend call and awaits the response writer. The backend body completion signal stops only the attempt timer. Netty and WebClient signal completion on the body. Terminal cleanup belongs to the HTTP client.
The loopback regression for both clients times out the first attempt, receives the retry's first event, and checks that the original request deadline truncates the stream and closes the backend connection. Increasing only the request budget allows both events to arrive. In an isolated negative control, removing only the outer deadline let the stream finish and failed both client cases. Existing tests also cover expiry during retry backoff and cancellation between upstream headers and writer subscription.
For the previous reviewed commit d20d1ef, the Checks API reported 63 successes and 6 skips. The separate legacy commit-status endpoint returned pending with zero status entries. CI for the new commit is tracked in the PR Checks tab.
IssueSpec
IssueSpec-Mode: full
IssueSpec-Reason: Add Gateway API v1.5.1 HTTPRoute request and backend timeout semantics to the embedded controller and HTTP runtime.
IssueSpec-Proposal: #8413
IssueSpec-Design: #8414
IssueSpec-Implement: #8415
IssueSpec-Specs: SPEC-8413001
IssueSpec-Tasks: TASK-8415001
IssueSpec-Validation: On the runtime merge commit 640ac3e, 611 selected tests passed on JDK 17. The CI-only follow-up ab42064 passed all 93 workflow and IssueSpec script tests locally. All 20 reactor projects passed Checkstyle and Apache RAT. IssueSpec implement gate and durable-spec check passed. No official Kubernetes conformance run.
Verification
CI follow-up ab42064 adds wrapper preflight to source_release_check and validates the extracted source wrapper before Maven. node --test .github/scripts/test-ci-workflows.mjs .github/scripts/issue-spec-policy-test.mjs passed all 93 tests, zero skipped. Runtime Maven tests were last run on parent 640ac3e.
./mvnw -pl shenyu-kubernetes-controller,shenyu-spring-boot-starter/shenyu-spring-boot-starter-k8s,shenyu-web -am verify -Dtest=<selected classes> -Dsurefire.failIfNoSpecifiedTests=false -Dmaven.javadoc.skip=trueran every test class ending inTestin the Kubernetes controller, Kubernetes starter, HTTP client, Divide and response modules plusGlobalErrorHandlerTest,DivideRuleHandleTest,DivideRuleHandlePoolGroupTestandHttpRouteDeadlineTest. 611 tests passed, zero skipped, including HTTPRoute rejection/recovery, Namespace selectors, and the streaming timeout regressions.The loopback routing tests exercise both HTTP client/writer pairs, including the v1.5.1 request/backend timeout fixture behaviors, retry success and exhaustion, expiry during backoff and an active attempt, stalled/trickling bodies, and client disconnect after upstream headers. The tests assert upstream dispatch count and connection closure.
Previous head a64adbd, default reactor on Windows with JDK 17:
./mvnw clean install -Dmaven.javadoc.skip=truecompleted modules 1–145, then six existingShenyuToolCallbackBodyTestcases could not match LF-only Markdown fences in a CRLF checkout. After restoring the two MCP example documents to their indexed LF bytes locally,./mvnw clean install -Dmaven.javadoc.skip=true -rf :shenyu-plugin-mcp-serverpassed all remaining 71 modules. Neither document is changed in this PR. The Kubernetes Gateway API integration job passed on GitHub. No official Gateway API conformance suite run is claimed.I have read the contribution guidelines.
I submit test cases that back these changes.
Full default-reactor clean install on this head. The previous head completed all 216 modules using the documented resume.