Skip to content

C0-5: Honor the configured storage tier in the CargoShip transporter #158

Closed

Description

@scttfrdmn

Summary

NewClientManager hardcodes INTELLIGENT_TIERING for the CargoShip transporter, ignoring
cfg.StorageTier. Since the standard path honors the configured tier, an object's storage
class ends up depending on which upload path it happened to take.

Background

internal/storage/s3/client.go NewClientManager:

cargoConfig := awsconfig.S3Config{
    Bucket:             bucket,
    StorageClass:       awsconfig.StorageClassIntelligentTiering, // Intelligent tiering
    MultipartThreshold: cfg.MultipartThreshold,
    MultipartChunkSize: cfg.MultipartChunkSize,
    Concurrency:        cfg.MultipartConcurrency,
}

A mount configured for DEEP_ARCHIVE writes INTELLIGENT_TIERING through the transporter and
DEEP_ARCHIVE through the standard client — a cost and lifecycle discrepancy that varies per
object. ConvertTierToCargoShipStorageClass in internal/storage/s3/tiers.go already exists
and is exactly the right call.

Scope limit worth knowing before starting. CargoShip's config.StorageClass
([email protected]/pkg/aws/config/config.go) defines only six constants: STANDARD,
STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE. The AWS SDK
([email protected]/types/enums.go) defines thirteen, including EXPRESS_ONEZONE, FSX_ONTAP,
FSX_OPENZFS, SNOW, and OUTPOSTS. So:

  • ConvertTierToStorageClass can gain the newer classes — but that also needs new
    Tier* constants and StorageTiers entries, because NewTierValidator silently downgrades
    an unrecognized tier to STANDARD, which would make a typo look like it worked.
  • ConvertTierToCargoShipStorageClass cannot, absent an upstream change. Note the
    existing GLACIER_IR → GLACIER arm is already a lossy substitution of this kind.

Implementation

  1. Call ConvertTierToCargoShipStorageClass(cfg.StorageTier) instead of the hardcoded constant.
  2. When the configured tier has no faithful CargoShip equivalent, skip the transporter and
    use the standard path rather than silently substituting a different storage class. Log the
    decision at INFO. Wrong tier is a billing and durability problem; slower upload is not.
  3. Add EnableCargoShipOptimization to buildS3Config — it defaults true in
    s3.NewDefaultConfig but is false on the mount path today, so the transporter is never
    constructed there at all.
  4. Optionally revisit the GLACIER_IR → GLACIER substitution under the same rule as (2).

Adding the newer AWS storage classes to ConvertTierToStorageClass is genuinely useful but
is a separate change with its own StorageTiers work; keep it out of this issue unless it
comes for free.

Acceptance Criteria

  • The CargoShip transporter receives the storage class derived from cfg.StorageTier
  • A tier CargoShip cannot express falls back to the standard path, with an INFO log, and
    never silently uploads under a different storage class
  • EnableCargoShipOptimization reaches the backend from buildS3Config
  • Table-driven test covers every tier in StorageTiers, asserting either a faithful
    CargoShip class or the documented fallback
  • go test -race ./internal/storage/s3/... ./internal/adapter/... passes
  • Integration check: an object uploaded to a STANDARD_IA-configured mount reports
    StorageClass: STANDARD_IA from HeadObject

Dependencies

Blocked on C0-1 (#153). Item 3 activates the CargoShip path on the mount, which is
exactly what makes the Content-Encoding corruption reachable. Do not plumb the flag first.

Activity

  1. added
    type: bug
    priority: medium
    area: s3
    on Jul 29, 2026
  2. scttfrdmn commented on Jul 30, 2026

    @scttfrdmn
    OwnerAuthor

    Correction: the proposed fix targets dead code

    Follow-up verification against the vendored dependency shows the fix as written would have no effect, and the real lever is narrower than described.

    ConvertTierToCargoShipStorageClass is already dead code on this path. backend.go computes cargoStorageClass := ConvertTierToCargoShipStorageClass(effectiveTier) and sets it on the Archive, but CargoShip ignores it. Transporter.optimizeStorageClass ([email protected]/pkg/aws/s3/transporter.go:143) opens with:

    func (t *Transporter) optimizeStorageClass(archive Archive) types.StorageClass {
    	// Use configured default if no optimization criteria
    	if archive.AccessPattern == "" && archive.RetentionDays == 0 {
    		return types.StorageClass(t.config.StorageClass)
    	}
    	...

    ObjectFS never sets AccessPattern or RetentionDays on the Archive it builds, so this first branch always wins and archive.StorageClass is never read. The per-object tier is discarded; the per-client awsconfig.S3Config.StorageClass decides everything.

    Consequence for the fix. The only effective change is the hardcoded StorageClass: awsconfig.StorageClassIntelligentTiering in NewClientManager (internal/storage/s3/client.go:121) — a per-client setting. That means the CargoShip path cannot honor per-object tier decisions at all, including any downgrade computed by HandleStandardTierOverhead. Setting it correctly from cfg.StorageTier fixes the configured-tier case but leaves per-object variation unsupportable.

    Two viable routes:

    • Set the client-level StorageClass from cfg.StorageTier and skip the transporter for any object whose effective tier differs from the client default. Correct, no upstream change, loses the optimization for the divergent minority.
    • Populate AccessPattern/RetentionDays to steer optimizeStorageClass into its other branches. Fragile — it means encoding our tier decision as a hint and hoping the upstream heuristic reproduces it. Not recommended.

    Either way, delete or repurpose the now-provably-dead ConvertTierToCargoShipStorageClass call so the code stops implying a per-object tier is honored.

    Unchanged: the six-constant limit on awsconfig.StorageClass ([email protected]/pkg/aws/config/config.go:186-191) versus thirteen in the AWS SDK still holds, and the lossy GLACIER_IR -> GLACIER arm (tiers.go:273-274) is still a wrong-tier substitution worth removing.

    Also note the ordering hazard is now sharper. This issue plumbs EnableCargoShipOptimization into buildS3Config, which is what first makes the CargoShip branch reachable from a real mount. That branch carries the #153 corruption. #153 must land first.

  3. scttfrdmn commented on Aug 2, 2026

    @scttfrdmn
    OwnerAuthor

    Fixed in v0.10.1. The CargoShip upload path now converts the effective tier with ConvertTierToCargoShipStorageClass and sets Archive.StorageClass, so a configured tier reaches the transporter instead of being dropped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: s3priority: mediumtype: bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions