Repository navigation
feat: run sessions in AWS Lambda microVMs - #665
Merged
Merged
Conversation
A new lambda driver runs each session in an AWS Lambda microVM: the host resumes the one a session has, takes a warm one or runs a new one, and reaches fctl-agent microvm-serve in it over WebSockets through the microVM's endpoint. Sessions stay idle while their microVM is suspended: after the settings' while with nothing running, the agent saves the session's snapshot and the host suspends the microVM, resumes it for whatever comes for the agent, and lets it go once suspended for the settings' while. The runner's settings come from the control plane.
PUT and GET /api/v1/runners/{id}/microvms keep a runner's microVM
settings in D1 and send them to its host; FleetDO keeps what the host
says of its microVMs, counts suspended sessions as room, and places
sessions on runners whose settings say first before others. SessionDO
tells viewers when a session's sandbox is suspended.
…o xtask dev fctl runners microvms show and set read and change a runner's microVM settings; fctl host microvm-image writes what Lambda builds an image of your own from; fctl host install --driver lambda checks that the machine may manage microVMs. cargo xtask dev --microvms runs a host of the lambda driver against a stand-in for Lambda MicroVMs, whose microVMs are fctl-agent microvm-serve on this machine.
…ll of a microVM A host of microVMs probes its driver every 2 seconds, in memory, and sends a heartbeat when its microVMs or whether its driver is ready changed, so that a runner whose settings or image just came takes sessions at once. The stand-in's microVMs keep their homes under the temporary directory, whose short paths leave room for the session socket, and suspending one stops every process in it, as a real suspend does.
…ose microVM is suspended The Runners tab has a section on AWS Lambda microVMs: what they do for sessions, a drawing of a session's microVM over its life, each runner of them as a card with a pip for each microVM it may have, and how to set one up while there is none. A card opens a sheet with every microVM, its image and, for those who manage the runner, its settings, checked as the server checks them. A session whose microVM is suspended says so beside its status, with a moon and what a message does when hovered, in its details, and in its message box.
Its conversation and the work it hadn't pushed only where its snapshot was kept; where the workspace keeps none, a message starts it again from its task and branch, as the Runners tab now says too.
…whole The sheet is 520 px wide from 768 px, where its settings take two columns; its contents are padded as wide as its header. A runner's card wraps between its facts on a phone, and each microVM says what it does as a phrase (Running for 5m, Warm, just started).
The architecture's AWS Lambda microVMs section and ADR 0106; setting up a runner of them in Runners in your cloud, with the host's policy and the build role; fctl runners microvms, fctl host microvm-image and the [lambda] table in the CLI reference; cargo xtask dev --microvms in Development; a recipe in llms.txt. A runner's sheet shows the policy its host needs for its settings, open by itself while AWS refuses the host something, which the host's error now points to.
Native Clippy builds the control plane's tests too, without crate::testing, and Clippy denies indexing there.
This comment has been minimized.
This comment has been minimized.
Making the vm server serve Lambda microVMs too turned Firecracker's off by default: a VM stopped without its memory saved lost what its disk hadn't written, which the Firecracker sandboxes job caught.
…they're gone The upkeep lets go only of microVMs whose session's run ended: a session that runs lets its own go, saving its snapshot first. A microVM AWS hasn't let go of (a terminate that failed, a run whose answer never came) is kept as going-… and terminated again every 30 seconds, finding an unanswered run's id by asking again with its client token. Saves write one at a time, the newest last. The image's archive goes to S3 with the keys the host calls Lambda with, a role it assumes included.
…n't answer FleetDO sent no settings at all, which clear the host's, when reading them failed; it now sends none only where the runner has none.
The field kept only the parsed list, so the line break or space after an ARN vanished as it was typed.
This comment has been minimized.
This comment has been minimized.
A run that failed is kept to let go of only where Lambda may have run it: a timeout, a connection that broke once made, or a 5xx other than a throttle or no capacity. A throttled or refused run, or one that never left, is forgotten, and the warm pool waits while Lambda throttles or can't be reached. Every microVM the host keeps counts against the most it may have, those it lets go of too. A run a restart cut short, warm ones included, is let go of once unanswered for 10 minutes, and a session finds another rather than replaying a request that may have changed.
This comment has been minimized.
This comment has been minimized.
A later try's throttle no longer hides a timeout before it, and an answer that doesn't read means Lambda carried the request out, so neither forgets a microVM Lambda may run. A new session lets a suspended session's microVM go only where sessions and warm microVMs fill the limit: those the host lets go of free their room by themselves.
This comment has been minimized.
This comment has been minimized.
A replay's throttle or lack of capacity says nothing of the first try, which may have run the microVM: only a request Lambda refuses as invalid, which it would never have carried out, is forgotten.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…ch once A new session on a full runner asks the longest-suspended session whose snapshot was saved to let its microVM go, and never the same one twice: one without a saved snapshot would keep its microVM, and the new session would wait for room in vain.
The form compared its draft and the saved settings as JSON strings, so an emptied list (which the server leaves out) or keys in another order kept it changed after a save. Cleared connectors are unset, as the server keeps them.
This comment has been minimized.
This comment has been minimized.
…session The host remembered the sessions it asked to let their microVM go for good once nothing was full, and also one that declined as it resumed: it now keeps each ask with the suspension it was made in, dropping it once the session's run ends or it resumes, on every start.
kalaspuff
approved these changes
Dec 1, 2026
This was referenced Dec 1, 2026
kalaspuff
pushed a commit
that referenced
this pull request
Dec 2, 2026
## Summary Fixes nine bugs that came in with #665's AWS Lambda microVM support. Some left microVMs running, and billing, for hours, some made the host retry at once without end, and some hid errors from people: - **MicroVMs left running.** A microVM that was starting or resuming as its session's run ended, or whose suspend failed, ran until Lambda's 8-hour end. The upkeep now suspends one that has gone a minute like that, or lets it go if it can't. Before it lets one go, it checks again that the session's next run hasn't taken it back, or run a new one by its name, while it waited. - **Warm pool loop.** A warm microVM that failed to start for a reason the pool doesn't pause for, such as a request Lambda found wrong, was replaced at once, over and over. The pool now waits a minute after a failed start, or less if the settings change. - **Image archive upload.** A failed upload of the archive Lambda builds the image from was retried every 5 seconds and shown nowhere. It now shows as the runner's problem and on its image, and is tried again after 30 minutes, as a failed build is. The wait keeps saying why. - **Forgotten microVMs.** After a runner's image changed, the host forgot every microVM a list of the new image lacked, sessions' included, without terminating them. It now asks Lambda about each one the list lacks and forgets it only once Lambda says it is gone. It also forgets one only if a session's next run hasn't replaced it meanwhile. - **Take out and Remove.** Workspace admins couldn't take a microVM runner out of the workspace, or remove a member's that enrolled there. The microVM cards now offer Take out and Remove as runner rows do, with the same confirmation. - **Image version errors.** An image version the server refused showed no error. The error now shows under Version, and the web app also checks the version before saving, as it checks the other fields. - **Checkpoints.** A checkpoint that timed out stopped a session from ever suspending again. A finished upload no longer holds the next checkpoint off. - **Agent downloads.** fctl-agent downloads for two architectures shared one temp file, since `with_extension` cut the name at the version's last dot. Each download now has a temp file of its own, which it removes if it fails. - **Chunk size.** In `microvm-serve`, a chunk size near `usize::MAX` overflowed the body-length check and panicked the connection's task. It is now refused. New tests cover the first four bugs, Take out and Remove, the version error and the chunk size. I checked that the tests for the first two, the forgotten microVMs, the cards and the version error fail without their fixes, as does the test where a session takes its microVM back while the upkeep suspends it. fctl-host's 334 tests, fctl-agent's microVM tests, the web app's tests, `npm run check` and `cargo xtask check lint` pass. docs/architecture.md describes the new behavior. ## Screenshots Before: a microVM runner added from elsewhere, and a member's that enrolled here, offered admins only Open (dark theme).  After: Take out and Remove, as runner rows offer them, in the dark and light themes and at phone width.    An image version with a space in it, after Save: before, nothing said what was wrong; after, the error shows under Version.   ## Worth confirming - **Decision:** a microVM that ended unsuspended and then fails to suspend is let go of at once rather than retried. Its session's agent saved its snapshot as it stopped, so the session's next run carries on in a new microVM, but it loses the suspended microVM's disk. - **Decision:** on the microVM cards, a runner's owner now gets Take out instead of its menu, as on runner rows, where the runner was added from another workspace. Before, the menu's Remove deleted the runner from every workspace. - **Decision:** when the image's archive fails to upload, or Lambda refuses to build the image, the 30-minute wait after now shows that failure's reason rather than "Lambda couldn't build the image". - **Assumption:** after a change of region, the new region's API answers 404 for the old region's microVMs, so the host still forgets them without terminating them, and Lambda ends them within 8 hours. Fixing that would need each microVM's region saved with it, and is left for later. [fctl session](https://app.fctl.sh/s/ses_01M8VDPX5PJ1316JEN10GTNFRK) <!-- FCTL_REVIEW_SUMMARY --> --- > [!NOTE] > **Medium risk.** It changes how the host upkeep suspends, terminates and forgets AWS Lambda microVMs, which can destroy a session's suspended disk if a case is wrong, and it changes the checkpoint loop every session runs. > > **What it does.** Fixes nine bugs in the AWS Lambda microVM support: the upkeep now suspends or lets go of microVMs whose run ended unsuspended, the warm pool waits a minute after a failed start, and a failed image archive upload is shown and retried after 30 minutes. It also asks Lambda before forgetting a microVM missing from a list, adds Take out and Remove to the microVM cards, shows image version errors, lets a finished upload stop holding off the next checkpoint, gives each agent download its own temp file, and refuses an oversized chunk in `microvm-serve`. Before the upkeep lets a microVM go, it now checks again that a session hasn't taken it back meanwhile. > > **Lost disk on failed suspend.** A microVM that ended unsuspended and then fails to suspend is let go of at once instead of retried, so the session's next run starts in a new microVM without the suspended one's disk. > > <sub>[fctl review](https://app.fctl.sh/s/ses_01M8VGQ0MC1M4B7MQCQ6Z8C6CC)'s first look at [`cc1156a`](cc1156a) · 10 files, +531 −55 · [Review agent settings](https://app.fctl.sh/p/fctl?tab=reviews)</sub> <!-- /FCTL_REVIEW_SUMMARY --> --------- Co-authored-by: fctl-sh[bot] <fctl-sh[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A workspace can now run each of its sessions in an AWS Lambda microVM in its own AWS account. A new
lambdadriver forfctl hostruns on any machine that may manage the account's microVMs (an instance's or task's role, keys, or a role it assumes) and drives them through Lambda's API and each microVM's endpoint, wherefctl-agent microvm-serve, the image's program, answers Lambda's lifecycle hooks and serves the host the same exec protocol as the Firecracker driver, over a WebSocket only the host's key opens. The runner's owner or its workspace's admins choose its microVMs' settings on the Runners tab or withfctl runners microvms set: an image fctl builds from the sandbox image in their bucket and rebuilds as fctl updates, or one of their own; the size (512 MiB to 8 GiB, bursting to four times), architecture, execution role, egress connectors, KMS key and log group; when microVMs suspend and go; the warm pool; and whether sessions start there first. FleetDO hands them to the host, and the host reports its microVMs back.A session's microVM suspends once the session has waited 90 seconds (by default) with nothing running, no turn and no background task, after its agent saved the session's snapshot. The session stays idle, its page says "microVM suspended", and anything for the agent (a message, a follow-up, a GitHub event) resumes it as it was. After 60 minutes suspended (by default), or as Lambda's 8 hours near, the host lets it go and the session stops; the next message carries it on in a new microVM from its snapshot. Warm microVMs, started then suspended, are taken by sessions of every kind as they start. Suspended sessions don't count against the runner's capacity, a full runner lets the longest-suspended one go for a new session, and a runner set to go first takes the workspace's sessions before its other runners.
HostToAgent::Checkpoint) and quiet state. A microVM AWS hasn't let go of (a terminate that failed, a run whose answer never came) stays on the host's books and is terminated again until AWS says it's gone.runners),GETandPUT /api/v1/runners/{id}/microvms, and scheduling that skips suspended sessions and putsfirstrunners first.fctl runners microvms show|set,fctl host install --driver lambda,fctl host microvm-image, and[lambda]inhost.toml.fctl attachsays when a microVM suspends and resumes.cargo xtask dev --microvmsruns a stand-in for Lambda (xtask/lambda) and a runner of its microVMs.llms.txt.Unit tests cover the domain's rules, the agent's checkpoint, the microVM server's HTTP and WebSocket handling, the protocol's compatibility with older peers, the control plane's API (in Node), the CLI and the web components;
cargo xtask checkpasses. End to end,cargo xtask dev --microvmsran the whole path against the stand-in: a session took a warm microVM (its agent attached in about 40 ms) and the pool refilled; a minute after its turn its snapshot was saved and its microVM suspended; a message resumed it as it was; after 5 minutes suspended the host let it go and the session stopped; and a message then carried it on in a new microVM with its conversation restored. None of this has run against real AWS Lambda, since this sandbox has no AWS account: #664 tracks that.Deploying needs migration 0079, which only adds nullable columns. MicroVMs need hosts and agents of this release; FleetDO sends the settings only to hosts that announce the
microvmsfeature, and every new protocol field is optional.Screenshots
At f723c9b, in
cargo xtask dev --microvmsagainst the stand-in for Lambda.The Runners tab's microVMs section (light, 1440 px): the life of a session's microVM, drawn, and the dev runner's card with a pip for each of its 10 microVMs, one suspended with its session and one warm.
The same on a phone (dark, 390 px): the card's facts wrap between them, and the drawing goes under the text.
A runner's microVMs in the wide sheet (dark): the counts, the image, each microVM with its session, the host's AWS policy behind Show it, and the start of the settings.
Its settings further down (light): the image, size, whiles, warm pool and going first.
A session whose microVM is suspended (light, 1440 px): "microVM suspended" with a moon beside Waiting, the transcript's line, the message box, and the details' runner row.
The same on a phone (dark, 390 px).
Worth confirming
idlestatus rather than getting a new one: its page, its details, its message box andfctl attachsay the microVM is suspended, and lists show it as waiting.stopped, with a reason that says a message carries it on, as any idle session that stopped would be. Where the workspace keeps no snapshots, the reason says the session starts again from its task and branch.host.toml. Members see the runner's microVMs, and its settings in a sentence.ghcr.io/hyperstructure/sandboximage the Dockerfile starts from.nohupserver, say) may freeze while the microVM is suspended and go with it. Background tasks keep a session from suspending.Related pull requests
fctl session
Warning
High risk. It adds a new AWS Lambda microVM driver that starts, suspends, resumes and terminates billed cloud resources with assumed-role credentials, stores their state on the host, and touches the control plane, the database and the web app.
What it does. Lets a runner run agent sessions in AWS Lambda microVMs. The host starts, suspends, resumes and terminates microVMs, and keeps a warm pool. A session's snapshot is saved to S3 so a microVM can be let go and the session resumed later. Runners get microVM settings in the control plane and the web app, and docs explain how to set it up in your own cloud. Since the last review, the host remembers which suspended sessions it asked to give up their microVM, per suspension, so an ask no longer outlives the session's run or a resume.
Cloud resources and IAM. Whoever deploys it must give the host's AWS role the Lambda and S3 permissions in
docs/runners-in-your-cloud.md. A microVM the host fails to terminate keeps billing until Lambda's 8-hour limit.fctl review's first look at
f74068c· 103 files, +12732 −158 · Review agent settings