fix(oci): arm the blob upload initiate's own write deadline (#1122 part 2 stack: 2/3)

What this delivers

This MR is part 2b of issue 1122, and the second MR of a stack of three:

  1. The repository-fenced image upsert in the datastore: !3378 (merged).
  2. This MR: the initiate write deadline. It targets the branch of !3378 (merged).
  3. The fence on the OCI write paths: !3368 (merged), which targets this branch.

This MR does not depend on the code of !3378 (merged). It stacks on it only to keep the stack linear.

Cause

The blob upload initiate (a POST with no digest and no mount) ran under server.timeouts.write. Go starts that clock when it reads the request headers. The session open of the initiate can wait on the upload admission gate for the full storage.upload_session_wait_timeout, which has a 15s ceiling. At a 10s server.timeouts.write, a full wait outran the write deadline, and the 503 of the gate did not reach the client.

The fix

  • handleInitiate arms its own write deadline before it opens the session: storage.upload_session_wait_timeout plus a 5s tail for the response write. That is 10s at the 5s default and 20s at the 15s ceiling. The deadline replaces server.timeouts.write, as the mount deadline does.
  • The composition root passes the configured wait through the new oci.WithUploadSessionWait option. The option ignores a wait that is not positive, so the 5s default applies.
  • If the connection refuses the write deadline, the initiate answers 500 INTERNAL before any session work.

!3368 (merged) adds the 10s bound of the fenced image upsert to this budget, in the same change that adds that bound.

Documentation changed with the code

  • S12, Upload Read Deadlines: a new paragraph gives the initiate budget.
  • docs/dev/configuration-reference.md: the server.timeouts.write row lists the initiate among the paths that re-arm the write deadline, and gives its budget. The storage.upload_session_wait_timeout row says that its value sizes the initiate write deadline.

Tests

Test Change
TestUpload_InitiateArmsWriteDeadline Added. The initiate arms its own write deadline, sized from a configured 12s wait, and arms no read deadline.
TestUpload_InitiateSetWriteDeadlineFailureReturns500 Added. A connection that refuses the write deadline answers 500 before the image upsert runs.
TestInitiateWriteTimeoutCoversTheSessionWait Added. The budget is more than the wait for a configured, a zero, a negative and an unset wait. A wait that is not positive keeps the default.
TestBuildOCIStoreHandlers_ThreadsUploadSessionWait Added. The composition root builds the upload handler with a 12s wait. The default is 5s, so a lost WithUploadSessionWait option fails the test.
TestUpload_BodylessPathsSetNoDeadline Changed. The POST initiate row is removed, because the initiate now arms a write deadline.

Seven test files under cmd/artifact-registry/ change only because wireOCI and wireOCIWithStore take one more argument.

e2e scenario catalog

No row covers the write deadline of the initiate, and the answer to a client that keeps its connection does not change. Thus, this MR adds no row and changes no row.

User documentation

No page under docs/user/ describes server write deadlines or the upload admission gate, so docs/user/ does not change.

Size

264 changed lines (209 added, 55 deleted) in 16 files.

File group Files Added Deleted Total
Production Go 3 58 4 62
Go tests 11 147 49 196
Specs and docs 2 4 2 6

Merge order

Merge this MR after !3378 (merged) and before !3368 (merged).

Related to #1122 (closed)

🤖 Generated with Claude Code

Merge request reports

Loading
Loading