Skip to content

Launch into a Capacity Reservation / Capacity Block: wire the dead --reservation flags through to RunInstances #216

Closed

Description

@scttfrdmn

Summary

spawn has the scaffolding to launch into an EC2 Capacity Reservation / Capacity Block for ML, but none of it is connected — the flags, the config field, and the truffle hand-off all exist, yet the value never reaches RunInstances. Launching into a reservation is currently impossible.

What exists but is dead

  • Flags defined, never read: cmd/launch.go:237 --use-reservation (bool), cmd/launch.go:238 --reservation-id (string), bound to useReservation/reservationID (cmd/launch.go:71-72). Those variables appear only at declaration + flag binding — never consumed.
  • Config field defined, never populated/used: LaunchConfig.ReservationID (pkg/aws/client.go:127, "On-Demand Capacity Reservation ID to target").
  • truffle hand-off exists but is dropped: TruffleInput.ReservationID (pkg/input/parser.go:26, JSON reservation_id) is parsed, but the truffle-input → config copy in cmd/launch.go (~2019-2029) copies only InstanceType/Region/AZ/Spot — never ReservationID.
  • RunInstances never sets it: pkg/aws/client.go (~330-462) sets InstanceMarketOptions for Spot only (MarketType: MarketTypeSpot, line 436). It never sets CapacityReservationSpecification, and never MarketType: capacity-block.

What launching into a reservation requires

Two distinct cases — both need wiring:

  1. On-Demand Capacity Reservation (ODCR) or an open Capacity Block you own: set
    RunInstancesInput.CapacityReservationSpecification.CapacityReservationTarget.CapacityReservationId = <id>.
  2. Consuming a Capacity Block for ML: Capacity Blocks additionally require
    InstanceMarketOptions.MarketType = "capacity-block" (and the instance must land in the reservation's specific AZ — the reservation is AZ-pinned, so spawn must place the instance there, tying into the [FSx] --fsx-create ignores --az: filesystem always lands in subnets[0], not the pinned AZ #208 AZ-co-location work).

Proposal

  • Make --reservation-id (and a --capacity-block / market-type signal) actually flow: flag → LaunchConfig.ReservationID (+ a CapacityBlock bool or market-type field) → RunInstances.
  • Copy ReservationID from truffle input in the launch path (close the dropped hand-off).
  • In RunInstances: when a reservation id is set, build CapacityReservationSpecification; when it's a Capacity Block, also set InstanceMarketOptions.MarketType = capacity-block. Pin the instance to the reservation's AZ (reuse the [FSx] --fsx-create ignores --az: filesystem always lands in subnets[0], not the pinned AZ #208 subnet-for-AZ resolution).
  • Guardrails: a reservation is AZ- and instance-type-specific; validate/derive the AZ from the reservation rather than letting --az conflict. Spot + capacity-block are mutually exclusive market options — reject the combination.

Out of scope

  • Purchasing a Capacity Block (the paid write op) is a separate issue (per the maintainer decision, purchase lives in spawn — filed separately). This issue is launch into an already-reserved block/reservation.
  • Discovering offerings is truffle's job (filed on truffle).

Tests / docs

  • Unit test that RunInstancesInput carries CapacityReservationSpecification (and MarketType=capacity-block for CB) when set, and does not when unset (back-compat).
  • Test the truffle-input → config ReservationID copy (currently silently dropped — mirrors the lagotto#19 "snake_case keys dropped" class of bug).
  • README + CHANGELOG.

Refs

#208 (FSx/instance AZ co-location — reservations are AZ-pinned, same mechanism), truffle Capacity Blocks discovery issue, spawn Capacity Block purchase issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions