-
Notifications
You must be signed in to change notification settings - Fork 200
Add Northflank sandbox client #20660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
fontanierh
wants to merge
15
commits into
main
Choose a base branch
from
northflank-client
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+782
−3
Conversation
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
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
77f3253 to
a688ab7
Compare
3daa9bb to
f9eba88
Compare
64f26b9 to
b0b4d69
Compare
e1670e2 to
5c4eb8a
Compare
Adds a client for managing sandboxes via the Northflank API: - NorthflankSandboxClient with async factory pattern - Methods: createSandbox, attach, exec, writeFile, readFile, destroy - Config getters for API token and project ID - Helper functions to check sandbox availability
5c4eb8a to
7cb10ba
Compare
- Clean up service/volume when sandbox readiness times out - Check response.error in waitForReady() before accessing data - Check errors in pause/resume/destroy and don't clear state on failure
- Rename sandboxConfig to config - Extract resetState() and buildTags() helpers - Remove redundant comments - Condense object literals
METADATA_TAG_PREFIXES ensures adding a field to SandboxMetadata forces updating the tag prefix mapping (TypeScript error otherwise).
- Wrap waitForReady() in try/catch to cleanup on throws, not just Err - Check response.error in cleanupResources() (SDK doesn't throw on HTTP errors) - Document error handling pattern: Err for recoverable, throw for infra failures
- NorthflankSandboxClient is now a factory with createSandbox() and attach() - Sandbox class has all operations (exec, pause, resume, destroy, etc.) - No more runtime requireServiceId() checks - type system enforces attachment - createSandbox() returns Result<Sandbox, SandboxError> - attach() returns Sandbox
- pause(): Check if already paused, return early if so - resume(): Check if already running, return early if so - destroy(): Treat 404 as success (already deleted)
- Replace getServiceStatus() -> isServicePaused() returning boolean - Use response.data.servicePaused from Northflank SDK - Simplify pause/resume idempotency checks - Use normalizeError for consistent error handling (via code-simplifier) - Use serviceParams getter to reduce duplication (via code-simplifier)
- Sandbox now uses this.info.projectId instead of config.projectId so attach() works correctly with persisted SandboxInfo - waitForReady() now requires !servicePaused in addition to COMPLETED deployment status, preventing false positives when resuming
downloadServiceFileStream returns a completionPromise that indicates whether the underlying cat command succeeded. Without checking it, readFile could return empty/partial data on failure.
Call execServiceCommand directly with command array instead of going through bash -c with string interpolation. Prevents unintended shell expansion if remotePath contains metacharacters like $, backticks, etc.
- Use type-only import for Result - Extract deleteServiceIfExists/deleteVolumeIfExists helpers - Simplify buildTags with functional style
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.
Description
Introduce the Northflank sandbox client for managing isolated Linux containers via the Northflank API.
Two-class design:
NorthflankSandboxClient- Factory for creating and attaching to sandboxesSandbox- Attached instance with all operationsFactory methods:
create(apiToken, configOverrides?)- Create a client instancecreateSandbox(serviceName, metadata?)- Create a new sandbox with persistent volumeattach(info)- Reconnect to an existing sandboxSandbox operations:
exec(command)- Run bash commands, returns stdout/stderr/exitCodewriteFile(path, content)- Write files to the sandboxreadFile(path)- Read files from the sandboxpause()/resume()- Pause/resume to save costs (idempotent)destroy()- Delete sandbox and volume (idempotent, 404 = success)Error handling:
Result<T, SandboxError>for recoverable errors (name collision, timeout)Configuration: Compute plans, spot node scheduling, timeouts, persistent volumes.
This is the foundation for sandbox MCP server tools.
Tests
Risk
Low - New module with no integration points yet.
Deploy Plan
Standard deploy. Not used until sandbox MCP server tools are implemented.