CubeSandbox icon indicating copy to clipboard operation
CubeSandbox copied to clipboard

feat(examples): add template collection for common sandbox scenarios (#645)

Open xyaohubery opened this issue 4 months ago • 2 comments

Summary

Add Dockerfile templates for common sandbox scenarios to improve onboarding.

Templates

  • python-data-science: pandas, numpy, matplotlib, scikit-learn, seaborn, plotly
  • nodejs-server: Node.js 22 + npm, yarn, pnpm
  • go-dev: Go development environment

Usage

docker build -t my-registry/sandbox-python:latest python-data-science/
docker push my-registry/sandbox-python:latest
cubemastercli tpl create-from-image --image my-registry/sandbox-python:latest ...

Fixes #645

Assisted-by: claude-code:deepseek-v4-pro

xyaohubery avatar Jul 07 '26 01:07 xyaohubery

PR Review: #787 — Template collection + MCP server

Overall, this is a well-structured PR. The MCP server shows careful attention to async patterns, error sanitization, and lifecycle management. The Dockerfiles follow security best practices (GPG-pinned APT repos, pinned tool versions, apt cleanup). The bilingual documentation is comprehensive.

Key Findings

Code Quality (mcp_server.py)

  • Signal handler is a no-op (line 555): SIGTERM/SIGINT are silently swallowed. The process cannot be gracefully shut down externally — it relies entirely on stdio disconnect. This also means the atexit cleanup (which calls sb.kill() synchronously) may block process exit for the full HTTP timeout if CubeAPI is unreachable.
  • _sanitize_path doesn't reject absolute paths (line 123): The docstring claims it does, but p.is_absolute() is never checked. Defense-in-depth gap.
  • Lock scope doesn't protect SDK operations (line 347): _sandbox is read under the lock, but the lock is released before SDK calls execute. Barely exploitable with current stdio transport, but a ticking bomb for any future concurrent usage.
  • _sanitize_path doesn't resolve symlinks: If the sandbox workspace contains a symlink pointing outside the workspace, the current lexical .. check won't catch it.
  • sandbox_get_info key casing (line 466): Dict keys use camelCase; if the SDK returns snake_case, all lookups silently fail and the fallback "no recognised keys" message fires.

Documentation Issues

  • "can be resumed" is misleading: sandbox_pause creates a snapshot but there is no sandbox_resume tool. The docs imply you can resume directly.
  • Broken SDK path: README.md line 274 and README_zh.md line 254 link to ../sdk/python/README.md which resolves to a non-existent path.
  • Chinese README missing platform requirements: The Chinese README omits the Linux x86_64/KVM requirement and WSL2 incompatibility warning that the English README includes.
  • verify=False not implemented: The troubleshooting table in the integration guide suggests passing verify=False, but the MCP server has no such parameter.

Test Coverage

  • No tests included. The validation helpers (_validate_int, _require_str, _sanitize_path, _sanitize_error) are pure functions and would be high-ROI candidates for unit tests. The repo's existing SDK tests at sdk/python/tests/test_sandbox.py (using unittest.mock.patch and pytest-asyncio) provide a good pattern to follow.

Template Collection (Dockerfiles)

  • Well-structured with good practices: single RUN layers, --no-cache-dir, rm -rf /var/lib/apt/lists/*, pinned package versions, GPG-verified APT repos.
  • No issues found.

Positive Highlights

  • Clean separation of validation, error sanitization, and tool handler logic in the MCP server.
  • Bilingual documentation is thorough and largely well-synced.
  • atexit cleanup and asyncio.Lock guard show thoughtful lifecycle management.
  • Node.js Dockerfile correctly avoids curl|bash in favor of GPG-pinned APT.
  • Inline comments were posted for the specific issues noted above.

cubesandboxbot[bot] avatar Jul 07 '26 02:07 cubesandboxbot[bot]

Hello, thank you for your contribution! Since we have a large number of participants in this event, to speed up the PR review process, could you please attach some screenshots and logs (both are needed) showing the verification process and results for this PR? Thank you for your participation!

fslongjin avatar Jul 10 '26 07:07 fslongjin

Hi @fslongjin, sorry for the late reply. Same as my other PRs — I'm on a Windows machine without access to a Linux/KVM environment, so I'm unable to run a real CubeSandbox cluster to capture the verification screenshots and logs you requested. CI is green and the auto-review bot feedback has been addressed in follow-up commits. Would it be possible to proceed with CI + code review, or could someone on the team help verify on a real cluster? Happy to make any code changes needed. Thanks!

xyaohubery avatar Jul 22 '26 07:07 xyaohubery

@fslongjin I'd like to request reopening this PR.

The changes are purely additive — three Dockerfiles with documentation under . They do not touch any core code paths. The Dockerfiles follow project best practices (GPG-pinned APT repos, pinned versions, apt cleanup) as confirmed by the auto-review bot.

CI is green and all auto-review bot feedback was addressed in follow-up commits. I understand verification screenshots were requested, but these are standard Dockerfiles that can be verified via docker build without a full CubeSandbox cluster. I'm happy to:

  1. Provide docker build logs if that would satisfy the verification requirement
  2. Make any code changes the reviewers identify

Could you please reconsider, or let me know specifically what verification is needed for Dockerfile-only changes?

Co-Authored-By: Claude [email protected]

xyaohubery avatar Aug 05 '26 08:08 xyaohubery