Repository navigation
fix: delete the upload path that dropped four headers and gained nothing (#362) - #363
Merged
Merged
Conversation
PutObject had two implementations. The CargoShip transporter branch already carried three bypasses explaining what cargoships3.Archive cannot express — a Content-Encoding, the configured encryption headers, a per-object storage class — and #362 found the fourth, which was not bypassed but silently wrong: Content-Type was written into Archive.Metadata, which is S3 user metadata, not the header. Measured through the endpoint, file.txt stored as application/octet-stream on that path and text/plain on the direct one, with detectContentType having computed the right value one line earlier in both. There was nothing on the other side. The transporter was reachable only below MultipartThreshold, since PutObject returns into putObjectMultipart first and that function never referenced a transporter — so its 64 MiB multipart BufferProvider served an upload shape a mount cannot produce, and sync.Pool released that buffer at every GC: 20 PUTs allocated 3.4 MiB with no GC between them and 837 MiB with one after each, which also inverted GOMEMLIMIT. Throughput was 35% slower at 4 KiB and a wash at 8 MiB. So it is deleted rather than given a fourth bypass, along with storage.s3.use_cargoship, s3.Config.EnableCargoShipOptimization, GetTransporter, IsCargoShipEnabled, and cargoShipCanEncrypt. The config key is removed rather than deprecated and the loader is strict, so a file still setting it fails at startup naming the key — an operator who set it believed their uploads took a different path, and an error is the one way that belief gets re-examined. ConvertTierToCargoShipStorageClass stays. upload_path_test.go now pins the boundary rather than the path: Content-Type reaches the stored object on both sides of the threshold, the stored metadata key set is exactly what ObjectFS wrote, and caller metadata survives. All three fail on the old code and were verified by mutation. The first draft passed for the wrong reason — a 1 MiB chunk size is below the AWS uploader's 5 MiB part minimum, so every CargoShip upload failed and fell back to the path that sets the header correctly.
This was referenced Aug 5, 2026
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.
Closes #362.
PutObjecthad two implementations. The CargoShip transporter branch already carried three bypasses with long comments explaining whatcargoships3.Archivecannot express — aContent-Encoding, the configured encryption headers, a per-object storage class. This issue found the fourth, which was not bypassed but silently wrong.The fourth limitation
Content-Typewas written intoArchive.Metadataunder a"content-type"key. That is S3 user metadata, not the header. Measured through the endpoint onfile.txt:application/octet-streamtext/plaindetectContentTypecomputed the right value one line earlier in both cases. Since the transporter was reachable only belowmultipart.threshold, that was every object under 32 MiB on the shipped defaults — which is every object a FUSE mount writes.Why deletion rather than a fourth bypass
The transporter was unreachable at or above the threshold:
PutObjectreturns intoputObjectMultipartfirst, and that function never referenced a transporter (grep count zero). So its 64 MiB multipartBufferProviderwas installed on a path that only ever performed single-part uploads.That buffer lives in a
sync.Pool, which is cleared at every GC cycle — so it was re-allocated on the first PUT after each collection rather than amortized:It also inverted
GOMEMLIMIT. 300 difftest iterations, transporter on: 768 MiB limit → 751 MiB alloc / 4 GCs; 384 MiB limit → 3570 MiB / 28 GCs. Transporter off: 285 MiB at both limits. A tighter limit means more pool clears.Throughput gave nothing back — 30 PUTs per size against the in-process endpoint:
A local endpoint is not evidence against BBR over a real network, but the sizes where BBR could matter never reached the branch.
It further stamped four metadata keys on every small object, two structurally empty (
cargoship-original-sizealways"0",cargoship-compression-typealways""), pluscargoship-created-byand acargoship-upload-timetimestamp that made otherwise-identical objects differ.Four silently-wrong headers against no reachable benefit is a subtraction.
What's removed
storage.s3.use_cargoship,s3.Config.EnableCargoShipOptimization,ClientManager.GetTransporter,ClientManager.IsCargoShipEnabled,cargoShipCanEncrypt, and the branch itself.ConvertTierToCargoShipStorageClassstays — it has its own unit tests and CargoShip'sawsconfigtypes are still used for tier mapping.The config key is removed rather than deprecated, and the loader decodes strictly, so a file still setting it fails at startup naming the key. Same reasoning as the removed
security.encryptionbooleans and thecost_optimizationblock: an operator who set it did so believing their uploads took a different path, and an error is the one way that belief gets re-examined. The fuzz corpus seed for the key was converted to arejectedByLoadercase rather than deleted.Tests
internal/storage/s3/upload_path_test.gopins the boundary rather than the path, so a future second upload path has to satisfy these rather than inherit an untested seam:Content-Typereaches the stored object, parameterized over four suffixes × both sides of the multipart threshold{objectfs-sha256}— an exact set, not acargoship-prefix check, since a prefix check would pass for any future path stamping its own provenance under a different namePutObject'smetaargument (this is howvfscarries modes and ownership)All three fail on the pre-change code and were verified by mutation: dropping
ContentTypefrom the input, stamping a foreign metadata key, and dropping the caller's keys each fail the corresponding test.testaws.TestServer.ObjectContentTypewas added to read the header specifically, deliberately separate fromObjectMetadata, since confusing the two is the defect.One test nearly shipped passing for the wrong reason. The first draft set
MultipartChunkSizeto 1 MiB, below the AWS uploader's 5 MiB part minimum, so every CargoShip upload failed withpart size must be at least 5242880 bytesand fell back to the direct path — which sets the header correctly. It was green against the broken code. Caught by reading theCargoShip optimization failed, falling back to standard S3warning in the output of a run that was supposed to be failing.Verification
go test -race ./...— full suite greengo vet ./...clean, including-tags=aws_s3and-tags=integrationgolangci-linton the touched packages reports only two pre-existingcontextcheckfindings, identical to baseline with the cache cleared (the repo-widemake lintfailure is the 570 pre-existing golangci-lint issues, 385 of them paralleltest: burn down the backlog the new config surfaced #179 backlog)go mod tidydropped six transitive dependencies the transporter pulled in