Skip to content

refactor(cmd): extract step helpers from launchWithProgress (#319) - #340

Merged
scttfrdmn merged 1 commit into
mainfrom
audit/phase3-launchprogress-helpers
Jul 11, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
audit/phase3-launchprogress-helpers

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Closes #319. Part of the audit tracker #328 (Phase 3). No behavior change — command/flag tree byte-identical to main.

What changed

launchWithProgress (the single-instance launch orchestrator) was 743 lines. Extracted its cleanly-bounded early setup phases into named helpers so the function reads as a step sequence and drops to ~625 lines:

  • ensureAMIAndPreflight — AMI detect (Step 1) + OS resolve (1b) + instance-type guards (Windows lifecycle/burstable, nested-virt, MPI/EFA/hibernation preflight)
  • ensureIAMProfile — user-specified or default spored IAM instance profile (Step 3)
  • ensureSecurityGroup — MPI / Windows managed security group, else no-op (Step 4)

Each helper takes (ctx, awsClient, config, prog[, auditLog]), mutates config, and returns error — a mechanical lift of contiguous blocks.

Left inline (deliberately — the plan called this out)

  • FSx provisioning block (Step 4.5): its pendingFSxConfig/pendingFSx* locals thread through to the post-launch create step (6.5), so extracting would require a struct return and add risk for little readability gain.
  • Launch / wait / public-IP / SSH / spored-verify / DNS tail: interwoven with the result value.
  • The count > 1 job-array early-return stays in the parent (verified: launchWithProgress still contains the count > 1 → launchJobArray/launchJobArrayCohort dispatch), not buried in a helper.

Verification

  • go build ./..., go vet ./cmd, gofmt -l clean.
  • Full go test ./cmd green (excl. pre-existing TestCatalogValid / feat(plugin): permissions declaration block (#388) #392).
  • Confirmed the job-array early-return + step ordering unchanged.
  • Rebuilt bin/spawn, command+flag tree byte-identical vs main.

This is the highest-risk Phase 3 item (large, branchy, no direct unit test — needs AWS), so I kept extractions minimal and mechanical; anything that resisted a clean lift was left inline per the plan. Final Phase 3 PR (after #336/#337/#338 splits + #339 dedup).

The 743-line single-instance orchestrator now delegates its cleanly-
bounded early setup phases to named helpers, dropping to ~625 lines and
reading as a step sequence. No behavior change.

- ensureAMIAndPreflight — AMI detect + OS resolve + instance-type guards
  (Windows lifecycle/burstable, nested-virt, MPI/EFA/hibernation preflight)
- ensureIAMProfile      — user-specified or default spored IAM profile
- ensureSecurityGroup   — MPI / Windows managed SG (else no-op)

Left inline by design: the FSx-provisioning block (its pendingFSx* locals
thread into the post-launch create step) and the launch/wait/DNS tail
(interwoven with the launch result). The count>1 job-array early-return
stays in the parent, not buried in a helper.

Verified: go build ./..., go vet ./cmd, gofmt clean; full cmd test suite
green; job-array early-return confirmed still in launchWithProgress;
command+flag tree byte-identical vs main.
Part of the 2026-07-11 audit (#328, Phase 3).
@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 123 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/launch_single.go 0.00% 123 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit b35f34b into main Jul 11, 2026
6 of 7 checks passed
@scttfrdmn
scttfrdmn deleted the audit/phase3-launchprogress-helpers branch July 11, 2026 20:42
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.

[audit] Refactor: launchWithProgress is a 749-line function (longest in the repo) — extract per-step helpers

1 participant