Skip to content

EC2: GetSpotPlacementScores support #892

Closed

Description

@scttfrdmn

GetSpotPlacementScores returns InvalidAction (v0.116.0, substrate server).

Repro:

aws ec2 get-spot-placement-scores --instance-types g6.xlarge --target-capacity 1 --region-names us-east-1
# -> InvalidAction

Consumer / why: sonde samples SPS paired to each on-demand probe (a free signal it correlates against paid fulfillment). A modeled response — SpotPlacementScores[] with Region/AvailabilityZoneId/Score (1–10), honoring SingleAvailabilityZone — would let that pairing be tested offline. Seedable scores per (region/AZ, instance type) would be ideal.

Activity

  1. scttfrdmn commented on Sep 15, 2026

    @scttfrdmn
    OwnerAuthor

    Confirmed, and it is the #885 class again: "ec2:GetSpotPlacementScores": {} is in the generated authorization reference at emulator/authz_reference_gen.go:1075 (from authzref/ec2.json:3717), with an empty resource list meaning AWS supports no resource-level permissions for it — so the only wiring missing is the handler and its dispatch arm. Nothing else in emulator/ mentions spot placement scores.

    Verified shapes, and three corrections to the issue body

    From API_GetSpotPlacementScores, the parameter names are the query-protocol ones, which differ from the SDK field names this issue uses:

    • InstanceType.N, not InstanceTypes — "Min 0 items, Max 1000 items".
    • RegionName.N, not RegionNames — and it is capped at Max 10 items, which is the constraint most likely to matter to a caller sweeping regions.
    • TargetCapacity is the only required parameter: "Valid Range: Minimum value of 1. Maximum value of 2000000000."
    • MaxResults' floor is 10, not 1: "Valid Range: Minimum value of 10. Maximum value of 1000." That is unusual enough to be worth a test of its own — pricingLimit-style refusal rather than coercion, per iam: paginateIAMKeys silently rewrites an out-of-range MaxItems to 100 at eight operations AWS refuses #868's rule that an out-of-range page size is refused, not silently rewritten.
    • TargetCapacityUnitType: vcpu | memory-mib | units.
    • Also optional: DryRun, InstanceRequirementsWithMetadata, NextToken, SingleAvailabilityZone.

    Response is spotPlacementScoreSet, nextToken and requestId. SpotPlacementScore has exactly three members, all optional: region, availabilityZoneId, score.

    The score range is documented, so it is not substrate's invention: "The placement score, on a scale from 1 to 10. A score of 10 indicates that your Spot request is highly likely to succeed in this Region or Availability Zone. A score of 1 indicates that your Spot request is not likely to succeed."

    SingleAvailabilityZone selects which of the two members is populated, and it is either/or, which the issue's phrasing (Region/AvailabilityZoneId/Score together) does not capture: "Specify true so that the response returns a list of scored Availability Zones. Otherwise, the response returns a list of scored Regions." The page also explains why the two are not comparable: "If you request a Spot placement score for Regions, a high score assumes that your fleet request will be configured to use all Availability Zones and the capacity-optimized allocation strategy. If you request a Spot placement score for Availability Zones, a high score assumes that your fleet request will be configured to use a single Availability Zone…" — so a region score and an AZ score are answers to different questions and a caller must not read one as the other.

    The Errors section publishes nothing operation-specific: "For information about the errors that are common to all actions, see Common Error Types."

    What implementing it looks like here

    Small, because the two pieces it needs both exist:

    • AZ IDs are already modeled and already paired to zone names. ec2SeededZones(region) yields items carrying both ZoneName and ZoneID, derived by azRegionAbbrev (ec2_plugin.go:4992) over ec2SeededAZSuffixes (ec2_instancetypes.go:209), so availabilityZoneId comes out as the same use1-az1 a caller read from DescribeAvailabilityZones rather than a second, differently-derived form. That shared derivation is the whole point of ec2: CreateVolume with neither Size nor SnapshotId produces an 8 GiB volume where AWS refuses #712 and it makes SPS's AZ mode nearly free.
    • DescribeSpotPriceHistory is the structural precedent (ec2_plugin.go:5808): one stub value per catalog type per zone, from the catalog rather than from any real market.

    The one real design decision

    SpotPrice in the catalog (ec2_instancetypes.go:19-20) is explicitly documented as "deterministic stubs, not AWS prices … not researched", and a score would be the same kind of value — except worse, because a score is a prediction about capacity, and substrate models no capacity. A constant 10 (or any derived number) would be a value that does not come from where it appears to, which is the exact defect class v0.116.0 was spent removing. So the seeding this issue asks for is not a nice-to-have on top of a default; it is the honest primary interface, and the default should be a single documented constant whose provenance is stated as substrate's, not a plausible-looking spread across zones.

    ec2FleetShortfall (ec2_fleet_control.go:14-46) is the seed pattern to copy: a namespace, a key with a "*" wildcard, specific-then-wildcard resolution, and POST/DELETE control endpoints. Keying by (region-or-AZ-ID, instance type) with "*" on either axis covers what this issue asks for.

    Blocker shared with #891 and #894

    The repro uses g6.xlarge, and substrate's catalog has ten families — c5, c5a, g4dn, inf1, m5, m5a, p3, r5, t3, t3a (ec2_instancetypes.go:76-167) — with no g6, g5, p4, p5, trn1 or inf2. ec2CheckInstanceTypesExist (:241) refuses an unknown type wherever the catalog is authoritative, so an SPS query for the type in this repro would answer InvalidInstanceType before any scoring logic ran. Filed as #896.

    Sizing

    S/M — one handler, MaxResults/NextToken pagination, the either/or response mode, the seed pair, docs/services.md. Moved to v0.118.0 with #891, since it is the same consumer's pairing and shares the catalog prerequisite.

  2. added
    type: feature
    status: needs-design
    on Sep 15, 2026
  3. added this to the v0.118.0 milestone on Sep 15, 2026
  4. scttfrdmn commented on Sep 17, 2026

    @scttfrdmn
    OwnerAuthor

    Verified against API_GetSpotPlacementScores and API_SpotPlacementScore. Two wire names in the
    repro's own flags do not survive the translation to the API, and one range constraint is not what a
    reader would assume.
    Recording them before implementing, because each would produce an operation
    that accepts nothing the SDK sends.

    Wire names

    Commonly written Actual wire name
    InstanceTypes.N InstanceType.N
    RegionNames.N RegionName.N

    The CLI's --instance-types and --region-names flatten to the singular member names. Substrate's
    extractEC2Filters-style walks are prefix-driven, so a parser keyed on the plural reads an empty
    list from a request the SDK considers well-formed — and an empty RegionName.N is legal (minimum 0
    items), so the failure is silent rather than a refusal.

    MaxResults has a minimum of 10, not 1

    Valid Range: Minimum value of 10. Maximum value of 1000. This is a real Valid Range: line, not
    prose. It is the only EC2 operation I have seen in this tree whose MaxResults floor is not 1, and it
    matters because substrate's shared helper is
    ec2MaxResults(params, minResults, maxResults) — passing the usual ec2MinUnpublishedMaxResults
    (=1) here would accept MaxResults=1, which AWS refuses.

    The parameter set, with the two constraints that gate a request

    • TargetCapacity — Required: Yes, Valid Range: Minimum value of 1. Maximum value of 2000000000. The issue's repro passes --target-capacity 1, the floor.
    • InstanceType.N — Minimum number of 0 items. Maximum number of 1000 items. The page adds a
      recommendation that changes what a test should assert: "We recommend that you specify at least
      three instance types. If you specify one or two instance types … the returned placement score will
      always be low."
      The repro specifies one, so a faithful emulator's nominal answer to that exact
      command is a low score, not a mid-range one.
    • RegionName.N — Minimum number of 0 items. Maximum number of 10 items. "Enter the Region code,
      for example, us-east-1."
    • SingleAvailabilityZone — Boolean, Required: No. "Specify true so that the response returns a
      list of scored Availability Zones. Otherwise, the response returns a list of scored Regions."
      So
      criterion "honoring SingleAvailabilityZone" is exactly right, and the two modes are mutually
      exclusive in the response shape rather than additive.
    • TargetCapacityUnitType — vcpu | memory-mib | units.
    • InstanceRequirementsWithMetadata — carries a documented mutual exclusion: "If you specify
      InstanceRequirementsWithMetadata, you can't specify InstanceTypes."
    • NextToken, DryRun.

    There is no Filter.N on this operation, so it needs no ec2FilterSpec — unlike every Describe
    in the package.

    SpotPlacementScore has exactly three members, and the 1–10 range is prose only

    availabilityZoneId (String), region (String), score (Integer). No capacityAvailable, no
    ARN, no metadata.

    The issue writes Score (1–10), and 1–10 is correct — but it comes from the operation page's prose
    ("The Spot placement score for the top 10 Regions or Availability Zones, scored on a scale from 1 to
    10"
    ), not from a Valid Range: line on the member. SpotPlacementScore.score publishes no range
    constraint at all. Worth stating, because substrate's convention is to enforce published ranges, and
    this one is not published where an implementer would look for it.

    Three further pieces of prose that bear on what a seed should be allowed to express:

    • "Different Regions or Availability Zones might return the same score." — so a seed must not
      assume distinctness, and a test asserting a strict ordering would be asserting something AWS
      denies.
    • "The Spot placement score serves as a recommendation only."
    • The response is capped at the top 10 Regions or Availability Zones.

    Response elements: spotPlacementScoreSet, nextToken, requestId.

    Note on availabilityZoneId

    The member is the AZ ID (use1-az1-style), not the AZ name (us-east-1a). The issue's
    criterion writes AvailabilityZoneId, which is right, but the distinction is load-bearing for
    sonde: an AZ ID is stable per account-independent physical location whereas an AZ name is not, and
    that is precisely why AWS returns the ID here. Whatever substrate answers has to be consistent with
    whatever it answers from DescribeAvailabilityZones, or the pairing the issue describes cannot be
    correlated.

    No sample response is published

    Neither API_GetSpotPlacementScores nor API_SpotPlacementScore publishes an Examples section or
    any sample XML. The only verbatim XML on the EC2 reference is the generic error envelope. So the
    success-response element names come from the member lists above and the item-wrapper nesting
    rests on substrate's existing EC2 query-protocol rendering, not on a citation
    — that should be
    stated rather than implied.

    What this changes about the issue

    Nothing in the ask is wrong in substance. The corrections are the two wire names, the MaxResults
    floor of 10, that score's 1–10 range is prose rather than a constraint line, that the repro's
    single instance type is documented to produce a low score, and that SpotPlacementScore carries
    only three members — so there is nothing to model beyond region/AZ-ID/score.

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: ec2status: needs-designtype: feature

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions