Skip to content

fix(image): warm seed needs SSM instance profile; distinguish dead from slow (#98) - #181

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/98-warm-seed-ssm-profile
Jun 15, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/98-warm-seed-ssm-profile

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Field report (Win11 25H2 spawn image import): warm-AMI build fails after a 30-min wait — "warm seed's SSM agent never came Online ... instance did not register with SSM (PingStatus=Online) within 30m0s."

Root cause

The warm seed was launched without an IAM instance profile (cmd/image.go omitted IamInstanceProfile, unlike the normal launch path). Without AmazonSSMManagedInstanceCore, the SSM agent boots and runs but has no credentials to call UpdateInstanceInformation — so it can never register. The warm stage then waited out the full timeout on a structurally impossible condition. This is "dead," not "slow."

Fix — two parts (matching the "tell slow from dead" ask)

  1. Make it alive: launch the warm seed with the spored instance profile via SetupSporedIAMRole() (which attaches AmazonSSMManagedInstanceCore) — exactly what cmd/launch.go does.
  2. Tell dead from slow: WaitForSSMOnline now, only while registration is still pending, checks whether an instance profile is attached. With none it returns a new ErrSSMUnreachable immediately (with elapsed context) instead of burning the timeout. The check is skipped once the instance is Online, so a transient DescribeInstances gap on a healthy instance can't produce a false "dead." Added WaitForSSMOnlineProgress with an elapsed callback; the warm build prints a heartbeat every ~2 min so a long-but-live wait doesn't look hung.

Tests

go test ./pkg/aws ./cmd green. New TestInstanceHasInstanceProfile_NoProfile validates the decisive "dead vs slow" probe.

Substrate limitation (gap filed): the emulator reports every running instance as SSM PingStatus=Online and doesn't echo IamInstanceProfile in DescribeInstances, so it has no running-but-unregistered state to model the full end-to-end dead path. I test the decision input (instanceHasInstanceProfile) directly instead, and documented this in the test.

Refs #98. Pairs with the earlier warm-AMI work and #153 (EC2Launch re-arm).

…#98)

The warm-AMI build's seed was launched without an IAM instance profile, so its
SSM agent had no credentials to register — PingStatus could never reach Online.
The warm stage then waited out the full 30-min timeout on a structurally
impossible condition and failed (field report from Win11 25H2 import).

- Launch the warm seed with the spored instance profile (SetupSporedIAMRole,
  which attaches AmazonSSMManagedInstanceCore) — same as the normal launch path.
- WaitForSSMOnline now distinguishes "dead" from "slow": when an instance is not
  yet Online it checks for an attached instance profile; with none it returns
  ErrSSMUnreachable immediately instead of waiting out the timeout. The profile
  check is consulted only while registration is pending, so a transient describe
  gap on a healthy (already-Online) instance can't yield a false "dead".
- Add WaitForSSMOnlineProgress with an elapsed callback; the warm build prints a
  periodic heartbeat so a long-but-live wait doesn't look hung.

Substrate can't model the dead path (it reports every running instance as SSM
Online and doesn't echo IamInstanceProfile), so the decision input
(instanceHasInstanceProfile) is unit-tested directly; substrate gap filed.

Refs #98
@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 36.45833% with 61 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/image.go 0.00% 38 Missing ⚠️
pkg/aws/ssm.go 60.34% 15 Missing and 8 partials ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 62d1032 into main Jun 15, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/98-warm-seed-ssm-profile branch June 15, 2026 23:11
scttfrdmn added a commit that referenced this pull request Jun 15, 2026
…est (#182)

substrate v0.71.0 models the SSM dead-state (substrate#331): a running instance
with no IAM instance profile is no longer listed by DescribeInstanceInformation,
and DescribeInstances now echoes the IamInstanceProfile set at launch.

This lets WaitForSSMOnline's "dead vs slow" distinction (#98 / #181) be tested
end-to-end again: restored TestWaitForSSMOnline_NoProfileIsDeadNotSlow, which
asserts ErrSSMUnreachable fires fast for a no-profile instance instead of
waiting out the timeout. It was unit-only while substrate reported every running
instance as Online.

The pkg/testutil import is already github.com/scttfrdmn/substrate/emulator (the
v0.69.0 reorg path), so no import change was needed.

go test ./pkg/aws ./cmd green; go vet clean.
scttfrdmn added a commit that referenced this pull request Jun 16, 2026
Promote CHANGELOG [Unreleased] → [0.53.0]. MINOR per SemVer (backward-compatible
fixes + dep bump).

Ships:
- image import warm-AMI: SSM dead-vs-slow fix — warm seed gets the spored
  instance profile so SSM can register; fail-fast on no-profile instead of a
  30-min timeout (#98 / #181). This is the Windows `spawn image import` SSM fix.
- extend: floor TTL deadline at now+duration, no premature reaping (#374)
- snapshot create: ext4 lost+found 0755, no spurious find Permission denied (#177)
- substrate test dep → v0.71.0; re-enabled SSM dead-path e2e (#182)
- Semgrep SAST enforcing in CI (#368)
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.

1 participant