Skip to content

config: the two CostOptimization types are disjoint, so the YAML block cannot reach the backend at all #203

Closed

Description

@scttfrdmn

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:

  1. Decide which shape is the contract. The s3 one is richer and is what the code reads; the config one is what users have been writing. If the s3 shape 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.
  2. Synchronize accessPatterns before exposing MonitorAccessPatterns.
  3. 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

  1. added
    type: bug
    priority: medium
    area: s3
    area: config
    area: cost
    effort: small
    on Aug 2, 2026
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: configarea: costarea: s3effort: smallpriority: mediumtype: bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions