Skip to content

--proximity-from and --cost-tier are accepted, validated, persisted, and ignored #864

Closed

Description

@scttfrdmn

Found while de-duplicating region filtering for #811.

spawn launch accepts two flags that have no effect on anything:

--proximity-from string   Prefer regions close to this region (e.g., us-east-1)
--cost-tier string        Prefer cost tier: low, standard, premium

What actually happens to them:

  1. Validated. ValidateConstraint rejects a cost tier outside low|standard|premium and a proximity region that fails IsValidRegion. So a typo produces a real error, which is strong evidence to a user that the flag is wired up.
  2. Persisted. Both are carried on sweep.RegionConstraint with dynamodbav tags and written to the sweep record, so they show up in stored state.
  3. Never read. The only consumers are regions.ScoreRegions and regions.GetRegionsByPriority in pkg/regions/priority.go, and both have zero callers anywhere in the repo — verified with a quoted-glob grep over cmd/ and pkg/ (an earlier unquoted --include=*.go silently errored and reported zero for everything, so this was re-run).

So region selection ignores them completely.

The output made it worse

shouldApplyRegionConstraints() returns true if any of include/exclude/geographic/proximity/cost-tier is set. So spawn launch ... --cost-tier low with no other region flag entered the constraint branch and printed:

🌍 Applied region constraints: N regions allowed
   Filtered regions: [... every region ...]
   Constraint: cost_tier=low

N being every region, with nothing filtered. The message asserts a constraint was applied; the only honest reading of it is wrong.

What has been done, and what hasn't

Shipped in the #811 de-duplication PR, because it is a string change rather than a product decision:

  • the flag help on both now says RECORDED BUT NOT YET APPLIED: region ordering by proximity/cost tier is not implemented, so this does not change which regions are selected;
  • the sweep output adds a NOTE: line naming whichever of the two was supplied and saying it did not change the selection above;
  • pkg/regions/priority.go is retained with a comment explaining why. Dead-code inventory: ~3,980 unreachable non-test lines, plus two stranded-deployment inverses #811 lists it for deletion and it is genuinely unreferenced — but it is the only implementation of what these two flags promise, and deleting it would convert a wiring gap into a design decision taken by accident.

The decision itself is open, and it is the #783 question again — finish it or withdraw it:

  • Finish it: wire ScoreRegions/GetRegionsByPriority into region selection. Needs a design answer first, because the sweep path takes its candidate regions from a parameter file: does scoring reorder them, cap them, or only break ties? --proximity-from implies a distance metric (priority.go has haversine over RegionMetadata.LatLong) and --cost-tier implies a per-region cost classification — check that AllAWSRegions actually carries a usable tier before committing.
  • Withdraw it: remove both flags and priority.go. This is a user-visible removal, so MINOR, and it needs a deprecation note since the values are already persisted in existing sweep records — a reader of old records would otherwise find fields nothing explains.

Either way the half-state should not persist: a validated, stored, documented flag that does nothing is worse than an absent one, because the validation is what convinces the user it works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions