Files
orca/cloud/apps/sandbox-control/migrations/0007_sandbox_pool.sql
T
Neil 178eaf4ec8 feat(sandbox-control): warm VM pool (SANDBOX_POOL_SIZE); idempotent resume of a running sandbox; github_not_connected before provisioning (#36)
- pool.ts: N standard VMs booted from the current golden with egress denied; create claims one atomically
  (DELETE..RETURNING), applies the caller policy + full lease in parallel, bills from the claim; cron and
  each claim refill; recycled at 20 min, on golden change, pool off or kill switch; fallback to a fresh VM.
- F1: orca-sandbox-start leaked the start-lock fd into orcad, so a second start (resume of a running
  sandbox, retried create) waited 60 s and 502'd. Children now close fd 9; the Worker also reads the
  serving orcad's ready line without the lock (fixes VMs on older images).
- F2: a github.com repo with no App token and no anonymous access fails 409 github_not_connected before
  any VM work.
2026-11-09 04:45:39 -08:00

19 lines
800 B
SQL

-- Warm pool: VMs booted from the current golden image with egress denied, waiting to be claimed by a
-- create. The id is the sandbox id the claiming row will take, so the provider name and the ownership tag
-- already match. Rows leave by claim (DELETE ... RETURNING) or recycle; nothing here is billed to anyone.
CREATE TABLE sandbox_pool (
id TEXT PRIMARY KEY,
provider_name TEXT NOT NULL UNIQUE,
machine_size TEXT NOT NULL,
region TEXT NOT NULL,
snapshot_id TEXT NOT NULL,
-- warming (create in flight) | ready
status TEXT NOT NULL,
session_id TEXT,
session_started_at INTEGER,
session_timeout_ms INTEGER,
created_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL
);
CREATE INDEX sandbox_pool_claim ON sandbox_pool (status, machine_size, region, snapshot_id, created_at);