Repository navigation
[docs] add initial documentation for Ray sandboxing - #65503
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces comprehensive documentation for Ray Sandboxes, an experimental feature that utilizes gVisor to provide lightweight, kernel-isolated execution environments on Ray clusters. The changes include a new deployment guide for Kubernetes (GKE) and a detailed core concept guide covering architecture, APIs, and security models. The review feedback highlights several formatting and syntax issues that need to be addressed, such as bullet point inconsistencies, incorrect step numbering, a shell command prefix, and syntax errors in both Markdown and RST files (including incorrect cross-references and Markdown syntax used inside an RST file).
| - {ref}`kuberay-rayservice-deepseek-example` | ||
| - {ref}`kuberay-verl` | ||
| - {ref}`kuberay-agent-sandbox` | ||
| * {ref}`kuberay-sandboxing` |
| kubectl get pods -l job-name=rayjob-sandbox | ||
|
|
||
| # Stream the demo logs | ||
| $ kubectl logs -f -l job-name=rayjob-sandbox |
| ``` | ||
| --- | ||
|
|
||
| ## (Optional) Step 6: Verify Isolation and Security Guarantees |
|
|
||
| --- | ||
|
|
||
| ## (Optional) Step 7: Build a Custom Ray Image with Pre-installed `runsc` |
7ae9d6b to
130b8b6
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 130b8b6. Configure here.
| print(result.stdout) | ||
| ray.get(pool.close.remote()) | ||
| ``` | ||
|
|
There was a problem hiding this comment.
We should add another section here Example (advanced): Passing configurations directly to gvisor where we show some more of the most common ways to use _oci_spec_transform_fn, e.g. for host mounts, setting up networking and passing capabilities. And maybe a note that we are iterating on this and how to best expose these without needing _oci_spec_transform_fn and we would love to hear about people's feedback in an issue.
There was a problem hiding this comment.
We should add here that _by default_, the working directory is the only writable path in the sandbox and that by setting readonly = False the whole file system can be made writeable (and make it clear to the reader that writes will go into an overlayfs filesystem so multiple file systems with the same image that do writes won't interfere with each other). [I believe this is true, let me know if it is not]
There was a problem hiding this comment.
Same comment as I made here https://github.com/ray-project/ray/pull/65503/changes#r3793075723 -- this one is arguably more important since the docs to create is linked from the main docs very prominently.
There was a problem hiding this comment.
Maybe we should say something like Create a _remote_ sandbox environment. or similar to make the difference to the SandboxRuntime clearer.
| ### Core Components | ||
|
|
||
| 1. **High-Level Helper ({func}`ray.experimental.sandbox.create <ray.experimental.sandbox.create>`):** Spawns a Ray actor that encapsulates the sandbox lifecycle and returns an `ActorHandle`. | ||
| 2. **Sandbox Actor ({class}`ray.experimental.sandbox.Sandbox <ray.experimental.sandbox.Sandbox>`):** A Ray actor managing scheduling, lifecycle, command execution, and file I/O for an isolated sandbox instance. |
There was a problem hiding this comment.
Maybe we can modify this a little bit and say something like A Ray actor that serves as a proxy to forward command execution and file I/O to the isolated sandbox instance and manages scheduling and lifecycle of the sandbox or similar, to make the mental model clear to the user that the actor is not actually run in the sandbox.
|
|
||
| To install `runsc` on a Linux worker node, see the [gVisor installation guide](https://gvisor.dev/docs/user_guide/install/). | ||
|
|
||
| ## Usage Patterns and Examples |
There was a problem hiding this comment.
I imagine this section is actually the most useful for users so we should move it up. Some of the above sections are more interesting from the internal implementation perspective which users will generally be less interested in, it would make more sense to move those down a little more.
|
Thanks a lot for putting this together, I finished reviewing it now. It looks great, I left a bunch of suggestions. Also cc @dstrodtman who might have additional comments or suggestions :) |
|
thanks for the review, all comments addressed |
dstrodtman
left a comment
There was a problem hiding this comment.
Docs style review (Anyscale docs team)
Douglas Strodtman, technical writer on the Anyscale docs team. @pcmoritz cc'd me above, so here's a full pass. Claude Code assisted with the mechanical sweeps and the verification queries below; I read every comment before posting and I stand behind each one.
Scope: style, grammar, and Ray docs conventions only, against the Ray documentation style guide. I don't own whether any of the described behavior is true. Everything technical below is a question for you and @pcmoritz, not a request. Happy to give this a docs-side approval once the content questions settle.
Worth saying plainly: this is the first Claude-aided review I've run against the Kubernetes and KubeRay conventions that landed in #65239, so the guide is getting its first real workout here. I read every recommendation and they all match what I'd have written by hand. But if a specific term or rule reads wrong to you, that's useful signal about the rule rather than a verdict on this PR, and I'd rather hear it and refine the guide than have you apply something that doesn't fit. You reviewed #65239, so you're the right person to push back.
I read the existing threads first. @pcmoritz's six comments and the bot findings all look applied at b1029a1, including the section reorder, the "remote sandbox" wording, the proxy-actor description, and the readonly docstrings. Where I comment on that text I'm styling your applied fix, not reopening the request.
One bot suggestion to skip: the gemini comment asking to point the resource-isolation cross-reference at resource-isolation-with-cgroupv2. I checked the tree; .. _resource-isolation: is the label defined in doc/source/ray-core/resource-isolation-with-cgroupv2.rst and resource-isolation-with-cgroupv2 isn't a label anywhere. What you have is correct.
What the inline comments cover
The bulk is sentence-case headings, about 20 across the three pages. Nothing in CI catches this: Google.Headings is disabled and .vale.ini doesn't scope Vale to Ray Core or KubeRay pages at all, so it's a human check every time. I batched them into two sweep comments rather than 20 separate ones.
The one structural change I'd push for is the "Benefits of gVisor" H4. It's a bolded benefits list, which the guide names twice as something to cut, and it's the page's only H4. The suggestion folds it into two prose paragraphs and keeps every claim.
The rest: numbered lists that aren't sequences, first-person plural, e.g. and via and "utilizing," a few passive constructions with a nameable actor, and bare {ref} links so text tracks titles.
Questions for you and @pcmoritz
_oci_spec_transform_fnframing.runtime.pydocuments it as "PRIVATE -- development/testing only ... No stability guarantees," while the new advanced section presents it as the supported escape hatch. Since @pcmoritz asked for that section, softening the docstring is probably the right direction, but it should say one thing.RAY_SANDBOX_IGNORE_CGROUPS=1in Troubleshooting. It maps to_ignore_cgroups, also marked "PRIVATE -- testing only" inruntime.py. Is it something users in cgroup-restricted environments should reach for?- The inline RayJob script. It's a hand-copy of the sample YAML and has already drifted by one line (see the L93 comment). A
literalincludeor a link to the sample would keep them from separating further. - Two adjacent sandbox examples. The examples index now lists "Sandboxed Code Execution with Ray and Agent Sandbox" next to "Deploying Ray Sandboxes using KubeRay." They're genuinely different things, but the titles don't say so. One clause on each would help a reader pick.
- Untested snippets. The Python blocks are bare fences, so the doc tests don't run them, and a couple aren't runnable standalone (
sbis undefined in the Step 4 blocks). Fine if that's intentional for illustrative fragments.
Nice work on this. It's a lot of new surface and the structure is right.
Signed-off-by: Andrew Sy Kim <[email protected]>
Signed-off-by: Andrew Sy Kim <[email protected]>
Signed-off-by: Andrew Sy Kim <[email protected]>
Signed-off-by: Andrew Sy Kim <[email protected]>
Signed-off-by: Andrew Sy Kim <[email protected]>
Signed-off-by: Andrew Sy Kim <[email protected]>
Signed-off-by: Andrew Sy Kim <[email protected]>
Signed-off-by: Andrew Sy Kim <[email protected]>
Signed-off-by: Andrew Sy Kim <[email protected]>
Signed-off-by: Andrew Sy Kim <[email protected]>
Signed-off-by: Andrew Sy Kim <[email protected]>
Signed-off-by: Andrew Sy Kim <[email protected]>
Co-authored-by: Douglas Strodtman <[email protected]> Signed-off-by: Andrew Sy Kim <[email protected]>
Co-authored-by: Douglas Strodtman <[email protected]> Signed-off-by: Andrew Sy Kim <[email protected]>
Co-authored-by: Douglas Strodtman <[email protected]> Signed-off-by: Andrew Sy Kim <[email protected]>
Co-authored-by: Douglas Strodtman <[email protected]> Signed-off-by: Andrew Sy Kim <[email protected]>
Co-authored-by: Douglas Strodtman <[email protected]> Signed-off-by: Andrew Sy Kim <[email protected]>
pcmoritz
left a comment
There was a problem hiding this comment.
Looks great, thanks a lot for writing this!
Signed-off-by: Andrew Sy Kim <[email protected]>
bbff47a to
5a0ab45
Compare
Signed-off-by: Andrew Sy Kim <[email protected]>
Signed-off-by: Andrew Sy Kim <[email protected]>
dstrodtman
left a comment
There was a problem hiding this comment.
Second pass from the Anyscale docs team, at 5a0ab45. Run by Douglas Strodtman with Claude Code assisting; I read every comment below and stand behind each one.
Scope: style, grammar, and docs conventions against Ray's own writing style guide. Anything about whether the described behavior is true is @pcmoritz's and your call, not mine. Where I verified a factual claim I say what I checked it against, so you can overrule me with better information.
Thanks for working through the last round. Nearly all of it landed, and the two structural asks in particular are much better: the Core page now leads with usage before architecture the way @pcmoritz asked, and the benefits list and the (Experimental) / alpha duplication are gone. Sentence-case headings are clean on both pages now.
One blocking item
ray-sandboxing.md L180 references {ref}kuberay-resource-isolation``, which isn't a defined label anywhere in doc/source. That's an undefined-label warning, and `doc/Makefile` builds with `-W` while `.readthedocs.yaml` sets `fail_on_warning: true`, so it fails the docs build rather than degrading to plain text. Inline comment has the label I believe you meant. This one is on me: it's a side effect of retargeting my earlier suggestion, which pointed at the Ray Core page instead.
Everything else inline is ordinary style, and none of it should hold the merge.
Things that didn't survive the last round
Flagging these only because they look like GitHub's suggestion-apply dropping the multi-line blocks rather than decisions you made. If any were deliberate, say so and I'll drop them:
- L51-62: "which will create" (future tense), list items without terminal periods.
- L53, L98, L108:
shfence tags; L108 is captured output rather than commands. - L93: the
RayJob completed successfully!string still disagrees with the output block at L114. - L151:
runscunformatted in the heading.
One note and one open question
Note: Step 3's kubectl apply URL isn't live yet, since the sample lands with the open kuberay#5153. It targets master so it self-heals on that merge, and it has no effect on the docs build. You own that PR, so I'm recording it rather than asking about merge order.
Question: _oci_spec_transform_fn still carries two different stability stories. The Core page's note calls it an experimental hook that's likely to change. runtime.py documents it as "PRIVATE -- development/testing only ... No stability guarantees." Raising this again only because it's a reader-facing promise; whichever way you and @pcmoritz reconcile it is fine by me.
Happy to give this the docs-side stamp once the L180 label is fixed. The blocker is a one-line change and the rest is optional polish.
|
|
||
| * See {ref}`ray-core-sandboxes` for API details and custom actor patterns. | ||
| * Learn more about [gVisor](https://gvisor.dev/docs/). | ||
| * Explore {ref}`kuberay-resource-isolation` to configure resource isolation on Kubernetes. |
There was a problem hiding this comment.
This one will fail the docs build, so it's the only thing in this review I'd call blocking.
kuberay-resource-isolation isn't defined anywhere in the tree. I grepped every (label)= and .. _label: under doc/source and there's no such target. An undefined {ref} emits WARNING: undefined label, doc/Makefile passes -W and .readthedocs.yaml sets fail_on_warning: true, and std refs aren't in nitpick_ignore_regex the way py:class is. So this errors rather than degrading quietly.
I think this is my fault: my earlier suggestion pointed at resource-isolation, and the KubeRay-specific retarget picked a label that doesn't exist. The page you almost certainly want is doc/source/cluster/kubernetes/user-guides/resource-isolation-with-writable-cgroups.md, whose label is resource-isolation-with-writable-cgroups. Its own title is long ("Resource isolation with writable cgroups on Google Kubernetes Engine (GKE)"), so this is one of the few places explicit link text reads better than a bare ref:
| * Explore {ref}`kuberay-resource-isolation` to configure resource isolation on Kubernetes. | |
| * Explore {ref}`resource isolation with writable cgroups <resource-isolation-with-writable-cgroups>` to reserve CPU and memory for Ray system processes on Kubernetes. |
If you meant the general Ray Core cgroup v2 page instead, resource-isolation is the valid label for that one.
Co-authored-by: Douglas Strodtman <[email protected]> Signed-off-by: Andrew Sy Kim <[email protected]>
Signed-off-by: Andrew Sy Kim <[email protected]>
…ing (#65503) (#65573) Cherry-pick of #65503 (merge commit d40da45, authored by @andrewsykim) onto `releases/2.58.0`. One conflict, resolved by hand: the PR adds `sandboxes.md` to the Ray Core API toctree in `doc/source/ray-core/api/index.md`, but that file only exists on master (the index was converted from `.rst` to `.md` after the branch cut). Applied the same one-line addition to the branch's `doc/source/ray-core/api/index.rst` instead; everything else picked clean and the commit is otherwise identical to the original (docs pages + docstring updates in `python/ray/experimental/sandbox/`, which already exists on this branch). Not a duplicate: no existing cherry-pick PR for #65503 targets this branch. AI assistance (Claude Code) was used to prepare this cherry-pick; reviewed by the submitter. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Andrew Sy Kim <[email protected]> Signed-off-by: Andrew Sy Kim <[email protected]> Signed-off-by: elliot-barn <[email protected]> Co-authored-by: Andrew Sy Kim <[email protected]> Co-authored-by: Douglas Strodtman <[email protected]>
…t images out of the box (#65570) (#65622) ## Description Cherry-pick of #65570 (`7408258f64`) into `releases/2.58.0`. Brings the Ray Sandbox Docker-image support onto the release branch, complementing the sandbox documentation already cherry-picked in #65573 (#65503). All changes are confined to `python/ray/experimental/sandbox/` plus its doc page and `doc/source/conf.py`. ## Verification - Clean cherry-pick (`git cherry-pick -x -s 7408258`), no conflicts; 14 files changed matching the original commit. - The original change passed full CI on master (merged 2026-08-20); release-branch CI on this PR will validate on 2.58.0. Not a duplicate: no existing cherry-pick PR for #65570 targets `releases/2.58.0`. AI assistance (Claude Code) was used to prepare this cherry-pick. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: xyuzh <[email protected]> Signed-off-by: elliot-barn <[email protected]> Co-authored-by: Xinyu Zhang <[email protected]>
…g section (#65627) (#65734) Cherry-picks the Ray Sandboxes networking-section style pass onto `releases/2.58.0`. Ray Sandboxing (gVisor) ships in 2.58.0 (#64964, #65570, and the initial docs #65503, all already on the release branch). This editorial pass on the networking and DNS section landed on master after the branch cut, so the versioned 2.58.0 docs are missing it. The change is prose-only: it tightens the network-mode table, splits the DNS guidance into its own subsection, and removes recommendation hedging. No behavior or API content changes. Cherry-pick of #65627. --------- Signed-off-by: Douglas Strodtman <[email protected]> Co-authored-by: Claude Opus 4.8 <[email protected]>
## Description Add initial documentation for Ray's experimental sandboxing library. ## Related issues > Link related issues: "Fixes ray-project#1234", "Closes ray-project#1234", or "Related to ray-project#1234". ## Additional information > Optional: Add implementation details, API changes, usage examples, screenshots, etc. --------- Signed-off-by: Andrew Sy Kim <[email protected]> Signed-off-by: Andrew Sy Kim <[email protected]> Co-authored-by: Douglas Strodtman <[email protected]>

Description
Add initial documentation for Ray's experimental sandboxing library.
Related issues
Additional information