Skip to content

fix: a tier's billing minimum is not a reason to refuse a write - #242

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/154-tier-min-size
Aug 3, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/154-tier-min-size

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes #154.

A mount on STANDARD_IA, ONEZONE_IA, or GLACIER_IR could not create anything: mkdir failed, touch failed, and so did writing any file under 128 KiB.

AWS's per-tier minimum object size is a billing floor — S3 stores a zero-byte STANDARD_IA object and bills it as 128 KiB. TierValidator.ValidateWrite enforced it as an API restriction, and PutObject calls it before anything else. Both of the ways this filesystem brings a name into existence go under that floor: Mkdir writes a zero-byte marker object so an empty directory is distinguishable from a prefix that never existed, and a Create plus a small write flushes a small object. So the three tiers most of the cost documentation recommends were the three a filesystem could not be used on, and an IA-tier integration test could not get past its own setup.

What changed

  • AWS's floor warns, naming the size written alongside the size that will be billed. That gap is the actionable fact: a tier billing every object as 128 KiB is more expensive than STANDARD for a workload of small files, and nothing downstream would have mentioned it.
  • tier_constraints.min_object_size still refuses. An operator who sets it has asked for a floor that is not AWS's; a policy someone chose is the only kind worth enforcing. The refusal message says whose rule it is, so it does not send the reader to the AWS docs to find that S3 accepts the write.
  • The sharp edge that split leaves is tested rather than left to be rediscovered: setting the constraint to the tier's own published minimum reinstates exactly the old gate, zero-byte directory markers included.
  • adapter.go's note on why TierConstraints is deliberately unmapped now records that MinObjectSize is the one field in it that can refuse a write, so if it is ever mapped it has to stay unset by default.

ValidateSize, which the issue also names, does not exist. The other caller is Backend.ValidateObjectForTier, which delegates straight to ValidateWrite and is therefore consistent by construction.

Tests

Pinned at both layers, because the gate is enforced two below the operation that trips it:

  • internal/storage/s3/tier_min_size_test.go — a zero-byte write is accepted on every tier with a minimum, and the warning carries the written size, the billed size, the tier, and the key. A test that only checks err == nil cannot tell "warned about the billing" from "said nothing", and saying nothing is the failure mode that matters: the write succeeds either way and the operator finds out from an invoice.
  • internal/fuse/tier_min_size_test.go — real Mkdir and Create calls through a go-fuse bridge against a real substrate endpoint, on every tier with a minimum, read from StorageTiers so a class that gains one later is covered without editing the test. Only this layer establishes that a mkdir is a zero-byte PUT, which is the step that turned a billing hint into an unusable mount.
  • tier_test.go's "Standard-IA should reject objects smaller than 128KB" assertion is reversed, with the reason in place.

Writing this surfaced a related property worth recording in the test: touch f alone cannot exercise a write gate at all. A file created and never written flushes through Flusher.attemptAttrOnly, which finds no object to carry the metadata and deliberately stores nothing — so the FUSE-level test writes 9 bytes, and says why.

Verified by mutation

restore the old hard gate       → 12 assertions fail at the validator,
                                  every mkdir fails at the mount
drop the warning, keep accept   → 12 assertions fail
ignore the operator constraint  → TestConfiguredMinimumStillRefusesTheWrite fails

Local checks

  • go build ./..., go vet ./... clean
  • go test -race ./internal/... ./pkg/... — all pass
  • golangci-lint run --new-from-merge-base=origin/main — 0 issues
  • coverage: internal/storage/s3 82.4% (floor 81), internal/fuse 66.2% (floor 59)

A mount on STANDARD_IA, ONEZONE_IA, or GLACIER_IR could not create anything.
mkdir failed, touch failed, and so did writing any file under 128 KiB.

AWS's per-tier minimum object size is a billing floor: S3 stores a zero-byte
STANDARD_IA object and bills it as 128 KiB. TierValidator.ValidateWrite enforced
it as an API restriction, and PutObject calls it before anything else. Both ways
this filesystem brings a name into existence land under the floor — Mkdir writes
a zero-byte marker so an empty directory is distinguishable from a prefix that
never existed, and Create plus a small write flushes a small object. The three
tiers the cost documentation recommends were the three a filesystem could not be
used on.

It warns now, carrying the size written and the size billed, which is the
actionable fact: a tier that bills every object as 128 KiB costs more than
STANDARD for a workload of small files, and nothing downstream would say so.

tier_constraints.min_object_size still refuses. An operator who sets it has asked
for a floor that is not AWS's, and a policy someone chose is the only kind worth
enforcing. The sharp edge that leaves — setting it to the tier's own published
number reinstates the old gate exactly, zero-byte markers included — is tested
rather than left to be rediscovered.

Pinned at both layers, because the gate is enforced two below the operation that
trips it. The validator's tests assert the zero-byte write is accepted and that
the warning names both sizes; a test in internal/fuse drives real Mkdir and
Create against a real endpoint on every tier with a minimum, read from
StorageTiers so a class that gains one later is covered without an edit. Only
that second layer establishes that a mkdir is a zero-byte PUT, which is the step
that turned a billing hint into an unusable mount. Both verified by mutation:
restoring the hard gate fails 12 assertions at the validator and every mkdir at
the mount; removing the warning while keeping the accept fails 12.

Also records, where adapter.go explains why TierConstraints is left unmapped,
that MinObjectSize is now the one field in it that can refuse a write — so if it
is ever mapped from config it has to stay unset by default.

Closes #154
@scttfrdmn
scttfrdmn merged commit 970f6ae into main Aug 3, 2026
23 checks passed
@scttfrdmn
scttfrdmn deleted the fix/154-tier-min-size branch September 20, 2026 05:25
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.

C0-2: Downgrade tier MinObjectSize from a write gate to a billing warning

1 participant