Skip to content

fix(connect,resume): one wake path for stopped/hibernated/stopping; resume never guesses a region (#57, #495) - #1234

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/connect-resume-57-495
Oct 20, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/connect-resume-57-495

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #57
Fixes #495

#57 — connect wakes stopped, hibernated and stopping instances on every path

cmd/connect.go had two auto-starts. The shell/one-shot path started stopped
and stopping (EC2 rejects StartInstances on a stopping instance, so that branch
could only fail). The DCV app path started only stopped, ignored --no-start,
and let a stopping instance fall through to a five-minute wait for a ready URL.

Both now call one helper, wakeForConnect (cmd/connect_wake.go):

  • stopped or hibernated: start (resume), wait for running, re-read for the new IP.
  • stopping (or hibernating): wait for stopped (new aws.Client.WaitForStopped), then start.
  • --no-start: refuse, with no EC2 calls.
  • Hibernation is detected from EC2's StateReason (Client.UserInitiatedHibernate),
    falling back to spawn's spawn:last-stop-reason=user-hibernated tag. The message
    then reads "Instance is hibernated — resuming it...".
  • The running wait is now 5 min, up from 2, because a resume restores RAM from disk.

#495 — resume: no panic, no us-east-1 guess

  • Sweep state records each launched instance's region, taken from LaunchResult at all
    three record sites.
  • resolveResumeRegions picks each instance's region in this order: recorded, then
    the param set's own region, then the file default (checked assertion), then the
    shared config region (flag > SPORE_REGION/AWS_REGION > spore config, the same
    source launch reads). If none of those is set, resume returns an error that names
    the instance and --region. This runs before any AWS client is built.
  • Pending sets fall back to: --region, then the sweep's single recorded region,
    then the shared config. If none is set, resume refuses. The hard-coded us-east-1
    is gone.
  • An instance is reconciled in the region it was launched in, so a sweep that spans
    regions is reconciled in each region.

Gates, each watched failing against a revert that compiles

  • TestEveryConnectPathWakesThroughTheSharedHelper is an AST check over the
    discovered connect*.go files: StartInstance may only be called from
    wakeForConnect, and runConnect and connectDCV must both call it. I reverted
    connectDCV to the old stopped-only StartInstance block and the test failed on
    both counts.
  • TestWakeForConnect_StoppingIsWaitedOutThenStarted: dropping the stopping wait
    (if false) makes it fail with the observed call order.
  • TestWakeForConnect_StartsStoppedAndHibernated: disabling hibernation detection
    makes it fail on the message.
  • TestRunResume_ParamFileWithoutRegionDefaultDoesNotPanic drives runResume with
    the issue's input. With the original unchecked assertion restored, it panicked
    with interface {} is nil, not string.
  • TestResolveResumeRegions_PendingFallbackNeverDefaultsToUSEast1: restoring the
    us-east-1 fallback makes it fail.
  • TestEverySweepInstanceRecordSetsItsRegion is an AST check over every
    InstanceState literal in non-test cmd files, and fails if it finds none. Dropping
    Region: from one literal makes it fail at launch_sweep.go:541.

Checks

make check passes every step except check-build-tags, which fails identically on
unmodified main on this machine (the /private/tmp path issue). make lint: 0 issues.
semgrep: clean. api-snapshot regenerated (one addition, WaitForStopped). gen-docs /
check-docs: no drift.

@scttfrdmn scttfrdmn added this to the v0.138.0 milestone Oct 20, 2026
@codecov

codecov Bot commented Oct 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 62.83186% with 42 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/resume.go 78.94% 12 Missing ⚠️
cmd/connect.go 0.00% 10 Missing ⚠️
cmd/connect_wake.go 72.22% 6 Missing and 4 partials ⚠️
pkg/aws/client.go 0.00% 7 Missing ⚠️
cmd/launch_sweep.go 0.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

…esume never guesses a region (#57, #495)

connect: the shell/one-shot and DCV app paths share wakeForConnect; a stopping
instance is waited out then started; hibernated is reported as resuming; the
app path now honours --no-start.

resume: per-instance region recorded in sweep state at launch; resume
reconciles each instance in its recorded/param/configured region and errors
asking for --region instead of panicking on a param file with no region
default or falling back to us-east-1.
@scttfrdmn
scttfrdmn force-pushed the fix/connect-resume-57-495 branch from 011fe41 to b25d996 Compare October 20, 2026 17:19
@scttfrdmn
scttfrdmn merged commit 104ffa2 into main Oct 20, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the fix/connect-resume-57-495 branch October 20, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant