Skip to content

fix(ami): resolve instance arch from EC2, not a Graviton allow-list (#410) - #411

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/410-arch-detect
Jul 19, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/410-arch-detect

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Summary

Fixes #410 — a plain spawn launch on m9g.24xlarge (Graviton5) picked an x86_64 AMI for an arm64 instance and failed immediately:

InvalidParameterValue: The architecture 'arm64' of the specified instance type
does not match the architecture 'x86_64' of the specified AMI.

Root cause

DetectArchitecture (pkg/aws/ami.go) recognized arm64 only from a hardcoded allow-list of Graviton family prefixes. m9g (a 2026 family) wasn't in it → fell through to the x86_64 default. Same class of bug as #384 (the GPU allow-list). Older families (c6g/c7g/c8g) launched fine because they were listed.

Fix

GetRecommendedAMI (the single-launch auto-AMI path, already has ctx+region+client) now resolves arch authoritatively from EC2: DescribeInstanceTypes → ProcessorInfo.SupportedArchitectures (new resolveArchitecture, mirroring the existing ValidateInstanceTypeForNestedVirtualization pattern). Any new arm64 family works with no code change.

  • Falls back to the static DetectArchitecture allow-list when the API is unavailable (offline/throttled/unknown type) — preserves today's behavior.
  • The allow-list also gained the current next-gen families (m9g/r9g/c9g/m8gd/c8gn/hpc7g/i8g/…) as a belt-and-suspenders default.
  • Extracted instanceFamily; pure DetectArchitecture stays for the no-client call sites (wizard, sweep grouping key, create-ami).

Testing

  • Unit: DetectArchitecture table extended with the Single-launch auto-AMI picks x86_64 for m9g (Graviton5) — unknown arm64 families not detected as arm64 #410 regression cases (m9g/r9g/c9g/hpc7g/i8g → arm64); new instanceFamily test. resolveArchitecture itself needs EC2, so it's covered by the gated smoke test below, not a unit test.
  • go test ./pkg/aws/, go vet, gofmt clean; no docs drift; Semgrep clean.
  • Real-AWS smoke (gated — TTL + approval before launch): launch a real arm64 type via auto-AMI (no --ami), confirm it resolves an arm64 AL2023 AMI and boots, then terminate + leak-check. I'll verify the exact arm64 family available and propose the spec for approval before any billable launch.

Closes #410

…410)

A plain 'spawn launch' on m9g.24xlarge (Graviton5) picked an x86_64 AMI and
failed with 'architecture arm64 does not match x86_64', because
DetectArchitecture recognized arm64 only from a hardcoded set of Graviton family
prefixes — and m9g (a 2026 family) wasn't in it, so it fell through to the
x86_64 default. Same class as the #384 GPU allow-list bug.

GetRecommendedAMI (the single-launch auto-AMI path) now resolves arch
authoritatively via DescribeInstanceTypes → ProcessorInfo.SupportedArchitectures
(new resolveArchitecture, mirroring ValidateInstanceTypeForNestedVirtualization),
so any new arm64 family works with no code change. Falls back to the static
allow-list when the API is unavailable; that list also gained the current
next-gen families (m9g/r9g/c9g/hpc7g/i8g/…) as a belt-and-suspenders default.
Extracted instanceFamily; the pure DetectArchitecture stays for the no-client
call sites (wizard, sweep grouping key).

Closes #410
@codecov

codecov Bot commented Jul 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 36.58537% with 26 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/aws/ami.go 36.58% 26 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit c44a705 into main Jul 19, 2026
7 checks passed
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.

Single-launch auto-AMI picks x86_64 for m9g (Graviton5) — unknown arm64 families not detected as arm64

1 participant