Skip to content

Make the bwrap alias a wrapper around the sandboxexec Go bindings. - #14022

Open
milantracy wants to merge 1 commit into
google:masterfrom
milantracy:bwrap
Open

Make the bwrap alias a wrapper around the sandboxexec Go bindings.#14022
milantracy wants to merge 1 commit into
google:masterfrom
milantracy:bwrap

Conversation

@milantracy

@milantracy milantracy commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

bwrap previously built its own specs.Spec, wrote an OCI bundle and drove runsc/container directly. It now only parses the bubblewrap command line and translates it into sandbox.Options; //sandboxexec/sandbox owns the bundle, the runsc invocation and the container lifecycle.

Update #13747
Fix #14020

Comment thread sandboxexec/sandbox/sandbox.go Outdated
Comment thread sandboxexec/sandbox/sandbox.go Outdated
copybara-service Bot pushed a commit that referenced this pull request Aug 6, 2026
bwrap previously built its own specs.Spec, wrote an OCI bundle and drove runsc/container directly. It now only parses the bubblewrap command line and translates it into sandbox.Options; //sandboxexec/sandbox owns the bundle, the runsc invocation and the container lifecycle.

To support this, the bindings gain:
- Run, an attached counterpart to New that runs a command to completion over `runsc run`, preserving its stdio and exit code, and relaying signals into the container via `runsc kill`.
- Options for the process, rootfs, namespaces, ID mappings and mount options bwrap needs, plus opt-outs for the bindings' default mounts, host binary mounts and base environment. Every zero value reproduces the previous bundle layout.
- Config, which resolves options into a BundleConfig for testing.
- runsc stderr in the failure message from New, instead of a bare exit status.

Signal relaying skips SIGURG, SIGPIPE and SIGCHLD as pkg/sighandling does; relaying SIGCHLD would be self-sustaining, since each forwarded signal spawns a runsc process whose exit raises another.

Behavior deltas: bwrap now forks a runsc process, passes --ignore-cgroups when not root, and roots a container with no `--bind / /` at the bundle's rootfs directory rather than a separate temporary directory.

FUTURE_COPYBARA_INTEGRATE_REVIEW=#14022 from milantracy:bwrap 24a225e
PiperOrigin-RevId: 960524302
@carzh carzh linked an issue Aug 6, 2026 that may be closed by this pull request
6 tasks
copybara-service Bot pushed a commit that referenced this pull request Aug 6, 2026
bwrap previously built its own specs.Spec, wrote an OCI bundle and drove runsc/container directly. It now only parses the bubblewrap command line and translates it into sandbox.Options; //sandboxexec/sandbox owns the bundle, the runsc invocation and the container lifecycle.

To support this, the bindings gain:
- Run, an attached counterpart to New that runs a command to completion over `runsc run`, preserving its stdio and exit code, and relaying signals into the container via `runsc kill`.
- Options for the process, rootfs, namespaces, ID mappings and mount options bwrap needs, plus opt-outs for the bindings' default mounts, host binary mounts and base environment. Every zero value reproduces the previous bundle layout.
- Config, which resolves options into a BundleConfig for testing.
- runsc stderr in the failure message from New, instead of a bare exit status.

Signal relaying skips SIGURG, SIGPIPE and SIGCHLD as pkg/sighandling does; relaying SIGCHLD would be self-sustaining, since each forwarded signal spawns a runsc process whose exit raises another.

Behavior deltas: bwrap now forks a runsc process, passes --ignore-cgroups when not root, and roots a container with no `--bind / /` at the bundle's rootfs directory rather than a separate temporary directory.

FUTURE_COPYBARA_INTEGRATE_REVIEW=#14022 from milantracy:bwrap 24a225e
PiperOrigin-RevId: 960524302
copybara-service Bot pushed a commit that referenced this pull request Aug 6, 2026
bwrap previously built its own specs.Spec, wrote an OCI bundle and drove runsc/container directly. It now only parses the bubblewrap command line and translates it into sandbox.Options; //sandboxexec/sandbox owns the bundle, the runsc invocation and the container lifecycle.

To support this, the bindings gain:
- Run, an attached counterpart to New that runs a command to completion over `runsc run`, preserving its stdio and exit code, and relaying signals into the container via `runsc kill`.
- Options for the process, rootfs, namespaces, ID mappings and mount options bwrap needs, plus opt-outs for the bindings' default mounts, host binary mounts and base environment. Every zero value reproduces the previous bundle layout.
- Config, which resolves options into a BundleConfig for testing.
- runsc stderr in the failure message from New, instead of a bare exit status.

Signal relaying skips SIGURG, SIGPIPE and SIGCHLD as pkg/sighandling does; relaying SIGCHLD would be self-sustaining, since each forwarded signal spawns a runsc process whose exit raises another.

Behavior deltas: bwrap now forks a runsc process, passes --ignore-cgroups when not root, and roots a container with no `--bind / /` at the bundle's rootfs directory rather than a separate temporary directory.

FUTURE_COPYBARA_INTEGRATE_REVIEW=#14022 from milantracy:bwrap 24a225e
PiperOrigin-RevId: 960524302

@EtiennePerot EtiennePerot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please write the comments as a human, this is annoying to read :)

Comment thread sandboxexec/sandbox/oci.go Outdated
Comment thread sandboxexec/sandbox/oci.go Outdated
Comment thread sandboxexec/sandbox/sandbox.go Outdated
Comment thread sandboxexec/sandbox/sandbox.go Outdated
Comment thread sandboxexec/sandbox/sandbox.go Outdated
Comment thread sandboxexec/sandbox/sandbox.go Outdated
Comment thread sandboxexec/sandbox/sandbox.go Outdated
Comment thread sandboxexec/sandbox/sandbox.go Outdated
Comment thread sandboxexec/sandbox/sandbox.go Outdated
Comment thread sandboxexec/sandbox/sandbox.go Outdated
Comment thread runsc/cmd/alias/bwrap/bwrap_test.go Outdated
Comment thread runsc/cmd/alias/bwrap/bwrap_test.go Outdated
Comment thread sandboxexec/sandbox/oci_test.go
Comment thread sandboxexec/sandbox/oci.go Outdated
Comment thread sandboxexec/sandbox/sandbox.go Outdated
Comment thread sandboxexec/sandbox/sandbox.go
Comment thread sandboxexec/sandbox/sandbox.go Outdated
@milantracy
milantracy force-pushed the bwrap branch 2 times, most recently from b3bc79e to 2fc124d Compare August 25, 2026 08:43
Comment thread runsc/cmd/alias/bwrap/bwrap.go Outdated
Comment thread runsc/cmd/alias/bwrap/bwrap.go
Comment thread runsc/cmd/alias/bwrap/bwrap.go Outdated
bwrap previously built its own specs.Spec, wrote an OCI bundle and drove
runsc/container directly. It now only parses the bubblewrap command line
and translates it into sandbox.Options; //sandboxexec/sandbox owns the
bundle, the runsc invocation and the container lifecycle.

@EtiennePerot EtiennePerot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good other than the one comment

// The command inherits the working directory, environment, user and
// capabilities the sandbox was created with. Calls may run concurrently, unless
// WithExecSignalRelay asks for the signal relay.
func (s *Sandbox) Exec(ctx context.Context, opts ...ExecOption) (*ExecResult, error) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sorry, I should probably have brought this up before, but I think we should keep arguments in the function signature rather than requiring WithExecArgs. This is similar to how all other exec-ish APIs work (positional arguments used to encode argv, optional/keyword-ish arguments to encode options)

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.

runsc/cmd/alias/bwrap to use sandboxexec/sandbox Enable migrating gVisor bwrap to go bindings

4 participants