Repository navigation
fix: cost_optimization keeps one key, and it reaches the object (#203) - #260
Merged
Merged
Conversation
`storage.s3.cost_optimization` had six keys and no effect. internal/config's S3CostOptimization and internal/storage/s3's CostOptimization shared not one field name, so buildS3Config carried a comment saying the block was not mappable — which was true, and is not a fix. `transition_to_ia: 30` had to become an element of a []TransitionRule carrying a source tier, a destination tier, an access pattern and a size filter, none of which the YAML supplied, and nothing read TransitionRules either. Five keys are deleted rather than plumbed, the same treatment #176 gave the fifteen inert read-ahead keys: `enabled` gated nothing, `tiering_enabled` names transitions no mount path invokes, and `lifecycle_enabled` / `transition_to_ia` / `transition_to_glacier` name bucket-level lifecycle rules this backend never writes. Removed, not deprecated — config decodes strictly, so a file still carrying one fails at startup naming it, which is the only way an operator learns the setting never did anything. `small_objects_on_standard` is what remains, and its behavior was corrected before being exposed. The rule was `objectSize < 128 KiB` with no reference to the configured tier, so it moved objects to STANDARD from tiers with no billing minimum at all — DEEP_ARCHIVE at ~23× the storage rate — and from the three that have one at sizes where they are still far cheaper. Being under a floor does not make STANDARD cheaper: the crossover is minBillable × rateTier / rateStandard, so 69.6 KiB on STANDARD_IA, 55.7 KiB on ONEZONE_IA, 22.3 KiB on GLACIER_IR. Three conditions now, the third computed against the prices this deployment pays. GLACIER and DEEP_ARCHIVE are excluded on a second ground: their objects need a restore to read, so a diversion would change what a read does, not only what it costs. Two further seams, each found by asserting the class recorded at the endpoint rather than the value passed in: - CargoShip drops a per-object class. Transporter.optimizeStorageClass returns its own config's StorageClass for any archive with no AccessPattern and no RetentionDays — every archive ObjectFS builds — and never reads Archive.StorageClass, the field whose comment says "Target storage class". The diverted class was computed correctly and lost at the boundary; the object stored fine, read fine, and only the invoice differed. Diverging objects now take the direct path, joining the existing compression and encryption bypasses. Filed as scttfrdmn/cargoship#352. - The billing warning described the wrong tier. ValidateWrite ran before the diversion, so an operator who enabled the setting because of that warning still saw billed_size=131072 on a 16 KiB object about to be billed as 16 KiB — and the diversion logs at Debug, so at the default level the misleading half was the only half visible. The decision now precedes validation. tier_constraints.min_object_size deliberately does not follow the effective tier: that is a floor the operator configured, and an internal cost optimization is not a reason to stop enforcing it. GetRecommendations had the identical size-only rule and is fixed the same way. It has no mount-path caller, but advice nobody can act on wrongly is still advice someone will act on. Tests, each verified by mutation: - the eight-tier table with per-tier sizes on both sides of each crossover, so a size-only implementation cannot pass it; restoring the old rule fails 7 of 8 tiers - a negotiated 90% discount on STANDARD_IA must keep a 64 KiB object there - the endpoint-level seam test, which is what caught the CargoShip drop - the billing warning follows the effective tier, stays for the undiverted case, falls back on an unknown tier name, and does not relax the operator's floor - the adapter mapping test asserted CostOptimization was the zero value and passed for the wrong reason once the mapping existed, because the fixture never set the key; it now sets it and compares the whole struct, so a new field arriving without a decision fails docs/index.md claimed "Lifecycle management: Automatic tiering to IA, Glacier, Deep Archive" as a key feature. It is now in the Not yet wired up table with the reason. Closes #203
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 #203.
storage.s3.cost_optimizationhad six keys and no effect on anything.internal/config.S3CostOptimizationandinternal/storage/s3.CostOptimizationshared not one field name, sobuildS3Configcarried a comment saying the block was not mappable — true, and not a fix. There was no mapping to write:transition_to_ia: 30had to become an element of a[]TransitionRulecarrying a source tier, a destination tier, an access pattern and a size filter, none of which the YAML supplied, and nothing readTransitionRuleseither.Breaking: five keys removed
Removed, not deprecated. Configuration decodes strictly, so a file still carrying one fails at startup naming the key — which is the only way an operator learns the setting never did anything. A block with no effect for its entire existence has no behavior to preserve.
enabledtiering_enabledlifecycle_enabledtransition_to_iatransition_to_glacierSame treatment #176 gave the fifteen inert read-ahead keys, and the fourth instance of the shape #156, #176 and the
cluster.redisfix were — in its worst form, since the two types could not be reconciled without deleting first.The surviving key, corrected before being exposed
small_objects_on_standard(defaultfalse) stores an object on STANDARD when the configured tier would bill it as larger than it is and STANDARD is genuinely cheaper.The old rule was
objectSize < 128 KiBwith no reference to the configured tier. It moved objects to STANDARD from tiers with no billing minimum at all — DEEP_ARCHIVE at ~23× the storage rate — and from the three that have one at sizes where they remain far cheaper. Being under a floor does not make STANDARD cheaper. The crossover isminBillable × rateTier / rateStandard:A 32 KiB object billed as 128 KiB of GLACIER_IR costs about a third of 32 KiB on STANDARD. Three conditions are now required, the third computed against the prices this deployment pays (volume/enterprise discounts and
CustomPricingincluded).GLACIER and DEEP_ARCHIVE are excluded on a second, non-monetary ground: their objects cannot be read without a restore, so a diversion would change what a read does, not only what it costs. A cost heuristic must not decide retrieval semantics.
Two seams, both found at the endpoint
Both were found by asserting the storage class S3 recorded, not the value passed in — the technique that found the
INTELLIGENT_TIERINGdefault in v0.10.1.CargoShip drops a per-object class.
Transporter.optimizeStorageClassreturns its own config'sStorageClass— fixed at construction fromstorage_tier— for any archive with noAccessPattern/RetentionDays, which is every archive ObjectFS builds. It never readsArchive.StorageClass, the field whose comment says "Target storage class". The class was computed correctly and lost at the boundary: object stored fine, read fine, only the invoice differed. Diverging objects now take the directPutObjectpath, joining the existing bypasses for compression and for encryption modes the transporter cannot express; the common path keeps CargoShip's throughput optimization. Filed upstream as scttfrdmn/cargoship#352 —OptimizedTransporter, a different type ObjectFS does not construct, already honors the field.The billing warning described the wrong tier.
ValidateWriteran before the diversion, so an operator who enabled the setting because of that warning still sawbilled_size=131072on a 16 KiB object about to be stored on STANDARD and billed as 16 KiB. The diversion logs at Debug, so at the default level the misleading half was the only half visible. The tier decision now precedes validation, viaValidateWriteToTier.tier_constraints.min_object_sizedeliberately does not follow the effective tier: that is a floor the operator configured for this mount, and an internal cost optimization is not a reason to stop enforcing it.TierValidator.GetRecommendationshad the identical size-only rule and is fixed the same way. No mount-path caller — it is exported API — but advice nobody can act on wrongly is still advice someone will act on.Tests, each verified by mutation
StorageTierInfomeans "no minimum", so an unrecognized name must not reach the checks as one), and does not relax the operator's floor.TestBuildS3ConfigMapsEveryConfiguredValueassertedCostOptimizationwas the zero value — and kept passing once the mapping existed, for the wrong reason, because the fixture never set the key. It now sets it and compares the whole struct, so a new field arriving without a decision fails.Two
s3.CostOptimizationfields survive as Go fields with no YAML key, deliberately:EnableAutoTieringandCostThresholdare reachable to an embedder using the package as a library, while a mount has no path toAnalyzeAndOptimize.MonitorAccessPatternsis likewise unmapped, and for a second reason — the map it populates holds one entry per distinct key read and nothing evicts.docs/index.mdclaimed "Lifecycle management: Automatic tiering to IA, Glacier, Deep Archive" as a key feature; it is now in the Not yet wired up table with the reason.Verification
go build ./...,go vet ./...,go test -race ./...— all cleangolangci-lint run --new-from-merge-base=origin/main— 0 issues./scripts/coverage-gate.sh— 30 packages at or above their floorsAlso updated:
examples/config.yaml,docs-platform/guide/getting-started.md,sdks/python/README.mdandsdks/python/objectfs/config.py— the Python SDK's default config wrote three of the removed keys asTrue, soto_yaml()produced a document asking for tiering and lifecycle management that would now fail the Go loader.