Skip to content

refactor: create ephemeral FSx after RunInstances succeeds (#213) - #215

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/213-fsx-after-launch
Jun 17, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/213-fsx-after-launch

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Closes #213. The structural follow-up to #210 — removes the create/teardown churn rather than just making it safe.

Change

Reorders the ephemeral --fsx-create flow so the filesystem is created after RunInstances succeeds:

Before (#210 era): create FSx → RunInstances → on failure, delete FSx. Under lagotto's per-AZ/per-poll capacity-retry loop, that's a create→fail→delete cycle on every attempt.

After: RunInstances → on failure, return (nothing created) → on success, create FSx + tag instance spawn:fsx-pending. A capacity-failed launch issues zero CreateFileSystem calls by construction.

How it preserves every existing guarantee

Scope

Both the CLI single-instance path (cmd/launch.go) and the headless launcher (pkg/launcher/provision.go, the lagotto path).

Tests

TestValidateEphemeralFSx (fail-fast pre-launch validation, valid + 4 reject cases). Existing TestProvision_FSxLifecycleFailClosed and TestProvision_EndToEnd still pass. go vet ./..., cmd/launcher/aws suites green, gofmt clean.

Verifies

lagotto#45 (a multi-AZ capacity-fail poll now creates zero filesystems). Refs #210 (orphan fix this supersedes as the normal path), #208, #194.

Reorders launcher.Provision and the CLI single-instance path so the ephemeral
FSx is created AFTER the launch succeeds, not before. A capacity-failed launch
(InsufficientInstanceCapacity — the case lagotto retries on) now issues zero
CreateFileSystem calls: no orphan AND no create→fail→delete churn that the #210
teardown otherwise incurred on every per-AZ/per-poll retry.

- Pre-launch: validateEphemeralFSx enforces the fail-closed lifecycle contract
  (#193) so a bad config still fails fast without launching an instance.
- Post-launch success: createAndAttachEphemeralFSx creates the FSx (co-located
  with the instance AZ, #208) and tags the running instance spawn:fsx-pending
  via UpdateInstanceTags, so spored waits → DRA → mounts once AVAILABLE (#194,
  unchanged). RunInstances returns while the instance is still booting, so the
  tag lands well before spored reads it; the 5-min config refresh covers lag.
- Teardown kept ONLY as a backstop for the narrow create-ok-but-tag-failed
  window (delete rather than leak). Reaper ephemeral-orphan net (#210) is the
  outer backstop.
- Job arrays (count>1) keep creating the shared FSx up front (each instance is
  tagged from config at dispatch, so it must exist first).
- No user-visible latency change (spored mounts async).

Tests: TestValidateEphemeralFSx (fail-fast pre-launch validation); existing
fail-closed + end-to-end launcher tests still pass.

Closes #213
@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 2.80374% with 104 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/launch.go 0.00% 75 Missing ⚠️
pkg/launcher/provision.go 9.37% 28 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 48f6517 into main Jun 17, 2026
6 of 7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/213-fsx-after-launch branch June 17, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

launcher.Provision: create ephemeral FSx AFTER a successful RunInstances (eliminate create/teardown churn on capacity-failed launches)

1 participant