Repository navigation
fix(vm-recipes): stop dialing a sleeping workspace VM, and resume one whose host is gone - #40105
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes.
|
… whose host is gone A suspended recipe VM kept getting reconnect attempts: shared-control socket retries, health probes and SSH logins. Providers that resume a VM on a new SSH login or connection woke it again, so suspend saved nothing (#36363). While a VM's record is suspended (or its resume failed) and no wake is under way, Orca now makes no background dial to it: - SSH: connect and the reconnect ladder refuse that VM's own SSH host, which covers tunnels, managed-server checks, census and browser bridge. - Shared control: no retry after close, and no socket open, including a retry timer armed before the sleep. - Status probe: answers asleep without dialing. A wake (opening the workspace, Resume) is pending before it dials, so the wake's own connect passes. Afterwards the server's control socket and status are reopened. A VM recorded as up whose SSH host Orca gave up reaching (the reconnect ladder used every attempt) may have been stopped or reclaimed by its provider. Before, opening the workspace did nothing for it (#34089). Now it runs the recipe's resume and reconnects. If that fails, the record is left as it was, so normal reconnects go on. Fixes #36363 Refs #34089
7cc8b28 to
12d6b1b
Compare
ELI5
When you put a VM workspace to sleep, Orca kept knocking on its door. Some providers wake the VM whenever someone knocks, so it never actually slept. Orca now stays quiet until you open the workspace. Also, if the VM died on its own, opening the workspace now restarts it instead of doing nothing.
What Changed
Suspended VMs get no background dials (#36363). A VM is held while its record is
suspended(orresume_failed) and no wake is under way. The hold is applied at the lowest dial points, so every caller above them is covered:SshConnectionManager.connectand the SSH reconnect ladder refuse that VM's Orca-owned SSH host. This covers managed tunnels, managed-server checks, terminal census, the browser bridge and pairing repair. A user's connection test (probe) is still allowed, as with Disconnect.retryNow, and every wait for ready. Waiting requests are rejected with the existingruntime_environment_asleepcode.prepareRecipeVm.A wake (opening the workspace, Resume, a phone or CLI open) is marked pending before it dials, so its own connect passes. After the wake, Orca reopens the server's control socket and refreshes its status. A suspend that is still running does not hold anything, so a suspend that fails or is skipped never strands reconnects.
A VM whose host is gone can be resumed (#34089). Before, opening a workspace whose VM is recorded
running(orsuspend_failed) returned the record unchanged, even when the VM was gone. Now, if Orca's SSH reconnect ladder for that VM has used every attempt (reconnection-failed, minutes of failures), opening the workspace runs the recipe's resume and reconnects. If the resume or reconnect fails, the record is left as it was, so it never lands in an asleep state and normal reconnects go on. A blip, a reconnect still under way, a host the user disconnected, or one not dialed this session does not trigger it.Why
Issue #36363 shows a provider whose paused box resumed about 25 s after suspend, from Orca's own reconnects. Holding dials at the transport layer gives one predicate (
isRecipeVmEnvironmentAsleep/isRecipeVmSshTargetAsleepinsrc/main/ephemeral-vm/recipe-vm-asleep.ts) instead of patching each poller.For #34089, Orca only resumes on strong evidence (an exhausted reconnect ladder) and never on a single failed probe. The default of refusing to sleep a host whose terminals can't be confirmed stopped is unchanged. A "Sleep anyway" action or a recipe status hook would need UI or recipe-schema decisions and is left out.
Linked Issue
Fixes #36363
Refs #34089. This covers the SSH-mode recovery path. Paired-mode VMs have no equivalent reliable "gone" signal yet.
Visual Proof
N/A. No UI change; the behaviour is in main-process transports. Test evidence:
remote-runtime-shared-control-asleep.test.ts, real ws server)ssh_host_asleep, no session createdsendRemoteRuntimeRequestnot calledrunning, SSH ladder exhaustedTesting
New tests:
ssh-host-sleep-hold.test.ts,remote-runtime-shared-control-asleep.test.ts,runtime-environment-status-owner-asleep.test.ts,recipe-vm-asleep.test.ts,workspace-resume-lost-contact.test.ts. I confirmed that disabling the hold makes the shared-control and SSH tests fail.pnpm check:changedpasses. The only failures were load timeouts in existing SSH and shared-control suites, which pass 3/3 when run alone. I did not run this against a real VM provider (macOS only).Risk
Level: Low
runtime-ssh-target ids). The environment check is one cached store read per socket open or close. The predicates never throw; an unreadable record means "not asleep".ssh_host_asleepinstead of an SSH login that would wake the VM behind Orca's back. Requests to such a VM were already refused withruntime_environment_asleep.