mirror of
https://github.com/sredevopsorg/deepseek-kubernetes-sandbox.git
synced 2026-11-03 01:13:24 +00:00
feat(example): start DSH's folder picker on the persisted workspace (#36)
The directory picker has no start-path setting: it lists $HOME whenever it opens. With the image default HOME=/home/node the folder explorer started on a throwaway directory, so point HOME at the PVC-backed /workspace in both sandbox templates. `~` and $HOME-relative tool caches/config follow; DSH_HOME stays /home/node/.dsh, so sessions, config and credentials are unaffected. Document the trade-off in the image contract and both examples, add troubleshooting for sandboxes whose pod env was stamped before the change, and assert HOME/~ in the e2e walkthrough. Co-authored-by: SREDevOpsAgents <agents@sredevops.org>
This commit is contained in:
committed by
GitHub
parent
a09d4ac340
commit
82ee0d0cdb
@@ -201,6 +201,7 @@ kubectl -n dsh-demo port-forward "pod/$SB" 18081:3080
|
||||
## 4. Write state on the PVC
|
||||
|
||||
```bash
|
||||
kubectl -n dsh-demo exec "$SB" -- printenv HOME # /workspace
|
||||
kubectl -n dsh-demo exec "$SB" -- sh -c 'echo "remember me" > /home/node/.dsh/marker.txt'
|
||||
kubectl -n dsh-demo exec "$SB" -- sh -c 'echo "remember me too" > /workspace/marker.txt'
|
||||
```
|
||||
@@ -210,6 +211,20 @@ kubectl -n dsh-demo exec "$SB" -- sh -c 'echo "remember me too" > /workspace/mar
|
||||
separate, so `.credentials.yaml` and the session store are never part of the
|
||||
agent-visible workspace.
|
||||
|
||||
The template also sets `HOME=/workspace`. DSH's directory picker (the folder
|
||||
explorer used to choose a workspace) has no start-path setting: when it opens,
|
||||
its browse backend lists `$HOME`, so with the image default (`/home/node`, which
|
||||
is not on a volume) it would start outside the persisted tree. Pointing `HOME`
|
||||
at the workspace makes the picker open on it (labelled *Home* in its breadcrumbs)
|
||||
and makes `~` in agent commands mean `/workspace`. The trade-off is that tools
|
||||
keeping caches or config under `$HOME` (`npm`/`pnpm`, `uv`, `git`, `gh`, and
|
||||
DSH's global `~/.agents` instructions and skills) write dotfiles onto the PVC
|
||||
inside the agent workspace, where the agent and the file explorer can see them.
|
||||
`DSH_HOME` is explicit (`/home/node/.dsh`), so sessions, config and credentials
|
||||
are unaffected. Pod env is stamped when a sandbox is created: a sandbox from
|
||||
before this setting keeps `HOME=/home/node` until it is recreated (see
|
||||
[Troubleshooting](#troubleshooting)).
|
||||
|
||||
## 5. Suspend: delete the pod, keep the PVC + Service
|
||||
|
||||
```bash
|
||||
@@ -599,6 +614,8 @@ is non-recursive, so the optional manifest is not applied by the base step.
|
||||
| Sandbox cannot reach a model API after applying the optional NetworkPolicy | The policy allows DNS and public TCP `443` only; a proxy, custom base URL, port `80` or non-443 endpoint needs an explicit egress rule |
|
||||
| Gateway cannot reach a sandbox after applying an exposure NetworkPolicy | Check that the CNI enforces NetworkPolicy and that the Traefik/oauth2-proxy pod labels match; kubelet probes may also need the node CIDR |
|
||||
| New provider key not visible in a sandbox | Pod env is stamped at creation: delete the warm-pool spares and recreate claimed pods. A key saved in DSH's credential store also wins over env |
|
||||
| Folder picker opens on `/home/node` instead of the workspace | The sandbox was created before the template set `HOME=/workspace`, and pod env is stamped at creation. Verify with `kubectl -n dsh-demo exec "$SB" -- printenv HOME`; patch the sandbox's `podTemplate` with the env (or recreate the sandbox — the PVC keeps DSH state and workspace) and resume |
|
||||
| File explorer and `ls /workspace` show `.cache`, `.config`, `.local`, `.npm`, `.agents` | Expected with `HOME=/workspace`: `~`-relative tool caches and DSH's global agent instructions/skills live on the PVC inside the workspace. Remove the `HOME` env from the template (and recreate the sandbox) if you would rather keep the picker on the ephemeral image home; point caches elsewhere per tool if only they are unwanted |
|
||||
| Sandbox reports `Finished=True` and every gateway request fails | The sandbox Pod reached phase `Failed` (node eviction, spot reclaim) and the default `Retain` keeps it. Delete the Pod so the controller recreates it, or set `failedPodPolicy: Recreate` (agent-sandbox v1.0.8+; see optional hardening) |
|
||||
|
||||
## Limitations
|
||||
|
||||
@@ -166,6 +166,15 @@ volume with `subPath: workspace`, which keeps `.credentials.yaml` out of the age
|
||||
The idle sweeper never touches the volume; deleting the claim still garbage-collects it, so
|
||||
`POST /recreate` wipes state and workspace together.
|
||||
|
||||
**Workspace as home.** The template sets `HOME=/workspace`. DSH has no start-path setting for its
|
||||
directory picker: the browse backend lists `$HOME` when the dialog opens, so with the image default
|
||||
(`/home/node`, off the PVC) the picker would start on a throwaway directory. The override makes the
|
||||
picker open on the persisted workspace and makes `~` resolve there; the cost is that tool caches
|
||||
and config kept under `$HOME` (`npm`/`pnpm`, `uv`, `git`, `gh`, and DSH's global `~/.agents`
|
||||
instructions and skills) become dotfiles in the workspace. `DSH_HOME` stays `/home/node/.dsh`, so
|
||||
sessions, config and credentials remain outside the agent-visible tree. Pod env is stamped when a
|
||||
sandbox is created, so an existing sandbox keeps the old `HOME` until it is recreated.
|
||||
|
||||
**Ownership boundary.** The gateway shares its namespace with claims created outside it — the
|
||||
example's resource-layer walkthrough applies `dsh-alice` by hand, and every claim is named
|
||||
`dsh-<user>`. Claims the gateway creates carry `aaas.example.com/managed-by=dsh-gateway`; the
|
||||
|
||||
@@ -89,6 +89,23 @@ spec:
|
||||
name: dsh-provider-keys-extra
|
||||
optional: true
|
||||
env:
|
||||
# Point the OS home at the persisted agent workspace. DSH's
|
||||
# directory picker (the folder explorer used to choose a workspace)
|
||||
# has no start-path setting: when it opens it lists $HOME, and
|
||||
# os.homedir() follows this variable. The image default is
|
||||
# /home/node, which is not on a volume, so the picker would open on
|
||||
# a throwaway directory; /workspace is the PVC-backed WORKDIR. `~`
|
||||
# in agent commands resolves here too. Trade-off: tools that keep
|
||||
# caches/config under $HOME (npm/pnpm, uv, git, gh, and DSH's global
|
||||
# ~/.agents instructions and skills) now write dotfiles onto the PVC
|
||||
# inside the agent workspace, so they are visible to the agent and
|
||||
# in the file explorer. DSH_HOME is explicit (/home/node/.dsh), so
|
||||
# sessions, config and credentials are unaffected. Existing
|
||||
# sandboxes stamp pod env at creation and keep the old HOME until
|
||||
# recreated. Keep in sync with the minimal variant:
|
||||
# examples/minimal-single-tenant/manifests/sandbox-template.yaml.
|
||||
- name: HOME
|
||||
value: /workspace
|
||||
# Empty => DSH derives links from the request Host, which the
|
||||
# gateway forwards (plus X-Forwarded-*). Point this at the
|
||||
# gateway base URL if you want hard-coded absolute links instead.
|
||||
|
||||
@@ -72,6 +72,15 @@ pass "claim Ready in ${ELAPSED}s, adopted $SB"
|
||||
|
||||
echo "=== 3. write state on the PVC"
|
||||
POD="$SB"
|
||||
# HOME must point at the PVC-backed workspace: DSH's directory picker lists
|
||||
# $HOME when it opens and has no start-path setting, so this is what makes the
|
||||
# folder explorer start on the persisted tree instead of the ephemeral image
|
||||
# home. It also makes ~ resolve to /workspace inside agent commands.
|
||||
HOME_VALUE=$(kubectl -n "$NS" exec "$POD" -- printenv HOME)
|
||||
[ "$HOME_VALUE" = "/workspace" ] || fail "HOME is '$HOME_VALUE', expected /workspace"
|
||||
TILDE=$(kubectl -n "$NS" exec "$POD" -- sh -c 'cd ~ && pwd')
|
||||
[ "$TILDE" = "/workspace" ] || fail "~ resolves to '$TILDE', expected /workspace"
|
||||
pass "HOME=$HOME_VALUE and ~ resolve to the workspace"
|
||||
kubectl -n "$NS" exec "$POD" -- sh -c 'echo "remember me" > /home/node/.dsh/marker.txt'
|
||||
pass "state marker written in $POD"
|
||||
# The agent workspace must be the dsh-home PVC's workspace/ subPath, writable
|
||||
|
||||
@@ -101,6 +101,25 @@ kubectl -n dsh-demo port-forward "pod/$SB" 18081:3080
|
||||
> example or a reachable Service instead; see
|
||||
> [optional hardening](../dsh-agents-as-a-service/docs/optional-hardening.md).
|
||||
|
||||
## Folder picker and the workspace
|
||||
|
||||
The template sets `HOME=/workspace`. DSH's directory picker (the folder explorer
|
||||
used to choose a workspace) has no start-path setting: it lists `$HOME` when it
|
||||
opens, so with the image default (`/home/node`) it would start on a directory that
|
||||
is not persisted. Pointing `HOME` at the PVC-backed workspace makes the picker
|
||||
open there (labelled *Home* in its breadcrumbs) and makes `~` in agent commands
|
||||
resolve to `/workspace`. The trade-off is that `$HOME`-relative tool caches and
|
||||
config (`.cache`, `.config`, `.local`, `.npm`, `.agents`) are written into the
|
||||
workspace on the PVC. DSH state is unaffected: `DSH_HOME` stays
|
||||
`/home/node/.dsh`. The rationale and the list of affected paths are in
|
||||
[`10-sandboxtemplate.yaml`](../dsh-agents-as-a-service/manifests/10-sandboxtemplate.yaml).
|
||||
|
||||
Verify inside a running sandbox:
|
||||
|
||||
```bash
|
||||
kubectl -n dsh-demo exec "$SB" -- printenv HOME # /workspace
|
||||
```
|
||||
|
||||
## Network policy and optional hardening
|
||||
|
||||
The template omits `networkPolicyManagement`, so the agent-sandbox controller
|
||||
|
||||
@@ -69,6 +69,21 @@ spec:
|
||||
name: dsh-provider-keys-extra
|
||||
optional: true
|
||||
env:
|
||||
# Point the OS home at the persisted agent workspace. DSH's
|
||||
# directory picker (the folder explorer used to choose a workspace)
|
||||
# lists $HOME when it opens and has no start-path setting, so with
|
||||
# the image default (/home/node, not on a volume) it would open on a
|
||||
# throwaway directory. /workspace is the PVC-backed WORKDIR, so the
|
||||
# picker opens on the tree that survives suspend/resume, and `~` in
|
||||
# agent commands resolves there. Trade-off: tools that keep caches
|
||||
# or config under $HOME (npm/pnpm, uv, git, gh, DSH's global
|
||||
# ~/.agents instructions and skills) write dotfiles onto the PVC
|
||||
# inside the agent workspace. DSH_HOME is explicit
|
||||
# (/home/node/.dsh), so sessions, config and credentials are
|
||||
# unaffected. Rationale in full at
|
||||
# examples/dsh-agents-as-a-service/manifests/10-sandboxtemplate.yaml.
|
||||
- name: HOME
|
||||
value: /workspace
|
||||
# Empty => DSH derives links from the request Host. Keep it empty
|
||||
# when fronting the sandbox with a proxy/gateway.
|
||||
- name: DSH_PUBLIC_URL
|
||||
|
||||
Reference in New Issue
Block a user