Skip to content

fix(launch): retry DescribeInstances on post-RunInstances NotFound (#78) - #81

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/78-describe-eventual-consistency
Jun 8, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/78-describe-eventual-consistency

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Summary

Fixes #78 (blocking nf-spawn): EC2 RunInstances and DescribeInstances are eventually consistent. A successful RunInstances followed by an immediate DescribeInstances on the new ID can return InvalidInstanceID.NotFound (HTTP 400) for a few seconds while EC2 propagates the instance. spawn treated that as fatal → exited 1 even though the instance launched and ran, leaking it and failing the caller (nf-spawn aborts the Nextflow run). Reproduces reliably on the nested-launch path (instance → spawn launch) where there's no TUI delay to mask it.

Fix

  • DescribeInstanceWithRetry retries InvalidInstanceID.NotFound (and the equivalent empty-result race) with capped backoff (1s, 2s, 4s, 8s… ~30s); a genuinely missing instance still errors, and any other error returns immediately.
  • isInstanceNotFound classifies via smithy.APIError with a message fallback.
  • Applied to GetInstancePublicIP / GetInstanceState (the --wait-for-running=false nested/nf-spawn path goes straight to GetInstancePublicIP), WaitForRunning (absorbs the window before the SDK running-waiter, which does not retry a NotFound 400 itself), and the queue connect-details path (reuses the exported helper).

Tests

  • isInstanceNotFound classifier — smithy APIError, string fallback, negatives.
  • DescribeInstanceWithRetry — happy path + bounded-context exhaustion against the substrate emulator.
  • make check green.

Release

CLI-only fix; bumps version 0.37.1 → 0.37.2. Will tag after merge so nf-spawn can pick it up.

Fixes #78. Refs spore-host/nf-spawn#34.

EC2 RunInstances and DescribeInstances are eventually consistent: a successful
RunInstances followed by an immediate DescribeInstances on the new ID can return
InvalidInstanceID.NotFound (HTTP 400) for a few seconds while EC2 propagates the
instance. spawn treated that as fatal and exited 1 — even though the instance
launched and ran — leaking it and failing the caller (nf-spawn aborts the
Nextflow run). Reproduces reliably on the nested-launch path (instance → spawn
launch) where there's no TUI delay to mask it.

Fix: DescribeInstanceWithRetry retries InvalidInstanceID.NotFound (and the
equivalent empty-result race) with capped backoff (1s,2s,4s,8s… ~30s) before
giving up; a genuinely missing instance still surfaces an error, and any other
error returns immediately. isInstanceNotFound classifies via smithy.APIError
with a message fallback.

Applied to:
- GetInstancePublicIP / GetInstanceState (the --wait-for-running=false path used
  by nested/nf-spawn launches goes straight to GetInstancePublicIP).
- WaitForRunning now absorbs the propagation window before the SDK
  running-waiter, which does NOT retry a NotFound 400 on its own.
- The queue connect-details path (separate *ec2.Client) reuses the exported
  helper.

Tests: isInstanceNotFound classifier (smithy + string fallback + negatives);
DescribeInstanceWithRetry happy path + bounded-context exhaustion against the
substrate emulator. Bump CLI version 0.37.1 → 0.37.2.

Fixes #78. Refs nf-spawn#34.
@codecov

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.90909% with 16 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/aws/client.go 78.00% 9 Missing and 2 partials ⚠️
cmd/queue.go 0.00% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 6e807e3 into main Jun 8, 2026
3 checks passed
@scttfrdmn
scttfrdmn deleted the fix/78-describe-eventual-consistency branch June 8, 2026 19:52
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.

spawn launch: InvalidInstanceID.NotFound immediately after RunInstances succeeds (EC2 eventual consistency)

1 participant