Repository navigation
feat(scaling): AWS EC2 units, as spot instances or on demand - #559
Conversation
Lens can grow from one machine onto AWS when work waits: a scaling group on an AWS provider launches EC2 instances that join over the mesh and run its worker. Spot units fall back to on demand when AWS has no spot capacity; when AWS takes one back the scaler says why and launches another. Prices are estimates (zone spot price or the Price List API); with no price nothing launches. Instances require IMDSv2, encrypt their disk and terminate on shutdown. botocore is the new `aws` extra, fetched when the first AWS provider is saved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SETHpH6NUGKT1Bwd6xyPCA
2d618ff to
928e0bc
Compare
|
Clicks and keystrokes per feature failed on 928e0bc: the computer survey's I don't think this is this PR's failure. The diff only adds the AWS driver ( No fix exists for it yet. I'm re-running the failed job once. Generated by Claude Code |
…rt of #578) The requirements check fails on main since #400 was released; the same change as #578, a no-op once that merges. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SETHpH6NUGKT1Bwd6xyPCA
…-dtagi8 # Conflicts: # README.md
…-dtagi8 # Conflicts: # README.md # docs/requirements.md # docs/scaling.md
Requested by Adeel · project thread
Builds on #556 (the auto scaling core, merged).
Description
Before: auto scaling could only run more workers on the machine Lens runs on.
After: a scaling group can use an AWS EC2 provider. Lens launches EC2 instances that join it over the Nebula mesh and run
lens worker, as spot instances (the default, falling back to on demand when AWS has no spot capacity or none under the max price) or on demand. When AWS takes a spot instance back, the scaler records "AWS took the spot instance back" and launches another; the job goes back in the queue through the existing heartbeat reaper.How:
app/domain/scaling_aws.pyimplements the core'sDriverinterface on botocore (Apache-2.0), the newawsextra fetched when the first AWS provider is saved. Prices are labelled estimates: the spot price in the zone the instance landed in, or the on-demand price from the AWS Price List API; a price set on the provider wins, and with no price nothing launches (an unpriced unit would never count against the budget). Instances require IMDSv2, encrypt their disk, terminate on shutdown (a stopped one is terminated too), are taggedlens-unit, and default to the newest Canonical Ubuntu 24.04 AMI for the type's architecture. User-data is only the mesh's one-time join line. The core's reconcile step now keeps the reason a driver gives when a unit is gone.Units launch only once the mesh can join machines (the Nebula thread's install line). Until then a launch fails before any AWS call, saying to turn the mesh on.
Motivation and Context
Adeel asked for Lens to start on a laptop or a Raspberry Pi and expand onto AWS and other clouds automatically when needed, including spot instances. The Auto scaling thread owns the core and the other providers; this PR is the AWS and spot part, as agreed between the two threads.
Types of changes
!in the title)Checklist:
tests/domain/test_scaling_aws.py, 7 tests on botocore's Stubber, so every call is checked against EC2's own API model, including one through the scaler.docs/accordingly (docs/scaling.md"AWS EC2", with the IAM policy).Done questions (AGENTS.md)
/api/v1/scaling, MCP and the assistant's scaling tools (the core's).uv lockfor the extra; no API shape change, so no OpenAPI change).docs/scaling.md: drain on the two-minute spot notice, following the spot price, instance roles and Identity Center, mixed instance types, spot at other clouds.🤖 Generated with Claude Code
https://claude.ai/code/session_01SETHpH6NUGKT1Bwd6xyPCA