Skip to content

Migrate S3 transfers off the deprecated feature/s3/manager to transfermanager (#932) - #974

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/932
Oct 16, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/932

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #932

What

All 16 SA1019 sites in four packages move from feature/s3/manager to feature/s3/transfermanager v0.4.16:

  • pkg/agent/queue_runner.go: spored's job and queue result uploads
  • pkg/aws/imagebuilder.go: UploadISOToS3
  • pkg/pipeline/data_handoff.go: stage output upload, stage input download, DownloadResultsToLocal
  • pkg/staging/staging.go: UploadScheduleParams

Every client is built through a new internal package, pkg/s3transfer. Its New starts from manager's behaviour, not transfermanager's defaults, because three of these callers run inside spored and a change there shows up only on hardware.

manager (before) transfermanager default s3transfer.New
part size 5 MiB 8 MiB 5 MiB
multipart threshold = part size 16 MiB = part size (WithPartSize moves both)
concurrency 5 5 5
download ranged GETs of one part size part-number GETs ranged (GetObjectRanges)
upload checksum CRC32 (WhenSupported) CRC32 (WhenSupported) unchanged
download validation ChecksumMode=ENABLED via the s3 client ChecksumMode=ENABLED unchanged
empty object, ranged GET (416) empty file empty file unchanged

imagebuilder.go keeps its 64 MiB parts and concurrency 4 through WithPartSize/WithConcurrency, so an ISO under 64 MiB is still a single PutObject.

One behaviour difference I couldn't avoid: transfermanager buffers each part in memory. It allocates a pool of concurrency+1 parts up front plus the first part. Manager read an *os.File in place through a SectionReader. An upload larger than one part therefore holds about 35 MiB by default, or about 384 MiB for an ISO. This is in the CHANGELOG.

The SDK modules move up to what transfermanager requires (service/s3 v1.102.2 to v1.114.3, aws-sdk-go-v2 v1.47.3, smithy-go v1.28.5). Root, lambda/sweep-orchestrator and lambda/ttl-reaper are re-tidied. go.mod no longer requires feature/s3/manager, and grep -rn 'feature/s3/manager' --include=*.go . is empty. The public-surface snapshot is unchanged: no exported symbol in pkg/aws or pkg/storage moved, and api_surface_test.go passes.

Tests (Substrate, no AWS)

  • pkg/s3transfer/s3transfer_test.go asserts manager's documented behaviour against the requests sent, recorded by a new testutil.S3Recorder:
    • at 5 MiB−1, a single PutObject;
    • at 5 MiB+1, CreateMultipartUpload plus 2 UploadParts;
    • at 11 MiB, 3 parts (transfermanager's own threshold would make it a single PutObject);
    • after WithPartSize(8 MiB), 7 MiB is single and 9 MiB is 2 parts;
    • a CRC32 is stored for single and multipart uploads;
    • a 12 MiB download is exactly 3 GETs with Range: bytes=0-5242879 first and no partNumber;
    • an empty object downloads.
  • At each call site:
  • Gate TestTransferClientsAreBuiltByNew parses every Go file in the repo, nested modules included, and resolves import aliases. It fails on a transfermanager.New call outside pkg/s3transfer and on any import of the old package. It fails if it walks fewer than 100 files.

Each test failed against a revert that compiles:

  • Dropping the threshold, part size and range mode from New:
    • CreateMultipartUpload calls = 0, want 1
    • GET requests = 1, want 3
    • 1 part-number GETs
  • Dropping the threshold from WithPartSize: PutObject calls = 0, want 1
  • Setting RequestChecksumCalculation=WhenRequired: no CRC32 checksum stored
  • Removing imagebuilder's WithPartSize: UploadPart calls = 13, want 2
  • Removing staging's Tagging: want one PutObject carrying x-amz-tagging ..., got 0
  • tm.New in imagebuilder: the gate reports it.
  • A temporary file importing the old package: the gate reports it.

make check: everything passes except the known Docker-only TestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker. make check-nested, make check-tidy and make check-docs are clean. The new code has no staticcheck findings.

Coordination with #938

#938 (still open) adds line-scoped //lint:ignore SA1019 ... (#932) comments on these 16 uses. This PR removes the uses, so whichever lands second has to drop them. If this merges first, #938's ignores become unused-directive findings and conflict on the edited lines, and #938 should delete them when it rebases. If #938 merges first, this PR needs a rebase that deletes them.

Not verified

  • Behaviour on real S3 and inside spored on an instance. No AWS resources were used.
  • Concurrency 4 for ISOs is set but not observed. A test would need about 5 × 64 MiB in flight.

@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 52.70270% with 35 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/testutil/s3requests.go 0.00% 33 Missing ⚠️
pkg/s3transfer/s3transfer.go 84.61% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

…rmanager (#932)

The four packages that used manager's Uploader/Downloader (pkg/agent queue
results, pkg/aws ISO staging, pkg/pipeline stage data and results,
pkg/staging schedule params) now build a feature/s3/transfermanager client
through a new pkg/s3transfer.New, which starts from manager's behaviour
rather than transfermanager's defaults:

- 5 MiB parts, not 8 MiB, for uploads and ranged downloads;
- a multipart threshold equal to the part size (manager's rule), not a
  fixed 16 MiB; WithPartSize moves both, so imagebuilder keeps 64 MiB
  parts and its single-PutObject cutoff, with WithConcurrency(4);
- downloads as ranged GETs, not part-number GETs;
- 5 concurrent parts, and CRC32 upload checksums under WhenSupported (both
  already the same in both libraries).

Tests against Substrate (no AWS): pkg/s3transfer asserts the request
shapes (PutObject vs CreateMultipartUpload/UploadPart counts at the
boundaries, 5 MiB Range headers, no partNumber GETs, a stored CRC32, an
empty object downloads), each call site round-trips through the emulator
(multipart sizes and empty files), and a gate fails if any Go file calls
transfermanager.New outside pkg/s3transfer or imports the old package.

The SDK modules move up to the versions transfermanager v0.4.16 requires
(service/s3 v1.114.3); root and nested modules are re-tidied.

Fixes #932
@scttfrdmn
scttfrdmn merged commit b91e5de into main Oct 16, 2026
8 checks passed
@scttfrdmn
scttfrdmn deleted the fix/932 branch October 16, 2026 18:41
scttfrdmn added a commit that referenced this pull request Oct 17, 2026
…#1036)

* Make the path validators correct on Windows, and follow links (#1000)

ValidatePathForReading compared filepath.Abs against /etc-style prefixes,
so on Windows it refused nothing. It now applies the host's rules:

- Windows: refuses the Windows directory, ProgramData and System Volume
  Information (case-insensitive, either separator), UNC and \\?\, \\.\,
  \??\ prefixes, alternate data streams, reserved device names, and
  elements ending in a dot or space.
- Every OS: any ".." element (before cleaning), NUL bytes, case-insensitive
  root comparison (macOS /ETC), and symlink/junction resolution of the
  longest existing prefix via filepath.EvalSymlinks; /private/etc and
  /var/root added for macOS.

spored's queue runner now validates every glob match, not only the
pattern, so a wildcard or a link through an allowed directory cannot
upload a system file.

ValidateMountPath describes a Linux instance path and now uses package
path on every host; SanitizePath output is forward-slashed everywhere.

Tests: host-neutral table plus build-tagged POSIX and Windows tables
(drive letters, UNC, ADS, device names, junctions, 8.3 short names); the
Windows string rules are also unit-tested on every OS.

(#1000)

* go mod tidy after rebase

* Build the queue-runner test's uploader with s3transfer.New after #974 (#1000)

* Windows CI: run pkg/security now that its validators handle Windows paths (#1000)

* go mod tidy after rebase

* Resolve junctions on Windows with GetFinalPathNameByHandle (#1000)

Since Go 1.23 (GODEBUG winsymlink=1) os.Lstat reports a junction or mount
point as ModeIrregular and filepath.EvalSymlinks no longer follows it, so a
junction to C:\Windows passed ValidatePathForReading. On Windows, open the
longest existing prefix with FILE_FLAG_BACKUP_SEMANTICS and use
GetFinalPathNameByHandle; refuse a reparse point that cannot be resolved.
POSIX keeps EvalSymlinks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate off deprecated feature/s3/manager to feature/s3/transfermanager (16 SA1019 sites suppressed in #923)

1 participant