Documentation
¶
Overview ¶
Package launch is Prism's seam over the instance launch/lifecycle engine.
It defines a narrow, host-owned Launcher port expressed entirely in terms of spore.host/spawn's types, plus a pure mapping from Prism's already-resolved launch inputs into a spawn.LaunchConfig. The real *spawn.Client satisfies Launcher directly (see the compile-time assertion below), and so does the EC2-backed default implementation that lives in pkg/aws. This mirrors the pattern proven in the sibling project prp (pkg/engine).
pkg/launch is deliberately dependency-light: it imports spawn's types and Prism's shared types only, never pkg/aws. That keeps the mapping unit-testable without an AWS client and lets pkg/aws depend on pkg/launch rather than the other way around.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToLaunchConfig ¶
func ToLaunchConfig(in Inputs) spawn.LaunchConfig
ToLaunchConfig maps resolved Prism launch inputs into a spawn.LaunchConfig.
It is a pure function: given the same Inputs it always returns the same config, with no AWS calls, clock reads, or environment lookups. Those impure concerns are resolved upstream and passed in via Inputs (notably Tags).
Types ¶
type Inputs ¶
type Inputs struct {
InstanceType string
Region string
AMI string
// Networking, resolved by NetworkingResolver.
SubnetID string
SecurityGroupID string
KeyName string
// UserDataEncoded is the gzip-compressed, base64-encoded cloud-init script.
// spawn passes UserData verbatim to RunInstances, so this encoding is
// preserved end to end.
UserDataEncoded string
// PrimaryUsername is the template's primary Linux user.
PrimaryUsername string
// RootVolumeGB is the resolved root EBS size (template default already applied).
RootVolumeGB int
// Hibernate reflects req.IdlePolicy after the idle/spot-conflict and
// hibernation-support validations have already passed in pkg/aws.
Hibernate bool
// Spot requests a one-time spot instance.
Spot bool
// SpotMaxPrice is an optional max spot price in $/hr (e.g. "0.50"); only
// meaningful with Spot. Empty = the on-demand-capped default.
SpotMaxPrice string
// EFA requests an Elastic Fabric Adapter network interface (opt-in; the
// caller validates the instance type is EFA-capable before mapping).
EFA bool
// PlacementGroup is an optional cluster placement group name for
// tightly-coupled / MPI workloads.
PlacementGroup string
// CapacityReservationID targets a pre-reserved EC2 Capacity Block (req.CapacityBlockID).
CapacityReservationID string
// IAMInstanceProfile is the resolved instance-profile name, or "" when the
// profile does not exist (the check runs in pkg/aws before mapping).
IAMInstanceProfile string
// HourlyRate is the true per-hour compute rate, threaded through for
// spawn's spawn:price-per-hour tag and Prism's cost seed.
HourlyRate float64
// Name is the workspace/instance name.
Name string
// Tags is the fully-built EC2 tag set (including the prism:-namespaced
// lifecycle tags spored reads), constructed in pkg/aws where version,
// current user, and test-mode are known. spawn appends these verbatim.
Tags map[string]string
}
Inputs carries the already-resolved values Prism computes during its launch pipeline (template extraction, networking resolution, user-data encoding, IAM profile check) into the pure ToLaunchConfig mapping. Everything here is resolved upstream in pkg/aws so that ToLaunchConfig stays free of AWS calls and side effects, and can be unit-tested without a client.
Phase 1 deliberately maps only the "what to launch" fields that reproduce today's RunInstances behavior. spawn's own lifecycle fields (TTL, IdleTimeout, DNSName, HibernateOnIdle, Slack…) are intentionally left unset: those values travel as prism:-namespaced entries in Tags so the already-deployed spored (SPORED_TAG_PREFIX=prism) keeps reading them unchanged. See the Phase 2 tag-namespace note in the plan.
type Launcher ¶
type Launcher interface {
// Launch provisions a single instance from the given config and returns the
// initial result (instance id, IPs, AZ, state). It must not be called for
// dry-run requests — the caller short-circuits those before reaching here.
Launch(ctx context.Context, cfg spawn.LaunchConfig) (*spawn.LaunchResult, error)
// StopInstance stops a running instance. When hibernate is true the instance
// is hibernated (RAM state preserved) instead of a plain stop.
StopInstance(ctx context.Context, region, instanceID string, hibernate bool) error
// StartInstance starts a stopped instance. It also resumes a hibernated one.
StartInstance(ctx context.Context, region, instanceID string) error
// Terminate permanently deletes an instance.
Terminate(ctx context.Context, region, instanceID string) error
}
Launcher is the narrow port Prism drives for instance launch and lifecycle. It is expressed in spawn's own types so that swapping the default EC2-backed implementation for *spawn.Client is a one-line change with no signature churn.