Repository navigation
Conversation
Prototype for #37 (broker-level OCI runtime). A profile in the broker's global settings can declare sandbox_runtime: {name: runsc-dind, kind: gvisor, docker_storage_size: 6g} and, with the agent_policy.sandbox_runtime experiment on, agents started under that profile run with `--runtime <name>`. For kind gvisor Scion also adds the flags Docker-inside-gVisor needs (--cap-add ALL, seccomp=unconfined, an executable /var/lib/docker tmpfs) and keeps CAP_NET_RAW; those flags are confined to gVisor's user-space kernel and are only ever added together with the sandbox runtime. kind sysbox adds only --runtime. - Read from the global settings file only (LoadProfileSandboxRuntime); an invalid block refuses the start; runc/crun names are refused. - gVisor agents always use bridge networking (gVisor cannot share the host network stack); SCION_FORCE_HOST_NETWORK with gVisor is refused. - Experiment off, or a non-Docker/Podman runtime: the block is ignored with a warning and the agent starts on the default runtime. Verified on a local workstation hub (WSL, gVisor release-20261123 on the ptrace platform): a claude agent on a build profile ran an inner Docker engine and a testcontainers-go Redis test (Ryuk, mapped port) as the scion user; a privileged inner container mounting / saw only the sandbox.
…runtime experiment
|
Opened here by mistake; it was meant for our fork. Closing. |
There was a problem hiding this comment.
Code Review
This pull request introduces support for sandboxing OCI runtimes (such as gVisor and Sysbox) on Docker and Podman profiles, gated by the new agent_policy.sandbox_runtime experiment. It adds configuration schemas, validation logic, and runtime argument generation to run agents with restricted privileges and inner container engines. The review feedback highlights that the regular expression used to validate the tmpfs storage size for gVisor is overly restrictive, as it limits digits to six and only accepts lowercase suffixes. It is recommended to update the regex to be case-insensitive and support arbitrary digit lengths, along with adding corresponding test cases.
| const DefaultSandboxDockerStorageSize = "6g" | ||
|
|
||
| var ( | ||
| sandboxRuntimeNameRE = regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$`) |
There was a problem hiding this comment.
The regular expression for validating the tmpfs storage size (sandboxTmpfsSizeRE) is overly restrictive. It only accepts lowercase suffixes (k, m, g), whereas standard size suffixes in Docker/Podman and tmpfs mounts are case-insensitive and commonly written in uppercase (e.g., 6G, 4096M). Additionally, it arbitrarily limits the number of digits to 6, which restricts sizes specified in smaller units (for example, 1048576k for 1GB would fail validation because it has 7 digits). Making the regex case-insensitive and removing the arbitrary digit limit makes it more robust and user-friendly.
\tsandboxTmpfsSizeRE = regexp.MustCompile(\"(?i)^[1-9][0-9]*[kmg]$\")| wantErr string | ||
| }{ | ||
| {"gvisor ok", V1SandboxRuntime{Name: "runsc-dind", Kind: "gvisor"}, ""}, | ||
| {"gvisor size ok", V1SandboxRuntime{Name: "runsc", Kind: "gvisor", DockerStorageSize: "4096m"}, ""}, |
There was a problem hiding this comment.
Add test cases to verify that uppercase suffixes (like 4G or 512M) are successfully validated, and that larger digit counts are also allowed.
\t\t{\"gvisor size ok\", V1SandboxRuntime{Name: \"runsc\", Kind: \"gvisor\", DockerStorageSize: \"4096m\"}, \"\"},\n\t\t{\"gvisor size uppercase ok\", V1SandboxRuntime{Name: \"runsc\", Kind: \"gvisor\", DockerStorageSize: \"4G\"}, \"\"},\n\t\t{\"gvisor size large digits ok\", V1SandboxRuntime{Name: \"runsc\", Kind: \"gvisor\", DockerStorageSize: \"1048576k\"}, \"\"},
Refs miller79#37 (filed on our fork; scope agreed there with @ptone). Design note: miller79#37 (comment)
What
Operator-declared sandbox runtimes for Docker and Podman, the counterpart of Kubernetes
runtimeClassName. A profile in the Runtime Broker's global settings can declare:With the experiment
agent_policy.sandbox_runtimeon, agents started under that profile run with--runtime <name>, so they can run their own container engine (Testcontainers, image builds) without the host's engine and without--privileged.Behaviour
gvisoradds--cap-add ALL,--security-opt seccomp=unconfinedand--tmpfs /var/lib/docker:rw,exec,size=<n>, and keepsCAP_NET_RAW. These are what Docker inside gVisor needs; they are confined to gVisor's user-space kernel and are only ever added together with the runtime.sysboxadds only--runtime.config.LoadProfileSandboxRuntime). An invalid block refuses the start, andrunc/crunnames are refused.SCION_FORCE_HOST_NETWORKwith a gVisor profile is refused.Changes
pkg/config:V1ProfileConfig.SandboxRuntime,V1SandboxRuntimewithValidate, andLoadProfileSandboxRuntime. Root schema and Hubprofilessection schema (shape only).pkg/runtime:RunConfig.SandboxandappendSandboxRuntimeArgs, called by the Docker and Podman runtimes. TheCAP_NET_RAWdrop is skipped under gVisor.pkg/agent:resolveStartSandboxRuntime, resolved before the host-networking decision.pkg/experiments,pkg/hub: experimentagent_policy.sandbox_runtime(server, alpha, off), forwarded to brokers and classified deny in the test-admin policy.Tests
TestSandboxRuntimeValidate,TestLoadProfileSandboxRuntime*(pkg/config),TestAppendSandboxRuntimeArgsandTestBuildCommonRunArgs_NetRawDropKeptExceptUnderGVisor(pkg/runtime).go test ./pkg/config/... ./pkg/runtime/ ./pkg/experiments/pass.go vetofpkg/agent,pkg/runtime,pkg/configandpkg/experimentsis clean, and gofmt is clean.node hack/check-docs-links.mjsreports 0 violations.pkg/hubtest suite (it needs more memory than my machine has; CI will run it) andnpm run buildfor the docs site.ptraceplatform because of WSL): a claude agent on abuildprofile ran under gVisor on bridge networking, and as thescionuser a testcontainers-go Redis test passed through the inner engine (mapped port, Ryuk). A--privilegedinner container mounting/saw only the sandbox. With the experiment off, the agent started onruncwithCAP_NET_RAWdropped.🤖 Generated with Claude Code