Skip to content

feat: Add sandbox integration - #436

Open
dragosgheorghioiu wants to merge 19 commits into
prod-stagingfrom
dragosg/feat/sandbox-api-integration
Open

feat: Add sandbox integration#436
dragosgheorghioiu wants to merge 19 commits into
prod-stagingfrom
dragosg/feat/sandbox-api-integration

Conversation

@dragosgheorghioiu

Copy link
Copy Markdown
Contributor

No description provided.

@dragosgheorghioiu
dragosgheorghioiu force-pushed the dragosg/feat/sandbox-api-integration branch 2 times, most recently from 0320422 to 0ff74af Compare August 7, 2026 04:08
@dragosgheorghioiu
dragosgheorghioiu marked this pull request as ready for review August 7, 2026 04:18
@dragosgheorghioiu
dragosgheorghioiu force-pushed the dragosg/feat/sandbox-api-integration branch from f38a068 to 69ab70e Compare August 7, 2026 10:14
@jedevc

jedevc commented Aug 7, 2026

Copy link
Copy Markdown
Member

Can you update the description with info on how to run the plugin? Also probably worth looking at https://linear.app/unikraft/issue/TOOL-1319/publish-plugins-images.

Comment thread internal/cmd/shell.go
Comment thread internal/cmd/shell.go
Comment thread internal/cmd/shell.go Outdated
Comment thread internal/cmd/shell_builtins.go Outdated
Comment thread internal/cmd/sandbox.go Outdated
Comment thread internal/cmd/sandbox_test.go Outdated
Comment thread internal/cmd/shell.go Outdated
Comment on lines +103 to +106
fields := shellFields(line)
if len(fields) == 0 {
return false
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we're not using the evaluator things in mvdan.sh, it means that things like volumes mounted > out don't work. Also echo $(volumes mounted) won't work, because it's not present in the shell.

If we really don't want to use the evaluator (and want to directly rely on the host's shell), we need to be clear that these are special commands (some sort of prefix, maybe /, like /volumes mounted)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the builtins are documented in the help menu but i can make the fact clear that they cannot run on the sandbox directly

maybe some different syntax highlighting for them can also be a plus

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, but we should be very clear that they are evaluated differently - different syntaxing is a plus, but also additional syntax to really clarify is useful too. Otherwise, users will attempt to use it like I showed, and will be surprised that it doesn't.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a special "builtin mode" that is triggered by keybind where you can only run builtins
maybe that would be clear enough for the user

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's also possible. I've seen some cool stuff before where you type something like ! at the beginning of the line, and the prompt changes - but if you backspace, it goes back to the normal prompt. So it's not like a "mode", it's more like a nice display on top of a prefix.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure how to handle cd and export because they technically run locally

for example:
:cd - runs locally and changes the cwd for the following commands
cd - runs on the instance itself and effects only the current command

@jedevc jedevc Aug 14, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh 🙁 hm, cd then needs to be different. although, argh, this works really weirdly for things like echo foo; cd bar; pwd.

make an exception for cd for now, but as I've mentioned before, we need to do some real shell parsing to properly solve this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but then it would be really unclear where the cd is being run

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, exactly, but that's the problem with this approach.

IMO, just pick something that feels sensible for now, this is experimental anyways — we should make sure there's a log message on all sandbox commands warning that this is experimental. I'm confident these problems are solvable, but the core problem is that we are trying to handle some builtins ourselves, and sending others to the remote sh — this split responsibility is what's causing all this. The solution is to remove the split:

  • Either we use mvdan/sh and have all the commands + builtins evaluated directly by us.
  • Or we open a login shell on the remote, and just stream all our commands there, so there's only one command running, then there's cd persistence there (but we then lose the ability to know the working directory at all, and a bunch of other shiny things).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe the "different mode" idea would work better for now

Comment thread internal/cmd/shell.go Outdated
Comment thread internal/cmd/shell.go Outdated
Comment thread internal/cmd/shell_builtins.go Outdated
Comment thread internal/multimetro/client.go Outdated
Comment thread internal/cmd/sandbox.go
Comment thread internal/cmd/sandbox.go Outdated
@dragosgheorghioiu
dragosgheorghioiu force-pushed the dragosg/feat/sandbox-api-integration branch from ec6831f to 797784e Compare August 11, 2026 17:54
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/sandbox.go
{
Description: "Run a command on a sandbox instance",
Commands: []string{
"unikraft instance exec my-instance --plugin sandbox -- echo hello",

@nderjung nderjung Aug 11, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can derive the default --plugin <name> for sandbox from https://github.com/unikraft-cloud/openapi/blob/prod-staging/plugins/sandbox.yaml#L838-L839 (and image)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

i think the sdk exports only the name for now, i can also add suport for it to export the image as well
happy to add it as it may also enable stuff like --sandbox or --plugin sandbox in the create instance command

@dragosgheorghioiu
dragosgheorghioiu force-pushed the dragosg/feat/sandbox-api-integration branch from 20e8d22 to 18f7c11 Compare August 13, 2026 07:11
Signed-off-by: Dragos Gheorghioiu <dragosg@unikraft.com>
Signed-off-by: Dragos Gheorghioiu <dragosg@unikraft.com>
Signed-off-by: Dragos Gheorghioiu <dragosg@unikraft.com>
Signed-off-by: Dragos Gheorghioiu <dragosg@unikraft.com>
Signed-off-by: Dragos Gheorghioiu <dragosg@unikraft.com>
Signed-off-by: Dragos Gheorghioiu <dragosg@unikraft.com>
Signed-off-by: Dragos Gheorghioiu <dragosg@unikraft.com>
Signed-off-by: Dragos Gheorghioiu <dragosg@unikraft.com>
Signed-off-by: Dragos Gheorghioiu <dragosg@unikraft.com>
Signed-off-by: Dragos Gheorghioiu <dragosg@unikraft.com>
Signed-off-by: Dragos Gheorghioiu <dragosg@unikraft.com>
Signed-off-by: Dragos Gheorghioiu <dragosg@unikraft.com>
Signed-off-by: Dragos Gheorghioiu <dragosg@unikraft.com>
Signed-off-by: Dragos Gheorghioiu <dragosg@unikraft.com>
Signed-off-by: Dragos Gheorghioiu <dragosg@unikraft.com>
@dragosgheorghioiu
dragosgheorghioiu force-pushed the dragosg/feat/sandbox-api-integration branch from 18f7c11 to 50fee59 Compare August 13, 2026 07:32
@dragosgheorghioiu
dragosgheorghioiu force-pushed the dragosg/feat/sandbox-api-integration branch 2 times, most recently from 281035d to 6230e23 Compare August 13, 2026 07:50
Signed-off-by: Dragos Gheorghioiu <dragosg@unikraft.com>
@dragosgheorghioiu
dragosgheorghioiu force-pushed the dragosg/feat/sandbox-api-integration branch from 6230e23 to e69382b Compare August 13, 2026 08:08
Signed-off-by: Dragos Gheorghioiu <dragosg@unikraft.com>
Signed-off-by: Dragos Gheorghioiu <dragosg@unikraft.com>
Signed-off-by: Dragos Gheorghioiu <dragosg@unikraft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants