Skip to content

fix(launch): wait for SSM agent before probing spored (#277 Symptom A) - #279

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/277a-ssm-readiness-gate
Jul 8, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/277a-ssm-readiness-gate

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Addresses #277 Symptom A: spawn launch --command on a fresh m8g.4xlarge / AL2023 (spot) consistently failed the spored-readiness gate with spored did not become ready within 3m0s: ssm send-command: ... context deadline exceeded — even though SSH was up within ~120s.

Root cause

verifySporedReady sent spored status over SSM SendCommand immediately, without first waiting for the SSM agent to register. On a just-booted AL2023/Graviton spot instance the agent lags, so every SendCommand fails until the whole 3m gate deadline elapses — surfacing as an opaque "context deadline exceeded".

Fix

verifySporedReady now:

  1. Waits for the SSM agent to be Online first, via the existing WaitForSSMOnline (polls DescribeInstanceInformation). Crucially, that helper fails fast with ErrSSMUnreachable if the instance has no IAM instance profile (the agent could then never register) — so a genuinely-doomed launch errors in seconds instead of waiting out the timeout.
  2. Then polls spored status as before (the agent is Online now, so SendCommand reaches it).

Gate budget raised 3m → 5m to accommodate Graviton agent-registration latency; the online-wait gets the bulk, with 30s reserved for the status poll.

Tests (substrate-backed)

  • TestVerifySporedReady_WaitsForSSMOnlineThenSucceeds — instance with a profile reaches Online, gate passes.
  • TestVerifySporedReady_NoProfileFailsFast — no-profile instance fails fast (ErrSSMUnreachable, <10s), not a full-timeout burn.
  • gofmt/vet/go test ./cmd/ green.

Scope: #277 Symptom A only. Symptom B (--require-spored=false box terminated ~100s with Client.UserInitiatedShutdown) is separate and needs a gated live repro to isolate — not addressed here.

The spored-readiness gate (verifySporedReady) sent 'spored status' over SSM
immediately after launch. On a fresh AL2023/Graviton spot instance the SSM agent
hasn't registered yet, so every SendCommand failed until the 3m gate timed out
('context deadline exceeded') — even though SSH was up in ~120s, making
'spawn launch --command' unusable on those instances.

Fix: verifySporedReady now first calls WaitForSSMOnline (polls
DescribeInstanceInformation for PingStatus=Online, and fails FAST with
ErrSSMUnreachable if the instance has no IAM instance profile — the agent could
then never register), and only then polls 'spored status'. The 30s SendCommand
timeouts no longer accumulate against a not-yet-registered agent. Gate budget
raised 3m -> 5m for Graviton registration latency.

Substrate-backed tests: an instance with a profile reaches Online and the gate
passes; a no-profile instance fails fast (ErrSSMUnreachable, <10s) instead of
burning the full timeout.

Addresses #277 (Symptom A). Symptom B (--require-spored=false early terminate)
is separate and needs a live repro.
@scttfrdmn
scttfrdmn merged commit 2382d02 into main Jul 8, 2026
6 checks passed
@scttfrdmn
scttfrdmn deleted the fix/277a-ssm-readiness-gate branch July 8, 2026 02:37
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.94737% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/launch.go 78.94% 3 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

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