Collapse the two response write-deadline arming helpers in internal/format/oci
What
internal/format/oci carries two functions that arm a fill's response write
deadline, and they differ only in the log message and in whether they return the
instant they armed:
armRemoteReadResponseDeadlineinremote_manifest.go, for the by-digest manifest fill. Returns nothing.armBlobFillResponseDeadlineinremote_blob.go, for the blob cache-miss fill. Returns the armed instant, which its caller hands toblobFillWriteDeadlineKillto tell a truncation this deployment produced from a client that walked away.
Both call http.NewResponseController(w).SetWriteDeadline(time.Now().Add(budget)),
both log a Warn attributed by remoteReadSubject.logAttrs() with the error
through remote.RedactedForLog, and both degrade rather than refuse when arming
fails. The second is the first plus a return value.
Why it is worth collapsing
Two copies of the arm-and-log decision can drift on the level, on the redaction, or on the degrade-rather-than-refuse trade, and nothing fails when they do. The message is the one thing that has to stay per-arm, because an operator filters on the text.
The manifest arm also wants what the blob arm's version already has. #841 asks for a deadline kill on that arm to be attributable and says so directly: "return the armed instant and count the kill, the way npm's tarball route does." A merged helper hands it the first half for free.
Why it was not done in the MR that added the second copy
The blob arm's copy arrived with Step 15 part 2 of the S16 container remote work. Merging the two there would have meant, all of it in the manifest arm rather than in that MR's own subject:
- adding a
message stringparameter and atime.Timereturn toarmRemoteReadResponseDeadline, and updating its caller; - rewriting that function's doc comment, which at the time stated "This arm has one caller, holding the subject when it calls" — false once there are two.
The second cost is gone. Step 14-3 rewrote that doc down to one caller-agnostic line plus banner sections, so a second caller no longer falsifies anything there and no compression is owed. The merge is cheaper now than when this was filed.
Proposal
Give armRemoteReadResponseDeadline a message string parameter and a
time.Time return, have both arms call it, and delete
armBlobFillResponseDeadline. Keep one message constant per arm. The blob arm's
msgBlobFillDeadlineArmFailed and the manifest arm's literal are the two values.
Behaviour-preserving: same call, same level, same attributes, same degrade. The manifest arm gains an armed instant it does not yet consult, which is #841's to use.