Skip to content

fix(microsandbox): mount workspace source and make it usable by the remote user#778

Merged
skevetter merged 1 commit into
mainfrom
impolite-turtle
Jul 27, 2026
Merged

fix(microsandbox): mount workspace source and make it usable by the remote user#778
skevetter merged 1 commit into
mainfrom
impolite-turtle

Conversation

@skevetter

Copy link
Copy Markdown
Contributor

Summary

Fixes the microsandbox microVM backend so a devcontainer workspace actually works. Previously VS Code failed to connect: the workspace source was never shared into the microVM, so /workspaces/<name> did not exist ("Workspace does not exist"), and even once mounted the virtiofs share was root-owned and unusable by a non-root remote user.

Three root causes addressed, plus an OOM default:

  1. Workspace source not mounted. The driver ignored options.WorkspaceMount and dropped bind mounts entirely. Now the workspace bind mount and any MountTypeBind mounts are translated to msb --mount-dir SOURCE:DEST[:ro] (virtiofs).
  2. Mount root-owned in the guest. msb's virtiofs share presents files as root:root with no UID mapping, and microsandbox does no UID remap. Added a driver.WorkspaceChowner capability; microsandbox reports it, so the agent recursively chowns the workspace to the remote user — the same treatment podman machine already gets for the identical problem.
  3. ChownR aborted early. The recursive chown bailed on the first un-chownable entry (read-only .git pack files on the share), leaving everything after it root-owned. It now skips failed entries, finishes the walk, and returns aggregated errors.
  4. OOM on connect. MICROSANDBOX_MEMORY now defaults to 2048 MiB, so the VS Code extension host no longer gets OOM-killed on first connect (the VM previously booted at the runtime's ~512 MiB default). User-set values still win.

Validation

Verified end-to-end on a clean microsandbox workspace (cross-compiled Linux agent injected via DEVSY_AGENT_BINARY):

  • msb inspect shows the /workspaces/<name> bind mount.
  • Setup log shows chown workspace recursively: user=vscode.
  • Over SSH and msb exec as vscode: cd into the folder works, all files (incl. app.py, .gitignore, .github/*) are vscode-owned and editable, git status clean.

gofmt, go vet, and all tests in the touched packages (267) pass.

Notes

  • The agent-side fixes (ChownR, chownWorkspace gating) ship in the Linux agent binary and take effect once a release is built from this code.
  • The memory default only applies to freshly-resolved provider options; existing workspaces with an explicit value are unchanged.

@netlify

netlify Bot commented Jul 27, 2026

Copy link
Copy Markdown

Deploy Preview for images-devsy-sh canceled.

Name Link
🔨 Latest commit 5dc8b6d
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a6703c90c3f300008b41ecb

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@skevetter, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 30 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 36a827ec-2f66-4647-97cc-02c7f2216484

📥 Commits

Reviewing files that changed from the base of the PR and between 9776e9d and 5dc8b6d.

📒 Files selected for processing (11)
  • pkg/copy/copy.go
  • pkg/devcontainer/setup.go
  • pkg/devcontainer/setup/setup.go
  • pkg/devcontainer/setup_test.go
  • pkg/driver/microsandbox/cliclient.go
  • pkg/driver/microsandbox/cliclient_test.go
  • pkg/driver/microsandbox/client.go
  • pkg/driver/microsandbox/microsandbox.go
  • pkg/driver/microsandbox/microsandbox_test.go
  • pkg/driver/types.go
  • providers/microsandbox/provider.yaml

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@netlify

netlify Bot commented Jul 27, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit 5dc8b6d
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a6703c97ef5960008ab66a5

…e user

The microsandbox driver never shared the workspace source into the microVM,
so the devcontainer workspaceFolder (/workspaces/<name>) did not exist and VS
Code failed to connect with "Workspace does not exist". Even once mounted, the
virtiofs share is root-owned in the guest with no UID mapping, so a non-root
remote user could not enter or edit it.

- Translate the workspace bind mount (options.WorkspaceMount) and MountTypeBind
  mounts into `msb --mount-dir SOURCE:DEST[:ro]`.
- Add a WorkspaceChowner capability so the agent recursively chowns the
  workspace to the remote user (as it already does for podman machine).
- Stop ChownR from aborting the whole walk on a single un-chownable entry
  (e.g. read-only .git pack files on the share), leaving the rest unowned.
- Default MICROSANDBOX_MEMORY to 2048 MiB so the VS Code extension host no
  longer OOMs on first connect.
@skevetter
skevetter marked this pull request as ready for review July 27, 2026 07:49
@skevetter
skevetter merged commit ff6197e into main Jul 27, 2026
66 checks passed
@skevetter
skevetter deleted the impolite-turtle branch July 27, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant