Repository navigation
Description
internal/config.S3CostOptimization and internal/storage/s3.CostOptimization are both "the cost optimization settings," and they share not one field name:
// internal/config/config.go:392 — what the YAML schema accepts
type S3CostOptimization struct {
Enabled bool `yaml:"enabled"`
TieringEnabled bool `yaml:"tiering_enabled"`
LifecycleEnabled bool `yaml:"lifecycle_enabled"`
TransitionToIA int `yaml:"transition_to_ia"`
TransitionToGlacier int `yaml:"transition_to_glacier"`
}
// internal/storage/s3 — what the backend actually reads
type CostOptimization struct {
EnableAutoTiering bool `yaml:"enable_auto_tiering"`
TransitionRules []TransitionRule `yaml:"transition_rules"`
LifecycleManagement bool `yaml:"lifecycle_management"`
IntelligentTiering bool `yaml:"intelligent_tiering"`
CostThreshold float64 `yaml:"cost_threshold"`
MonitorAccessPatterns bool `yaml:"monitor_access_patterns"`
}Disjoint names, disjoint types (int day-counts vs a []TransitionRule), and no conversion between them anywhere. So the cost-optimization block a user writes in YAML cannot reach the backend even in principle — there is no mapping to write without deciding what transition_to_ia: 30 means in terms of TransitionRules.
This is the same seam that produced the v0.10.1 config-plumbing class, in its worst form: the other cases were fields dropped by an incomplete mapping, and this is two independent designs of the same feature that were never reconciled.
Related and load-bearing: MonitorAccessPatterns has no representation on the config side at all, and it is the flag that gates costOptimizer.accessPatterns — the unsynchronized map written from GetObject. That map's data race is currently latent only because the flag cannot be set from config. So the reconciliation must not enable it before the map is synchronized, or plumbing this config introduces a race. Same ordering hazard as CargoShip/Content-Encoding (#153): wire the safety first, the config second.
Do:
- Decide which shape is the contract. The
s3one is richer and is what the code reads; theconfigone is what users have been writing. If thes3shape wins, the YAML keys change and that is a breaking change for a block that never worked — worth stating plainly in the changelog rather than quietly. - Synchronize
accessPatternsbefore exposingMonitorAccessPatterns. - Map field-by-field with a test asserting output values, per the v0.10.1 pattern.
Verification: a test that loads a YAML cost-optimization block and asserts what the backend received; and -race with MonitorAccessPatterns on under concurrent GetObject, which is the case that must be green before the flag is reachable.
Activity