`/workspace/<sessionId>/` directories accumulate on sandbox pods for workload runs

Open
#551 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
56/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript

Research direction

Read harness/src/select-sandbox.ts and trace how workload sessions set workspaceKey; compare that path with remote-worker/internal/exec/workspace.go, where the workspace directory is created. Reproduce with a workload run and inspect /workspace/ on the sandbox pod. Done means workload runs no longer leave an unused per-session directory, while ordinary workspace behavior still works.

Written by the indexing model from the issue text.

Description

Summary

For a session dispatched with --workload, the leaf's cwd is correctly set to /workspace/.moca-context/runs/<sid>/ (per #534), but the sandbox worker still also creates an empty /workspace/<sessionId>/ directory on first Exec, which the leaf never uses.

To reproduce

Dispatch a leaf with --workload, let it finish, kubectl -n moca-sandbox exec moca-sandbox-0 -c sandbox -- ls -la /workspace/. The <sessionId>/ directory is present and empty; .moca-context/{cache,runs,used} have correctly cleaned up.

Trace
  • harness/src/select-sandbox.ts passes { workspaceKey: sessionId } on every Exec, regardless of whether the session has a workload.
  • remote-worker/internal/exec/workspace.go WorkspaceRunner creates <WorkspaceRoot>/<key>/ on first use of a new key (the workspace-subdir capability).
  • DefaultWorkspaceIdle = 30 * time.Minute sweeps these eventually, but between runs the pod visibly carries empty session dirs:
    drwxr-xr-x b38c63c3-1dcb-45cb-a29c-10adba32ca5c (empty)
    drwxr-xr-x ea4bc0e4-cde7-40ac-a01c-747d494ee371 (empty)
Potential fixes
  1. Skip workspace_key for workload runs: if the session carries a workloadId, the leaf's cwd is the workload mount, and the per-session /workspace/<sid>/ serves no purpose.
  2. Sweep eagerly on session end: remove /workspace/<sid>/ when the session's final /v1/runs completes, instead of waiting 30 minutes idle.
  3. Create lazily: don't mkdir /workspace/<sid> until the first Exec targeting that cwd (and workload runs never target that cwd)
Dominant language
TypeScript
Stars
5
Forks
12
Avg merge
9h 42m
Merged PRs (30d)
168

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rossoctl/moca

All issues in rossoctl/moca

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.