Repository navigation
Conversation
nderjung
force-pushed
the
nderjung/feat/init
branch
11 times, most recently
from
November 25, 2026 02:06
ea16c49 to
7c9f496
Compare
nderjung
force-pushed
the
nderjung/feat/sandbox-init
branch
from
November 25, 2026 02:46
f54e713 to
7e37e3a
Compare
The sandboxes porcelain wraps the generated plumbing of the sandbox plugin, published as unikraft-cloud-plugin-sandbox-api. Depend on it, and check that ApiClient still satisfies the transport its Transport module declares, signature by signature and over the wire. check_package installs the plugin gems from the bundle's own cache, so it keeps working without an index and with a locally built plugin gem. Signed-off-by: Alexander Jung <alex@unikraft.com>
A sandbox is an instance with the sandbox plugin attached, reached at `ukc.metro(:fra).sandboxes`, or through `Unikraft::Cloud::Sandbox.create` and `.connect`, which build a client from their options. It lives in one metro, so it hangs off a metro scope only. `create` attaches the plugin, applies the image, memory and autokill defaults, waits for the plugin, and deletes the instance it made when that wait fails, naming the likely cause. With a block it deletes the sandbox when the block returns, like `await using` in JS. Commands run to completion with `run`, which takes a shell line or an argument vector like Kernel#system, or start with `spawn`, returning a Command whose standard input reads like an IO (`write`, `close_write`) and that takes signals as Symbols. Files go through `sb.files`, with binary Strings sent as bytes and other Strings as UTF-8. Signed-off-by: Alexander Jung <alex@unikraft.com>
Boot a real sandbox, run commands, and round-trip text and bytes through its filesystem, then check that the create block deletes the machine: the platform reports it gone with an error envelope the SDK reads as a 404. Skipped without UKC_TOKEN, like the rest of the live suite. Signed-off-by: Alexander Jung <alex@unikraft.com>
Show both doors, the create block that deletes the sandbox, commands with run and spawn, standard input and signals, and the filesystem, in the README and as a runnable example mirroring the JS one. Signed-off-by: Alexander Jung <alex@unikraft.com>
nderjung
force-pushed
the
nderjung/feat/sandbox-init
branch
from
November 25, 2026 02:47
7e37e3a to
36ad067
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved sandbox defects can mishandle timeouts, falsely report readiness, leak idle connections after deletion, and ignore explicitly requested deployments.
5 open issues
Preserve explicit metro when creating the owned client · New Unwrap plugin probe responses before declaring readiness · New Close plugin transport connections after sandbox deletion · New Stretch the HTTP timeout for default boot waits · New Forward HTTP timeout through readiness, cleanup, and get · New
What changed in this PR
Adds sandbox support to the Ruby SDK, wrapping the generated plugin client with Ruby-style APIs for managing sandbox instances, commands, and files.
Changes:
- Adds metro-scoped sandbox creation, connection, listing, readiness checks, and block-based cleanup.
- Introduces command execution, standard input, log access, and file operations.
- Adds documentation, examples, unit and live tests, plus plugin dependency and packaging support.
| File | Description |
|---|---|
unikraft-cloud.gemspec |
Declares the sandbox plugin dependency. |
test/unit/sandboxes_test.rb |
Tests sandbox lifecycle, commands, and files. |
test/unit/plugin_transport_test.rb |
Checks plugin transport compatibility. |
test/support/fake_cloud.rb |
Supports binary responses and plugin transport methods. |
test/e2e/sandbox_test.rb |
Adds live sandbox integration tests. |
README.md |
Documents sandbox APIs and usage. |
Rakefile |
Installs cached plugin gems during package checks. |
lib/unikraft/cloud/resources/sandboxes/sandboxes.rb |
Implements sandbox collection and lifecycle operations. |
lib/unikraft/cloud/resources/sandboxes/sandbox.rb |
Adds sandbox handles, readiness, and execution. |
lib/unikraft/cloud/resources/sandboxes/files.rb |
Implements sandbox file operations. |
lib/unikraft/cloud/resources/sandboxes/command.rb |
Adds command handles, input, logs, and signals. |
lib/unikraft/cloud/client.rb |
Exposes sandboxes on metro scopes. |
lib/unikraft/cloud.rb |
Loads sandbox support. |
Gemfile.lock |
Locks the sandbox plugin dependency. |
examples/sandbox.rb |
Demonstrates sandbox workflows. |
CONTRIBUTING.md |
Explains using locally built plugin gems. |
Review effort: Balanced (adaptive)
Comment on lines
+133
to
+135
| ref_kw = kwargs.slice(*Core::Ref.members) | ||
| ukc, rest, scope = door(client, kwargs.except(*Core::Ref.members), | ||
| "`Sandbox.connect(ref, client:)`") |
| # 404 or 502, which the loop retries. | ||
| Core::Ready.wait_until_ready(**policy, timeout: within, what: "sandbox #{uuid}", | ||
| diagnose: ->(_) { diagnose }) do |left| | ||
| api.commands.list_commands(headers:, timeout: left) |
| # | ||
| # @param call [Hash] `headers:`, `timeout:` | ||
| # @return [Resources::InstanceHandle] carrying what the platform reported | ||
| def delete(**call) = instance.delete(**call) |
| plugin_name = (spec.delete(:plugin_name) || Sandbox::DEFAULT_PLUGIN_NAME).to_s | ||
| body = instance_body(spec, plugin_name, spec.delete(:rom)) | ||
| body[:timeout_s] = boot_within || (ready == false ? 0 : Sandbox::DEFAULT_BOOT_WITHIN) | ||
| booting = boot_within&.positive? ? { timeout: boot_within + 10 }.merge(call) : call |
| body[:timeout_s] = boot_within || (ready == false ? 0 : Sandbox::DEFAULT_BOOT_WITHIN) | ||
| booting = boot_within&.positive? ? { timeout: boot_within + 10 }.merge(call) : call | ||
| sandbox = attach(create_instance(body, booting), plugin_name) | ||
| ready_or_delete(sandbox, ready, headers) unless ready == false |
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.

Adds sandboxes to the Ruby SDK, on top of #1. They wrap the sandbox plugin's generated client,
unikraft-cloud-plugin-sandbox-api, the same way the JS SDK does.The names follow Ruby rather than JS:
execbecomesrun(Ruby'sexecreplaces the process),startbecomesspawn, stdin iswrite/close_write, and file methods live undersb.files. As in the rest of the SDK,within:is a server-side wait andtimeout:is only the HTTP timeout.Before this can go green:
unikraft-cloud-plugin-sandbox-apihas to be on RubyGems first. Until it is,bundle installfails in CI. The end-to-end sandbox tests have not been run against a live account yet.