Repository navigation
CI-8: S3 storage HTTP timeouts, retries, redirect guard and no connection reuse - #16
Merged
Merged
Conversation
…ge (CI-8 Task 1)
Storages accept two optional blocks, http {connect_timeout, timeout: float > 0}
and retries {mode: legacy|standard|adaptive, max_attempts: int >= 1}. If a
block is set, every subkey is required; a missing, unknown or invalid subkey
fails configuration processing with the key path (R-B1, D-9). Integer literals
are accepted and cast to float.
An s3 storage passes a set block to the S3Client arguments as http /
retries, after the 8.1.4 keys; an unset block stays absent, so without both
blocks the client definition equals 8.1.4 (R-B2, R-B3). The file_system
driver accepts and ignores both blocks, including an s3 base merged with a
file_system override (R-B4).
README: option rows (also the missing path_style and credentials rows) and
an S3 timeouts section with the limits of the bound (static credentials,
curl handler, asynchronous DNS). CLAUDE.md: Service Configuration.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SXB2dje72BXojVPbein4Rm
…p feed and single attempt (CI-8 Task 2a) A fake TCP server and the storage operation each run in a child process; the harness kills the operation after 10·T_test, so a client without timeouts fails instead of hanging (AC-5: I-1, I-2, I-3, I-7). Connect timeout: full backlog-1 accept queue on Linux, 192.0.2.1:81 on macOS, with a raw-connection probe that fails the test (never skips) when the environment cannot time out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SXB2dje72BXojVPbein4Rm
…CI in php:8.5-cli-trixie (CI-8 Task 2a fix F-1) - FakeS3Harness::connectTimeoutEndpoint() fails (never skips) on libcurl < 8.11, whose connect-timeout wording Guzzle classifies as NetworkTimeoutException instead of ConnectTimeoutException. - php.yml runs the job in the php:8.5-cli-trixie container (libcurl 8.14.1, + gd, git, unzip, Composer) instead of the runner's Ubuntu 24.04 (libcurl 8.5.0), and prints the PHP and libcurl versions. - The 10·T_test guard starts at operation.php's "ready" line (child start-up has its own deadline); the harness also fails on a non-zero exit code. - Timing upper bound A·T_test + 2 s + 1 s = 4 s; the A = 1 test asserts elapsed >= T_test (m3). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SXB2dje72BXojVPbein4Rm
… single-attempt 404 NoSuchKey (CI-8 Task 2b) - testServiceUnavailableThenSuccess: 503 ServiceUnavailable then 200; two requests, two SDK attempts. The PUT uploads 1 040 000 random bytes (Guzzle streams it, no Expect) and the retried request's body length and sha256 equal the file (I-4, E-28, M-2); the GET target holds only the 200 body (E-12). - testNoSuchKeyIsSingleAttemptWithCode: 404 NoSuchKey, one attempt, code kept, not a connection error. - FakeS3: scenarios unavailable_then_ok and no_such_key, requests() journal accessor, upload size and source sha256 in the operation result. - README and CLAUDE.md: a failed download() may leave a partial target file; the caller deletes it, Handler::archive does not (R-B5, L-5). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SXB2dje72BXojVPbein4Rm
…ound docblock, document both timing bounds (CI-8 Task 2a minors n1-n3) - FakeS3Harness: a PHP start-up warning printed before "ready" no longer sends the guard back to the from-spawn deadline; "did not start" now prints stdout too. - S3StorageFaultTest: delete the "D(A) = 6 s" docblock; the bound is 4 s. - CLAUDE.md: the A = 2 tests use 4 s, the A = 1 test uses T_test + 1 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SXB2dje72BXojVPbein4Rm
… without a code (CI-8 Task 3a, R-B7/D-17) register() appends one init step (NAME = chamber_orchestra_file.s3_redirect_guard) to an S3Client's handler list. A fulfilled result with @metadata.statusCode 300-399 becomes exactly S3Exception: status in the message, no AWS error code, connection_error false, the result kept for diagnostics. Other results and rejections pass unchanged. Not wired into the extension yet (Task 3b). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SXB2dje72BXojVPbein4Rm
…omes an error (CI-8 Task 3b, R-B7) With `http` set, the extension passes `allow_redirects: false` in the client's `http` argument and sets `[S3RedirectGuard::class, 'register']` as the client definition's configurator, so a 3xx ends the operation after one request: 301 -> PermanentRedirectException, any other 3xx -> S3Exception without an AWS error code, never retried. Without `http` the client definition stays as in 8.1.4 (no allow_redirects, no configurator). S3StorageRedirectTest (AC-17-AC-19) runs PUT and GET against a redirecting fake server with a silent Location target. Recorded runs: v1 (no allow_redirects, no guard) all 8 red; v2 (allow_redirects only) AC-17 green, AC-18/AC-19 red (silent success). The extension tests check the http array, the configurator, and on a compiled container exactly one guard step in `init` with `retry` and `s3.permanent_redirect` in `sign`. FakeS3Harness now holds the one 4 s bound (UPPER_BOUND), ATTEMPTS and the test storage config, shared by the fault and redirect tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SXB2dje72BXojVPbein4Rm
…sk 4, R-B8, AC-3, AC-20) With `http` set, the client's `http` argument also gets `curl => [CURLOPT_FORBID_REUSE => true]`, so Guzzle never re-sends a streamed PUT on a dead reused connection and one SDK attempt is one HTTP request. Without `http` the client definition stays exactly as in 8.1.4. S3StorageKeepAliveTest (AC-20): fake server scenario keep_alive (warm-up GET 200 keep-alive; request 2 closed 0.8*T_test after its body, unanswered; then silence), warm-up download() before the guard, upload of 1 040 000 B. Without R-B8: red 3/3, 4 requests on 3 connections, 3 PUTs for 2 SDK attempts. With R-B8: green 3/3, 3 requests on 3 connections, PUTs = attempts = 2, upload() 1.43-1.87 s (bound 4 s). Docs: README and CLAUDE.md state R-B8, the ext-curl requirement (container compile Error without it), the rejected `stream` option (StreamHandler), that remove() rethrows unwrapped (false only for NoSuchKey), and that a failed download may leave the S3 error XML in the target. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SXB2dje72BXojVPbein4Rm
- Requirements / Dependencies: Symfony 8.1 and metadata-bundle 8.1, as in composer.json. - http/retries: write literals; %env()% placeholders fail the > 0 / >= 1 check. - A timeout of .inf or below 0.001 passes configuration, but Guzzle 8.2 rejects every request with InvalidArgumentException; it is not "no timeout". - Stream-handler cases in the "do not bound" list fail instead when http is set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SXB2dje72BXojVPbein4Rm
…R-B1, AC-1) A timeout that is infinite or below 1 ms passed validation: Guzzle 7 then silently disables the timeout (CURLOPT_TIMEOUT_MS = 0) and Guzzle 8 rejects every request. Both keys now fail configuration processing with the key path. The message is built with var_export, since thenInvalid's json_encode cannot encode INF. Docs: README and CLAUDE.md state the new rule; the stream-option rejection is Guzzle 8+ only; composer suggest matches 8.1.* and lists ext-curl. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SXB2dje72BXojVPbein4Rm
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CI-8: optional HTTP timeouts and retry policy for S3 storages, and the two client settings that make one SDK attempt one HTTP transfer.
http(connect_timeout,timeout: seconds, finite float >= 0.001, D-28) andretries(mode:legacy/standard/adaptive;max_attempts: int >= 1). If a block is set, every subkey is required; a missing, unknown or invalid subkey throwsInvalidConfigurationExceptionwith the key path. The blocks are passed toS3Client; withhttp, the client'shttpargument also getsallow_redirects: falseandcurl: [CURLOPT_FORBID_REUSE => true](R-B7, R-B8). Thefile_systemdriver accepts and ignores them.connect_timeoutandtimeoutmust be finite and >= 0.001 s:.infor a value below 0.001 fails configuration processing with anInvalidConfigurationExceptionthat names the key path (551a07c). Reason: on such a value Guzzle 7 silently disables the timeout (CURLOPT_TIMEOUT_MS= 0), and Guzzle 8 rejects every request.allow_redirects, nocurl, no configurator.S3Storagebehaviour is unchanged (exception wrapping,NoSuchKey,SaveAs), except for R-B7 and R-B8. Docs: after a faileddownload()the target file may hold a partial body or the S3 error XML; the caller deletes it.CLAUDE.mddescribe the keys and state that the timeouts bound an operation only with staticcredentials(the SDK provider chain runs outside them), Guzzle's curl handler and an asynchronous DNS resolver.http). The client getsallow_redirects: false.S3RedirectGuardadds one step to theinitstep of the handler list, outsideretryands3.permanent_redirect. The step turns a 3xx result into exactlyS3Exceptionwithout an AWS error code, so a 3xx never reads asNoSuchKeyand is never retried (one HTTP request). A 301 staysPermanentRedirectException.CURLOPT_FORBID_REUSE(only withhttp). The client'shttpargument getscurl: [CURLOPT_FORBID_REUSE => true]. Every request opens a new TCP (and TLS) connection, so Guzzle never re-sends a request on a dead reused connection, and HTTP requests per operation = SDK attempts.Timeout tests on a client without
http/retries(AC-5, Task 2a)Recorded red run: the four timeout tests of
S3StorageFaultTestagainst a client withouthttp/retries(the two lines temporarily removed fromFakeS3Harness::storage(), then restored). T_test = 0.5 s; the harness kills the operation after 10·T_test.operation exceeded 10·T_test (5.0 s): "upload" killed after 5.001 s.(FakeS3Harness.php:153)… "download" killed after 5.004 s.… "upload" killed after 5.007 s.… "download" killed after 5.011 s.… "upload" killed after 5.002 s.… "download" killed after 5.012 s.… "upload" killed after 5.003 s.… "download" killed after 5.007 s.All ≤ 10·T_test + 1 s = 6 s (the connect tests include the 0.5 s probe). Linux container (connect tests only): killed after 5.002 s / 5.003 s. With
http/retriesall eight pass.Redirect tests (AC-17–AC-19, Task 3b)
Each test ran against three versions of the code: v1 (
http/retriesonly), v2 (allow_redirects: falseonly), and with the fix (373db61).S3Exceptioninstead ofPermanentRedirectException; followed to the silent target,NetworkTimeoutException, 2 attempts, 2.08 sKeep-alive test (AC-20, Task 4)
Scenario
keep_alive: a warm-updownload()leaves a kept-alive connection; the server reads the PUT body on it and closes the connection unanswered. Upload of 1 040 000 B, T_test = 0.5 s, A = 2.upload()timeThe strict review reproduced it on Linux: 5/5 red without R-B8, 5/5 green with it.
CI: libcurl >= 8.11
The connect-timeout test needs libcurl >= 8.11. Older libcurl words a connect timeout as "Failed to connect … Timeout was reached", which Guzzle classifies as
NetworkTimeoutException, notConnectTimeoutException. The test fails (never skips) on older libcurl. Thephp.ymljob therefore runs in thephp:8.5-cli-trixiecontainer (libcurl 8.14), not on the runner's Ubuntu 24.04 (libcurl 8.5). It prints the PHP and libcurl versions in the step "Show PHP and libcurl versions".Limits
credentials, the SDK provider chain (env, ini, ECS, IMDS) runs outside these timeouts and retries.httprequires ext-curl: without it, compiling the container fails withUndefined constant "CURLOPT_FORBID_REUSE".streamrequest option (Guzzle 8+). On Guzzle 8+, requests withstreamto the client of a storage withhttpfail: Guzzle'sStreamHandlerrejects thecurloption (InvalidArgumentException).http. Check that the endpoint answers without redirects before you sethttp. A storage withouthttpfollows redirects as in 8.1.4.%env(float:…)%/%env(int:…)%placeholders fail the >= 0.001 / >= 1 check, because Symfony validates a placeholder with a dummy 0.timeout. This PR does not claim a stronger per-operation bound.CI run on this PR
Run 39319614656 at 551a07c: green. Earlier run 39307052661 at 09e3848: green; the environment below is from that run. PHP 8.5.11, libcurl 8.14.1 (ext-curl loaded). The bundle has no lock file;
composer installresolvedaws/aws-sdk-php3.401.3 andguzzlehttp/guzzle8.3.0. Tests: 203, assertions: 612; PHPStan: no errors; PHP-CS-Fixer: 0 of 71 files to fix.Merging this PR, the release PR
8.1→mainand thev8.1.5tag are separate owner decisions.🤖 Generated with Claude Code
https://claude.ai/code/session_01SXB2dje72BXojVPbein4Rm