Add installable toolchains with persisted state - #51
Conversation
Introduces deployment-wide persistence for UI-installed toolchain images via a new `installed_toolchain_images` table and DB module, then wires it into toolchains APIs with install/uninstall endpoints, audit logging, and install lifecycle states (`pending/installed/failed`). The runner provisioner now accepts a DB pool, unions installed toolchains with env prewarm images on reconnect, and adds on-demand pull/remove helpers used by the new handlers. Frontend updates add install/uninstall mutations, polling while installs are pending, richer error messaging, install-status-aware cards and summary metrics, and a new branded `ToolchainLogo` component. Toolchain response types were expanded to include `installStatus`, `installError`, and `installSupported`.
✅ Deploy Preview for overup-app ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (17)
📝 WalkthroughWalkthroughToolchain installation and uninstallation now persist image state, manage Docker images through runner provisioners, expose asynchronous API endpoints, and provide frontend controls with installation status, polling, failure messaging, and branded logos. ChangesToolchain installation lifecycle
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant ToolchainCard
participant ToolchainsAPI
participant ToolchainsHandler
participant RunnerProvisioner
participant Database
User->>ToolchainCard: Click Install
ToolchainCard->>ToolchainsAPI: POST installToolchain
ToolchainsAPI->>ToolchainsHandler: Install request
ToolchainsHandler->>Database: upsert_pending
ToolchainsHandler->>RunnerProvisioner: pull image
RunnerProvisioner-->>ToolchainsHandler: Pull result
ToolchainsHandler->>Database: mark_installed or mark_failed
ToolchainCard->>ToolchainsAPI: Poll toolchain status
ToolchainsAPI-->>ToolchainCard: Updated installation status
Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Summary
This PR adds installable toolchain management with persistent state tracking. The implementation correctly uses asynchronous operations, proper error handling, and audit logging.
Critical Issue Found
Performance Regression: The migration is missing an index on the status column. The list_active_images query filters by status on every Docker reconnect (30-60s intervals during outages), which will cause full table scans that could block critical system operations as the table grows.
Implementation Notes
The async architecture properly handles long-running Docker pulls off the request path, and the spawned tasks correctly capture required state. Rate limiting is appropriately configured for the expensive install operations. The code correctly prevents removal of the default job image and uses global deployment state as documented.
Please address the indexing issue before merging to production.
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
| CREATE TABLE installed_toolchain_images ( | ||
| toolchain_key TEXT PRIMARY KEY, | ||
| image TEXT NOT NULL, | ||
| status TEXT NOT NULL DEFAULT 'pending' | ||
| CHECK (status IN ('pending', 'installed', 'failed')), | ||
| error TEXT, | ||
| created_at TIMESTAMPTZ NOT NULL DEFAULT now(), | ||
| updated_at TIMESTAMPTZ NOT NULL DEFAULT now() | ||
| ); |
There was a problem hiding this comment.
🛑 Performance Regression: Missing index on status column causes N+1 query on every reconnect.
The list_active_images function in db/toolchain_images.rs filters by status IN ('installed', 'pending') without an index. This query executes on every Docker daemon reconnect (every 30-60s during outages) and could block the reconnect loop on large datasets. Add index before the table goes to production.
| CREATE TABLE installed_toolchain_images ( | |
| toolchain_key TEXT PRIMARY KEY, | |
| image TEXT NOT NULL, | |
| status TEXT NOT NULL DEFAULT 'pending' | |
| CHECK (status IN ('pending', 'installed', 'failed')), | |
| error TEXT, | |
| created_at TIMESTAMPTZ NOT NULL DEFAULT now(), | |
| updated_at TIMESTAMPTZ NOT NULL DEFAULT now() | |
| ); | |
| CREATE TABLE installed_toolchain_images ( | |
| toolchain_key TEXT PRIMARY KEY, | |
| image TEXT NOT NULL, | |
| status TEXT NOT NULL DEFAULT 'pending' | |
| CHECK (status IN ('pending', 'installed', 'failed')), | |
| error TEXT, | |
| created_at TIMESTAMPTZ NOT NULL DEFAULT now(), | |
| updated_at TIMESTAMPTZ NOT NULL DEFAULT now() | |
| ); | |
| CREATE INDEX idx_installed_toolchain_images_status ON installed_toolchain_images(status); |
Add a new immutable SQL migration creating a partial index on `installed_toolchain_images(status)` for `installed` and `pending` rows. This aligns with `list_active_images` lookups used during hosted-runner Docker reconnect/prewarm cycles and keeps the query scalable as table size grows, while remaining a defensive optimization at current low cardinality.
Introduces deployment-wide persistence for UI-installed toolchain images via a new
installed_toolchain_imagestable and DB module, then wires it into toolchains APIs with install/uninstall endpoints, audit logging, and install lifecycle states (pending/installed/failed).The runner provisioner now accepts a DB pool, unions installed toolchains with env prewarm images on reconnect, and adds on-demand pull/remove helpers used by the new handlers. Frontend updates add install/uninstall mutations, polling while installs are pending, richer error messaging, install-status-aware cards and summary metrics, and a new branded
ToolchainLogocomponent. Toolchain response types were expanded to includeinstallStatus,installError, andinstallSupported.Summary by CodeRabbit
New Features
Documentation